Fix use of default font with font-family: styles

Base bumped.
Previsouly, parts of document in <p style="font-family: serif">
would be rendered with the first font set, and would not
follow change of font (unline other texts without styles).
That was observable with Embedded Styles set to On, but is even
more noticiable with the new Embedded Fonts setting set to off.
pull/3166/head
poire-z 7 years ago committed by Frans de Jonge
parent 774d2345e0
commit c24d75f18c

@ -1 +1 @@
Subproject commit b42a2b686ac0af88b70e4a44da065d3b7bed6433
Subproject commit 58112413f2a29fa227d47ae8e558ffdb74278aa9

@ -335,6 +335,26 @@ function CreDocument:setFontFace(new_font_face)
if new_font_face then
logger.dbg("CreDocument: set font face", new_font_face)
self._document:setStringProperty("font.face.default", new_font_face)
-- The following makes FontManager prefer this font in its match
-- algorithm, with the bias given (applies only to rendering of
-- elements with css font-family)
-- See: crengine/src/lvfntman.cpp LVFontDef::CalcMatch():
-- it will compute a score for each font, where it adds:
-- + 25600 if standard font family matches (inherit serif sans-serif
-- cursive fantasy monospace) (note that crengine registers all fonts as
-- "sans-serif", except if their name is "Times" or "Times New Roman")
-- + 6400 if they don't and none are monospace (ie:serif vs sans-serif,
-- prefer a sans-serif to a monospace if looking for a serif)
-- +256000 if font names match
-- So, here, we can bump the score of our default font, and we could use:
-- +1: uses existing real font-family, but use our font for
-- font-family: serif, sans-serif..., and fonts not found (or
-- embedded fonts disabled)
-- +25601: uses existing real font-family, but use our font even
-- for font-family: monospace
-- +256001: prefer our font to any existing font-family font
self._document:setAsPreferredFontWithBias(new_font_face, 1)
end
end

Loading…
Cancel
Save