2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

Merge pull request #415 from chrox/master

fix font size change when reopening the same credocument
This commit is contained in:
Qingping Hou 2013-12-25 15:25:20 -08:00
commit 043b8cfd96
7 changed files with 18 additions and 17 deletions

View File

@ -40,6 +40,7 @@ function FileManager:init()
local file_chooser = FileChooser:new{
-- remeber to adjust the height when new item is added to the group
path = self.root_path,
show_parent = self.show_parent,
height = Screen:getHeight() - self.banner:getSize().h,
is_popout = false,
is_borderless = true,

View File

@ -22,14 +22,6 @@ function ReaderCoptListener:onReadSettings(config)
end)
end
local copt_font_size = config:readSetting("copt_font_size")
if copt_font_size then
table.insert(self.ui.postInitCallback, function()
self.ui.document:setFontSize(copt_font_size)
self.ui:handleEvent(Event:new("UpdatePos"))
end)
end
local copt_margins = config:readSetting("copt_page_margins")
if copt_margins then
table.insert(self.ui.postInitCallback, function()

View File

@ -8,6 +8,7 @@ local Input = require("ui/input")
local Event = require("ui/event")
local UIManager = require("ui/uimanager")
local Screen = require("ui/screen")
local DEBUG = require("dbg")
local _ = require("gettext")
local ReaderFont = InputContainer:new{
@ -80,7 +81,7 @@ function ReaderFont:onReadSettings(config)
--@TODO change this! 12.01 2013 (houqp)
self.font_size = 29
end
self.ui.document:setFontSize(self.font_size)
self.ui.document:setFontSize(Screen:scaleByDPI(self.font_size))
self.line_space_percent = config:readSetting("line_space_percent")
if not self.line_space_percent then

View File

@ -6,6 +6,7 @@ local Input = require("ui/input")
local Event = require("ui/event")
local GestureRange = require("ui/gesturerange")
local ReaderPanning = require("ui/reader/readerpanning")
local UIManager = require("ui/uimanager")
local DEBUG = require("dbg")
local _ = require("gettext")
@ -243,7 +244,7 @@ end
function ReaderRolling:onZoom()
--@TODO re-read doc_height info after font or lineheight changes 05.06 2012 (houqp)
self:onUpdatePos()
self:updatePos()
end
--[[
@ -251,6 +252,11 @@ end
font has been changed, or line height has been changed.
--]]
function ReaderRolling:onUpdatePos()
UIManager:scheduleIn(0.1, function () self:updatePos() end)
return true
end
function ReaderRolling:updatePos()
-- reread document height
self.ui.document:_readMetadata()
-- update self.current_pos if the height of document has been changed.
@ -262,7 +268,6 @@ function ReaderRolling:onUpdatePos()
self.old_page = new_page
self.ui:handleEvent(Event:new("UpdateToc"))
end
return true
end
function ReaderRolling:onChangeViewMode()

View File

@ -573,6 +573,7 @@ function ReaderView:onSetPageMargins(margins)
local right = margins[3]
local bottom = margins[4]
self.ui.document:setPageMargins(left, top, right, bottom)
self.ui:handleEvent(Event:new("UpdatePos"))
return true
end

View File

@ -509,6 +509,7 @@ function ConfigDialog:onConfigChoice(option_name, option_value)
--DEBUG("config option value", option_name, option_value)
self.configurable[option_name] = option_value
self.ui:handleEvent(Event:new("StartActivityIndicator"))
self:closeDialog()
return true
end

View File

@ -169,7 +169,7 @@ function MenuItem:init()
end
local text_container = LeftContainer:new{
dimen = Geom:new{w = self.content_width},
dimen = Geom:new{w = self.content_width, h = self.dimen.h},
TextWidget:new{
text = self.text,
face = self.face,
@ -177,7 +177,7 @@ function MenuItem:init()
}
local mandatory_container = RightContainer:new{
dimen = Geom:new{w = self.content_width},
dimen = Geom:new{w = self.content_width, h = self.dimen.h},
TextWidget:new{
text = mandatory,
face = self.info_face,
@ -192,6 +192,7 @@ function MenuItem:init()
HorizontalGroup:new{
align = "center",
OverlapGroup:new{
dimen = Geom:new{w = self.content_width, h = self.dimen.h},
text_container,
mandatory_container,
},
@ -245,16 +246,15 @@ function MenuItem:onTapSelect()
return true
end
--[[
Widget that displays menu
--]]
local Menu = FocusManager:new{
show_parent = nil,
-- face for displaying item contents
cface = Font:getFace("cfont", 22),
cface = Font:getFace("cfont", 24),
-- face for menu title
tface = Font:getFace("tfont", 25),
tface = Font:getFace("tfont", 26),
-- face for paging info display
fface = Font:getFace("ffont", 16),
-- font for item shortcut
@ -302,7 +302,7 @@ function Menu:_recalculateDimen()
end
self.item_dimen = Geom:new{
w = self.dimen.w,
h = Screen:scaleByDPI(36), -- hardcoded for now
h = Screen:scaleByDPI(46), -- hardcoded for now
}
self.perpage = math.floor((self.dimen.h - self.dimen.x) / self.item_dimen.h) - 2
self.page_num = math.ceil(#self.item_table / self.perpage)