Skip to content

Commit

Permalink
if there is custom screen dpi also scale by dpi
Browse files Browse the repository at this point in the history
  • Loading branch information
chrox committed Oct 4, 2015
1 parent 3c4a3b6 commit d0bed73
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ffi/framebuffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function fb:new(o)
if o.init then o:init() end
return o
end
-- you can do the setup here, but remember to call this from
-- implementations!
function fb:init()
Expand Down Expand Up @@ -244,8 +244,15 @@ end
function fb:scaleBySize(px)
-- larger screen needs larger scale
local size_scale = math.min(self:getWidth(), self:getHeight())/600
-- if users custom screen dpi, also scale by dpi
local dpi_scale = size_scale
local custom_dpi = G_reader_settings:readSetting("screen_dpi")
if custom_dpi and self.device and self.device.display_dpi ~= self.dpi then
dpi_scale = self.dpi / 167
end
-- scaled positive px should also be positive
return math.ceil(px * size_scale)
return math.ceil(px * (size_scale + dpi_scale) / 2)
end
function fb:getRotationMode()
Expand Down

0 comments on commit d0bed73

Please sign in to comment.