Added Font Hinting toggle (#3182)

pull/3195/head
poire-z 7 years ago committed by Frans de Jonge
parent 2b3b310719
commit 75b7c4b524

@ -116,6 +116,10 @@ function ReaderFont:onReadSettings(config)
or G_reader_settings:readSetting("copt_font_weight") or 0
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
self.ui.document:setFontHinting(self.font_hinting)
self.line_space_percent = config:readSetting("line_space_percent")
or G_reader_settings:readSetting("copt_line_spacing")
or DCREREADER_CONFIG_LINE_SPACE_PERCENT_MEDIUM
@ -206,6 +210,13 @@ function ReaderFont:onToggleFontBolder(toggle)
return true
end
function ReaderFont:onSetFontHinting(mode)
self.font_hinting = mode
self.ui.document:setFontHinting(mode)
self.ui:handleEvent(Event:new("UpdatePos"))
return true
end
function ReaderFont:onSetFontGamma(gamma)
self.gamma_index = gamma
UIManager:show(Notification:new{
@ -222,6 +233,7 @@ function ReaderFont:onSaveSettings()
self.ui.doc_settings:saveSetting("header_font_face", self.header_font_face)
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("line_space_percent", self.line_space_percent)
self.ui.doc_settings:saveSetting("gamma_index", self.gamma_index)
end

@ -424,6 +424,11 @@ function CreDocument:setGammaIndex(index)
cre.setGammaIndex(index)
end
function CreDocument:setFontHinting(mode)
logger.dbg("CreDocument: set font hinting mode", mode)
self._document:setIntProperty("font.hinting.mode", mode)
end
function CreDocument:setStyleSheet(new_css)
logger.dbg("CreDocument: set style sheet", new_css)
self._document:setStyleSheet(new_css)

@ -136,6 +136,15 @@ local CreOptions = {
DCREREADER_CONFIG_DEFAULT_FONT_GAMMA,
DCREREADER_CONFIG_DARKER_FONT_GAMMA,
},
},
{
name = "font_hinting",
name_text = S.FONT_HINT,
toggle = {S.OFF, S.NATIVE, S.AUTO},
values = {0, 1, 2},
default_value = 2,
args = {0, 1, 2},
event = "SetFontHinting",
}
}
},

@ -23,6 +23,7 @@ S.AUTO_STRAIGHTEN = _("Auto Straighten")
S.INDENTATION = _("Indentation")
S.FONT_WEIGHT = _("Font Weight")
S.GAMMA = _("Gamma")
S.FONT_HINT = _("Font Hinting")
S.VIEW_MODE = _("View Mode")
S.EMBEDDED_STYLE = _("Embedded Style")
S.EMBEDDED_FONTS = _("Embedded Fonts")
@ -46,6 +47,7 @@ S.LIGHTER = _("lighter")
S.DEFAULT = _("default")
S.DARKER = _("darker")
S.DARKEST = _("darkest")
S.NATIVE = _("native")
S.LOW = _("low")
S.HIGH = _("high")
S.ZERO_DEG = _("0 deg")

Loading…
Cancel
Save