add line space control feature for credocument

pull/2/merge
Qingping Hou 12 years ago
parent b3cdbeee19
commit bad329811d

@ -73,7 +73,8 @@ function CreDocument:init()
self.info.has_pages = false
self:_readMetadata()
self._document:setDefaultInterlineSpace(self.line_space_percent)
-- @TODO read line_space_percent from setting file 12.06 2012 (houqp)
--self._document:setDefaultInterlineSpace(self.line_space_percent)
end
function CreDocument:hintPage(pageno, zoom, rotation)
@ -103,6 +104,10 @@ function CreDocument:zoomFont(delta)
self._document:zoomFont(delta)
end
function CreDocument:setInterlineSpacePercent(percent)
self._document:setDefaultInterlineSpace(percent)
end
DocumentRegistry:addProvider("txt", "application/txt", CreDocument)
DocumentRegistry:addProvider("epub", "application/epub", CreDocument)
DocumentRegistry:addProvider("html", "application/html", CreDocument)

@ -1,13 +1,28 @@
ReaderFont = InputContainer:new{
key_events = {
ShowFontMenu = { {"F"}, doc = "show font menu"},
IncreaseSize = { { "Shift", Input.group.PgFwd }, doc = "increase font size", event = "ChangeSize", args = "increase" },
DecreaseSize = { { "Shift", Input.group.PgBack }, doc = "decrease font size", event = "ChangeSize", args = "decrease" },
IncreaseSize = {
{ "Shift", Input.group.PgFwd },
doc = "increase font size",
event = "ChangeSize", args = "increase" },
DecreaseSize = {
{ "Shift", Input.group.PgBack },
doc = "decrease font size",
event = "ChangeSize", args = "decrease" },
IncreaseLineSpace = {
{ "Alt", Input.group.PgFwd },
doc = "increase line space",
event = "ChangeLineSpace", args = "increase" },
DecreaseLineSpace = {
{ "Alt", Input.group.PgBack },
doc = "decrease line space",
event = "ChangeLineSpace", args = "decrease" },
},
dimen = Geom:new{ w = Screen:getWidth()-20, h = Screen:getHeight()-20},
font_face = nil,
font_size = nil,
line_space_percent = 100,
}
function ReaderFont:init()
@ -71,4 +86,20 @@ function ReaderFont:onChangeSize(direction)
return true
end
function ReaderFont:onChangeLineSpace(direction)
if direction == "decrease" then
self.line_space_percent = self.line_space_percent - 10
-- NuPogodi, 15.05.12: reduce lowest space_percent to 80
self.line_space_percent = math.max(self.line_space_percent, 80)
else
self.line_space_percent = self.line_space_percent + 10
self.line_space_percent = math.min(self.line_space_percent, 200)
end
msg = InfoMessage:new{"line spacing "..self.line_space_percent.."%"}
self.ui.document:setInterlineSpacePercent(self.line_space_percent)
self.ui:handleEvent(Event:new("UpdatePos"))
return true
end

Loading…
Cancel
Save