2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00

ReaderFont: display preview of italic-only fonts in italic (#12351)

In font selection menus, ask creengine for italic versions
of fonts if there's no regular version to preview.
Also prevents a crash when a font can't be previewed in
the font family menu.
This commit is contained in:
charrarr 2024-08-18 07:28:23 +00:00 committed by GitHub
parent 2403087f68
commit 91c15d5277
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -72,6 +72,10 @@ function ReaderFont:setupFaceMenuTable()
face_list = self:sortFaceList(face_list)
for k, v in ipairs(face_list) do
local font_filename, font_faceindex, is_monospace = cre.getFontFaceFilenameAndFaceIndex(v)
if not font_filename then
-- The font may be available only in italic, for example script/cursive fonts
font_filename, font_faceindex, is_monospace = cre.getFontFaceFilenameAndFaceIndex(v, nil, true)
end
table.insert(self.face_table, {
text_func = function()
-- defaults are hardcoded in credocument.lua
@ -572,6 +576,9 @@ Enabling this will ignore such font names and make sure your preferred family fo
}
for k, v in ipairs(face_list) do
local font_filename, font_faceindex, is_monospace, has_ot_math, has_emojis = cre.getFontFaceFilenameAndFaceIndex(v)
if not font_filename then
font_filename, font_faceindex, is_monospace, has_ot_math, has_emojis = cre.getFontFaceFilenameAndFaceIndex(v, nil, true)
end
if i == 1 then
face_to_filename[v] = { font_filename, font_faceindex }
end

View File

@ -268,7 +268,7 @@ end
-- @treturn table @{FontFaceObj}
function Font:getFace(font, size, faceindex)
-- default to content font
if not font then font = self.cfont end
if not font then font = self.fontmap.cfont end
if not size then size = self.sizemap[font] end
-- original size before scaling by screen DPI