diff --git a/base b/base index 10d3aa437..f8cb8ab82 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 10d3aa43753d36e6449d54609a949524b7bd1959 +Subproject commit f8cb8ab825a2ccdd962ce7c8b5f03fc5cbcd5267 diff --git a/frontend/apps/reader/modules/readerfont.lua b/frontend/apps/reader/modules/readerfont.lua index 7e1f9368b..3953915e5 100644 --- a/frontend/apps/reader/modules/readerfont.lua +++ b/frontend/apps/reader/modules/readerfont.lua @@ -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) diff --git a/frontend/document/credocument.lua b/frontend/document/credocument.lua index cf89ddddc..999b98bcf 100644 --- a/frontend/document/credocument.lua +++ b/frontend/document/credocument.lua @@ -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) diff --git a/frontend/ui/data/creoptions.lua b/frontend/ui/data/creoptions.lua index d35d33322..dab927de3 100644 --- a/frontend/ui/data/creoptions.lua +++ b/frontend/ui/data/creoptions.lua @@ -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", diff --git a/frontend/ui/data/strings.lua b/frontend/ui/data/strings.lua index da3c0ec1c..05fc0fa82 100644 --- a/frontend/ui/data/strings.lua +++ b/frontend/ui/data/strings.lua @@ -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")