mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
remove rescaleByDPI since it's not reversible
alternatively we store the original size before scaling by screen DPI and use that value when needed.
This commit is contained in:
@@ -171,10 +171,6 @@ function Screen:scaleByDPI(px)
|
||||
return math.ceil(px * self:getDPI()/167)
|
||||
end
|
||||
|
||||
function Screen:rescaleByDPI(px)
|
||||
return math.ceil(px * 167/self:getDPI())
|
||||
end
|
||||
|
||||
function Screen:getRotationMode()
|
||||
return self.cur_rotation_mode
|
||||
end
|
||||
|
||||
@@ -54,6 +54,8 @@ function Font:getFace(font, size)
|
||||
font = self.cfont
|
||||
end
|
||||
|
||||
-- original size before scaling by screen DPI
|
||||
local orig_size = size
|
||||
local size = Screen:scaleByDPI(size)
|
||||
|
||||
local face = self.faces[font..size]
|
||||
@@ -72,7 +74,7 @@ function Font:getFace(font, size)
|
||||
self.faces[font..size] = face
|
||||
--DEBUG("getFace, found: "..realname.." size:"..size)
|
||||
end
|
||||
return { size = size, ftface = face, hash = font..size }
|
||||
return { size = size, orig_size = orig_size, ftface = face, hash = font..size }
|
||||
end
|
||||
|
||||
function Font:_readList(target, dir, effective_dir)
|
||||
|
||||
@@ -73,8 +73,8 @@ function RenderText:getGlyph(face, charcode, bold, bgcolor, fgcolor)
|
||||
local rendered_glyph = face.ftface:renderGlyph(charcode, bgcolor, fgcolor, bold)
|
||||
if face.ftface:checkGlyph(charcode) == 0 then
|
||||
for index, font in pairs(Font.fallbacks) do
|
||||
-- rescale face size by DPI since it will be scaled in getFace again
|
||||
local fb_face = Font:getFace(font, Screen:rescaleByDPI(face.size))
|
||||
-- use original size before scaling by screen DPI
|
||||
local fb_face = Font:getFace(font, face.orig_size)
|
||||
if fb_face.ftface:checkGlyph(charcode) ~= 0 then
|
||||
rendered_glyph = fb_face.ftface:renderGlyph(charcode, bgcolor, fgcolor, bold)
|
||||
--DEBUG("fallback to font", font)
|
||||
|
||||
Reference in New Issue
Block a user