Skip to content

Commit

Permalink
[chore] decouple reader setting from framebuffer (#822)
Browse files Browse the repository at this point in the history
  • Loading branch information
houqp authored and Frenzie committed Mar 3, 2019
1 parent 5cce446 commit 7fb4218
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ffi/framebuffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,21 +254,26 @@ function fb:getScreenHeight()
return self.screen_size.h
end

local screen_dpi_override

function fb:getDPI()
if self.dpi == nil then
self.dpi = EMULATE_READER_DPI or G_reader_settings:readSetting("screen_dpi")
end
if self.dpi ~= nil then return self.dpi end

self.dpi = EMULATE_READER_DPI or screen_dpi_override

if self.dpi == nil and self.device then
self.dpi = self.device.display_dpi
end

if self.dpi == nil then
self.dpi = 160
end

return self.dpi
end

function fb:setDPI(dpi)
G_reader_settings:saveSetting("screen_dpi", dpi)
screen_dpi_override = dpi
end

function fb:scaleByDPI(px)
Expand All @@ -282,7 +287,7 @@ function fb:scaleBySize(px)
-- if users custom screen dpi, also scale by dpi
local dpi_scale = size_scale

local custom_dpi = EMULATE_READER_DPI or G_reader_settings:readSetting("screen_dpi")
local custom_dpi = EMULATE_READER_DPI or screen_dpi_override
if custom_dpi and self.device and self.device.display_dpi ~= self.dpi then
dpi_scale = self.dpi / 167
end
Expand Down

0 comments on commit 7fb4218

Please sign in to comment.