bump crengine: more granular font weights (#7616)

Includes:
- MathML: a few minor fixes
- (Upstream) lvtext: fix possible index out of range
- Fonts: RegisterExternalFont() should take a documentId
- Fonts: fix: letter-spacing should not be applied on diacritic
- (Upstream) Fonts: more granular synthetic weights
- Fonts: synthesized weights: tweak some comments
- Fonts: keep hinting with synthetic weight
- Fonts: fix synthesized weight inconsitencies
- Fonts: fix getFontFileNameAndFaceIndex()
- Fonts: adds LVFontMan::RegularizeRegisteredFontsWeights()
- Fonts: handle synth_weight tweaks in glyph/glyphinfo slots
- (Upstream) Fonts: fix some compiler warnings
- Fix hyphenation on Armenian and Georgian text

Update the bottom menu widget "Font Weight" to allow more
granular weights than the previous "regular | bold".

Also bump thirdparty/luasec to v1.0.1.
reviewable/pr7611/r5
poire-z 3 years ago committed by GitHub
parent 3cb9508185
commit 9ef435c97a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1 @@
Subproject commit 4774d294aa9bca74179996e75a09367819872e8b
Subproject commit 85dacfbba80e4f7a540ef9de3dff1186440d707b

@ -127,10 +127,10 @@ function ReaderFont:onReadSettings(config)
or 22
self.ui.document:setFontSize(Screen:scaleBySize(self.font_size))
self.font_embolden = config:readSetting("font_embolden")
or G_reader_settings:readSetting("copt_font_weight")
self.font_base_weight = config:readSetting("font_base_weight")
or G_reader_settings:readSetting("copt_font_base_weight")
or 0
self.ui.document:toggleFontBolder(self.font_embolden)
self.ui.document:setFontBaseWeight(self.font_base_weight)
self.font_hinting = config:readSetting("font_hinting")
or G_reader_settings:readSetting("copt_font_hinting")
@ -238,9 +238,9 @@ function ReaderFont:onSetLineSpace(space)
return true
end
function ReaderFont:onToggleFontBolder(toggle)
self.font_embolden = toggle
self.ui.document:toggleFontBolder(toggle)
function ReaderFont:onSetFontBaseWeight(weight)
self.font_base_weight = weight
self.ui.document:setFontBaseWeight(weight)
self.ui:handleEvent(Event:new("UpdatePos"))
return true
end
@ -288,7 +288,7 @@ function ReaderFont:onSaveSettings()
self.ui.doc_settings:saveSetting("font_face", self.font_face)
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_base_weight", self.font_base_weight)
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("word_spacing", self.word_spacing)

@ -146,7 +146,7 @@ local settingsList = {
render_dpi = {category="string", rolling=true},
line_spacing = {category="absolutenumber", rolling=true, separator=true,},
font_size = {category="absolutenumber", title=_("Set font size to %1"), rolling=true},
font_weight = {category="string", rolling=true},
font_base_weight = {category="string", rolling=true},
font_gamma = {category="string", rolling=true},
font_hinting = {category="string", rolling=true},
font_kerning = {category="string", rolling=true, separator=true,},
@ -251,7 +251,7 @@ local dispatcher_menu_order = {
"decrease_font",
"font_size",
"font_gamma",
"font_weight",
"font_base_weight",
"font_hinting",
"font_kerning",

@ -118,6 +118,14 @@ function CreDocument:engineInit()
end
end
end
-- Make sure registered fonts have a proper entry at weight 400 and 700 when
-- possible, to avoid having synthesized fonts for these normal and bold weights.
-- This allows restoring a bit of the previous behaviour of crengine when it
-- wasn't handling font styles, and associated for each typeface one single
-- font to regular (400) and one to bold (700).
-- It should ensure we use real fonts (and not synthesized ones) for normal text
-- and bold text with the font_base_weight setting set to its default value of 0 (=400).
cre.regularizeRegisteredFontsWeights(true) -- true to print what modifications were made
engine_initialized = true
end
@ -1067,9 +1075,12 @@ function CreDocument:setInterlineSpacePercent(percent)
self._document:setDefaultInterlineSpace(percent)
end
function CreDocument:toggleFontBolder(toggle)
logger.dbg("CreDocument: toggle font bolder", toggle)
self._document:setIntProperty("font.face.weight.embolden", toggle)
function CreDocument:setFontBaseWeight(weight)
-- In frontend, we use: 0, 1, -0.5, a delta from the regular weight of 400.
-- crengine expects for these: 400, 500, 350
local cre_weight = math.floor(400 + weight*100)
logger.dbg("CreDocument: set font base weight", weight, "=", cre_weight)
self._document:setIntProperty("font.face.base.weight", cre_weight)
end
function CreDocument:getGammaLevel()

@ -3,6 +3,7 @@ local Screen = Device.screen
local optionsutil = require("ui/data/optionsutil")
local _ = require("gettext")
local C_ = _.pgettext
local T = require("ffi/util").template
-- Get font size numbers as a table of strings
local tableOfNumbersToTableOfStrings = function(numbers)
@ -492,16 +493,6 @@ Note that your selected font size is not affected by this setting.]]),
{
icon = "appbar.contrast",
options = {
{
name = "font_weight",
name_text = _("Font Weight"),
toggle = {_("regular"), _("bold")},
values = {0, 1},
default_value = 0,
args = {0, 1},
event = "ToggleFontBolder",
name_text_hold_callback = optionsutil.showValues,
},
{
name = "font_gamma",
name_text = _("Contrast"),
@ -528,6 +519,39 @@ Note that your selected font size is not affected by this setting.]]),
value_step = 1,
},
},
{
name = "font_base_weight",
name_text = _("Font Weight"),
toggle = { "-1", "", "0", "", "+1", "+1½", "+3" },
values = { -1, -0.5, 0, 0.5, 1, 1.5, 3 },
args = { -1, -0.5, 0, 0.5, 1, 1.5, 3 },
default_value = 0,
event = "SetFontBaseWeight",
more_options = true,
more_options_param = {
value_min = -3,
value_max = 5.5,
value_step = 0.25,
precision = "%+.2f",
value_hold_step = 1,
},
help_text = _([[Set the font weight delta from "regular" to apply to all fonts.
- 0 will use the "regular (400)" variation of a font.
- +1 will use the "medium (500)" variation of a font if available
- +3 will use the "bold (700)" variation of a font if available
If a font variation is not available, as well as for fractional adjustments, a font variation will be synthesized from the nearest available weight of the font.]]),
help_text_func = function(configurable, document)
local font_face = document:getFontFace()
local available_weights = cre.getFontFaceAvailableWeights(font_face)
return T(_("The default font '%1' is available in %2."), font_face, table.concat(available_weights, ", "))
end,
name_text_hold_callback = optionsutil.showValues,
name_text_true_values = true,
show_true_value_func = function(val)
return string.format("%d", 400+val*100)
end,
},
{
name = "font_hinting",
name_text = _("Font Hinting"),

@ -13,7 +13,7 @@ function optionsutil.enableIfEquals(configurable, option, value)
return configurable[option] == value
end
function optionsutil.showValues(configurable, option, prefix)
function optionsutil.showValues(configurable, option, prefix, document)
local default = G_reader_settings:readSetting(prefix.."_"..option.name)
local current = configurable[option.name]
local value_default, value_current
@ -98,6 +98,10 @@ function optionsutil.showValues(configurable, option, prefix)
if option.help_text then
help_text = T("\n%1\n", option.help_text)
end
if option.help_text_func then
-- Allow for concatenating a dynamic help_text_func to a static help_text
help_text = T("%1\n%2\n", help_text, option.help_text_func(configurable, document))
end
local text
local name_text = option.name_text_func
and option.name_text_func(configurable)

@ -299,7 +299,7 @@ function ConfigOption:init()
hold_callback = function()
if self.options[c].name_text_hold_callback then
self.options[c].name_text_hold_callback(self.config.configurable, self.options[c],
self.config.config_options.prefix)
self.config.config_options.prefix, self.config.document)
end
end,
}

Loading…
Cancel
Save