mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Font menu: show font names with their own font
This commit is contained in:
@@ -214,8 +214,9 @@ end
|
||||
--- Gets font face object.
|
||||
-- @string font
|
||||
-- @int size optional size
|
||||
-- @int faceindex optional index of font face in font file
|
||||
-- @treturn table @{FontFaceObj}
|
||||
function Font:getFace(font, size)
|
||||
function Font:getFace(font, size, faceindex)
|
||||
-- default to content font
|
||||
if not font then font = self.cfont end
|
||||
|
||||
@@ -235,6 +236,9 @@ function Font:getFace(font, size)
|
||||
-- Make a hash from the realname (many fonts in our fontmap use
|
||||
-- the same font file: have them share their glyphs cache)
|
||||
local hash = realname..size
|
||||
if faceindex then
|
||||
hash = hash .. "/" .. faceindex
|
||||
end
|
||||
|
||||
local face_obj = self.faces[hash]
|
||||
if face_obj then
|
||||
@@ -250,7 +254,7 @@ function Font:getFace(font, size)
|
||||
else
|
||||
-- Build face if not found
|
||||
local builtin_font_location = FontList.fontdir.."/"..realname
|
||||
local ok, face = pcall(Freetype.newFace, builtin_font_location, size)
|
||||
local ok, face = pcall(Freetype.newFace, builtin_font_location, size, faceindex)
|
||||
|
||||
-- Not all fonts are bundled on all platforms because they come with the system.
|
||||
-- In that case, search through all font folders for the requested font.
|
||||
@@ -261,7 +265,7 @@ function Font:getFace(font, size)
|
||||
for _k, _v in ipairs(fonts) do
|
||||
if _v:find(escaped_realname) then
|
||||
logger.dbg("Found font:", realname, "in", _v)
|
||||
ok, face = pcall(Freetype.newFace, _v, size)
|
||||
ok, face = pcall(Freetype.newFace, _v, size, faceindex)
|
||||
|
||||
if ok then break end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user