cre: configurable kerning method (off/freetype/harfbuzz) (#4167)

Bump base & crengine for HarfBuzz support.
pull/4172/head
poire-z 6 years ago committed by GitHub
parent 4428ecb422
commit 6f2368e3bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1 @@
Subproject commit 10d3aa43753d36e6449d54609a949524b7bd1959
Subproject commit f8cb8ab825a2ccdd962ce7c8b5f03fc5cbcd5267

@ -147,9 +147,13 @@ function ReaderFont:onReadSettings(config)
self.ui.document:toggleFontBolder(self.font_embolden)
self.font_hinting = config:readSetting("font_hinting")
or G_reader_settings:readSetting("copt_font_hinting") or 2 -- default in cre.cpp
or G_reader_settings:readSetting("copt_font_hinting") or 2 -- auto (default in cre.cpp)
self.ui.document:setFontHinting(self.font_hinting)
self.font_kerning = config:readSetting("font_kerning")
or G_reader_settings:readSetting("copt_font_kerning") or 1 -- freetype (default in cre.cpp)
self.ui.document:setFontKerning(self.font_kerning)
self.space_condensing = config:readSetting("space_condensing")
or G_reader_settings:readSetting("copt_space_condensing") or 75
self.ui.document:setSpaceCondensing(self.space_condensing)
@ -254,6 +258,13 @@ function ReaderFont:onSetFontHinting(mode)
return true
end
function ReaderFont:onSetFontKerning(mode)
self.font_kerning = mode
self.ui.document:setFontKerning(mode)
self.ui:handleEvent(Event:new("UpdatePos"))
return true
end
function ReaderFont:onSetSpaceCondensing(space)
self.space_condensing = space
self.ui.document:setSpaceCondensing(space)
@ -279,6 +290,7 @@ function ReaderFont:onSaveSettings()
self.ui.doc_settings:saveSetting("font_size", self.font_size)
self.ui.doc_settings:saveSetting("font_embolden", self.font_embolden)
self.ui.doc_settings:saveSetting("font_hinting", self.font_hinting)
self.ui.doc_settings:saveSetting("font_kerning", self.font_kerning)
self.ui.doc_settings:saveSetting("space_condensing", self.space_condensing)
self.ui.doc_settings:saveSetting("line_space_percent", self.line_space_percent)
self.ui.doc_settings:saveSetting("gamma_index", self.gamma_index)

@ -541,6 +541,11 @@ function CreDocument:setFontHinting(mode)
self._document:setIntProperty("font.hinting.mode", mode)
end
function CreDocument:setFontKerning(mode)
logger.dbg("CreDocument: set font kerning mode", mode)
self._document:setIntProperty("font.kerning.mode", mode)
end
-- min space condensing percent (how much we can decrease a space width to
-- make text fit on a line) 25...100%
function CreDocument:setSpaceCondensing(value)

@ -178,6 +178,23 @@ Note that your selected font size is not affected by this setting.]]),
- off: no hinting.
- native: use the font internal hinting instructions.
- auto: use FreeType's hinting algorithm, ignoring font instructions.]]),
},
{
name = "font_kerning",
name_text = S.FONT_KERNING,
toggle = {S.OFF, S.FAST, S.ENHANCED},
values = {0, 1, 2},
default_value = 1,
args = {0, 1, 2},
event = "SetFontKerning",
name_text_hold_callback = optionsutil.showValues,
help_text = _([[Font kerning is the process of adjusting the spacing between individual letter forms, to achieve a visually pleasing result.
- off: no kerning.
- fast: use FreeType's kerning implementation (no ligatures).
- enhanced: use HarfBuzz's kerning implementation (slower, but may support ligatures with some fonts).
(Font Hinting may need to be adjusted for the best result with either kerning implementation.)]]),
},
{
name = "space_condensing",

@ -25,6 +25,7 @@ S.INDENTATION = _("Indentation")
S.FONT_WEIGHT = _("Font Weight")
S.GAMMA = _("Gamma")
S.FONT_HINT = _("Font Hinting")
S.FONT_KERNING = _("Font Kerning")
S.VIEW_MODE = _("View Mode")
S.EMBEDDED_STYLE = _("Embedded Style")
S.EMBEDDED_FONTS = _("Embedded Fonts")
@ -48,6 +49,8 @@ S.LIGHTER = _("lighter")
S.DEFAULT = _("default")
S.DARKER = _("darker")
S.NATIVE = _("native")
S.FAST = _("fast")
S.ENHANCED = _("enhanced")
S.LOW = _("low")
S.HIGH = _("high")
S.ZERO_DEG = _("0 deg")

Loading…
Cancel
Save