Merge pull request #273 from chrox/master

add DHINTCOUNT in defaults.lua
This commit is contained in:
{Qingping, Dave} Hou
2013-09-14 10:15:21 -07:00
8 changed files with 44 additions and 38 deletions

View File

@@ -1,7 +1,11 @@
-- number of page turns between full screen refresh
-- default to full refresh on every page turn
-- default to do a full refresh on every 6 page turns
DRCOUNTMAX = 6
-- number of pages for hinting
-- default to pre-rendering 2 pages
DHINTCOUNT = 2
-- full screen mode, 1 for true, 0 for false
DFULL_SCREEN = 1
@@ -26,6 +30,10 @@ DOUTER_PAGE_COLOR = 0
-- supported view mode includes: "scroll" and "page"
DCREREADER_VIEW_MODE = "page"
-- show dimmed area to indicate page overlap in "page" view mode,
-- default to false
DSHOWOVERLAP = false
-- koptreader config defaults
DKOPTREADER_CONFIG_FONT_SIZE = 1.0 -- range from 0.1 to 3.0
DKOPTREADER_CONFIG_TEXT_WRAP = 0 -- 1 = on, 0 = off
@@ -34,7 +42,7 @@ DKOPTREADER_CONFIG_DETECT_INDENT = 1 -- 1 = enable, 0 = disable
DKOPTREADER_CONFIG_DEFECT_SIZE = 1.0 -- range from 0.0 to 3.0
DKOPTREADER_CONFIG_PAGE_MARGIN = 0.10 -- range from 0.0 to 1.0
DKOPTREADER_CONFIG_LINE_SPACING = 1.2 -- range from 0.5 to 2.0
DKOPTREADER_CONFIG_RENDER_QUALITY = 0.8 -- range from 0.5 to 1.0
DKOPTREADER_CONFIG_RENDER_QUALITY = 1.0 -- range from 0.5 to 2.0
DKOPTREADER_CONFIG_AUTO_STRAIGHTEN = 0 -- range from 0 to 10
DKOPTREADER_CONFIG_JUSTIFICATION = -1 -- -1 = auto, 0 = left, 1 = center, 2 = right, 3 = full
DKOPTREADER_CONFIG_MAX_COLUMNS = 2 -- range from 1 to 4

View File

@@ -46,6 +46,12 @@ function KoptInterface:createContext(doc, pageno, bbox)
-- So there is no need to check background context when creating new context.
local kc = KOPTContext.new()
local screen_size = Screen:getSize()
local lang = doc.configurable.doc_language
if lang == "chi_sim" or lang == "chi_tra" or
lang == "jpn" or lang == "kor" then
kc:setCJKChar()
end
kc:setLanguage(lang)
kc:setTrim(doc.configurable.trim_page)
kc:setWrap(doc.configurable.text_wrap)
kc:setIndent(doc.configurable.detect_indent)
@@ -62,8 +68,7 @@ function KoptInterface:createContext(doc, pageno, bbox)
kc:setDefectSize(doc.configurable.defect_size)
kc:setLineSpacing(doc.configurable.line_spacing)
kc:setWordSpacing(doc.configurable.word_spacing)
kc:setLanguage(doc.configurable.doc_language)
kc:setBBox(bbox.x0, bbox.y0, bbox.x1, bbox.y1)
if bbox then kc:setBBox(bbox.x0, bbox.y0, bbox.x1, bbox.y1) end
if Dbg.is_on then kc:setDebug() end
return kc
end
@@ -133,12 +138,6 @@ function KoptInterface:getReflewTextBoxes(doc, pageno)
if cached then
local kc = self:waitForContext(cached.kctx)
--kc:setDebug()
local lang = doc.configurable.doc_language
if lang == "chi_sim" or lang == "chi_tra" or
lang == "jpn" or lang == "kor" then
kc:setCJKChar()
end
kc:setLanguage(lang)
local fullwidth, fullheight = kc:getPageDim()
local boxes = kc:getWordBoxes(0, 0, fullwidth, fullheight)
Cache:insert(hash, CacheItem:new{ rfpgboxes = boxes })
@@ -154,14 +153,8 @@ function KoptInterface:getTextBoxes(doc, pageno)
local cached = Cache:check(hash)
if not cached then
local kc_hash = "kctx|"..doc.file.."|"..pageno
local kc = KOPTContext.new()
local kc = self:createContext(doc, pageno)
kc:setDebug()
local lang = doc.configurable.doc_language
if lang == "chi_sim" or lang == "chi_tra" or
lang == "jpn" or lang == "kor" then
kc:setCJKChar()
end
kc:setLanguage(lang)
local page = doc._document:openPage(pageno)
page:getPagePix(kc)
local fullwidth, fullheight = kc:getPageDim()

View File

@@ -3,6 +3,21 @@ ReaderHinting = EventListener:new{
hinting_states = {}
}
function ReaderHinting:onHintPage()
if not self.view.hinting then return true end
for i=1, DHINTCOUNT do
if self.zoom.current_page + i <= self.ui.document.info.number_of_pages then
self.ui.document:hintPage(
self.view.state.page + i,
self.zoom:getZoom(self.view.state.page + i),
self.view.state.rotation,
self.view.state.gamma,
self.view.render_mode)
end
end
return true
end
function ReaderHinting:onSetHinting(hinting)
self.view.hinting = hinting
end
@@ -16,4 +31,4 @@ end
function ReaderHinting:onRestoreHinting()
self.view.hinting = table.remove(self.hinting_states)
return true
end
end

View File

@@ -5,7 +5,7 @@ ReaderPaging = InputContainer:new{
number_of_pages = 0,
visible_area = nil,
page_area = nil,
show_overlap_enable = true,
show_overlap_enable = DSHOWOVERLAP,
overlap = scaleByDPI(20),
flip_steps = {0,1,2,5,10,20,50,100}
}

View File

@@ -161,19 +161,6 @@ function ReaderZooming:onReZoom()
return true
end
function ReaderZooming:onHintPage()
if not self.view.hinting then return true end
if self.current_page < self.ui.document.info.number_of_pages then
self.ui.document:hintPage(
self.view.state.page + 1,
self:getZoom(self.view.state.page + 1),
self.view.state.rotation,
self.view.state.gamma,
self.view.render_mode)
end
return true
end
function ReaderZooming:getZoom(pageno)
-- check if we're in bbox mode and work on bbox if that's the case
local zoom = nil

View File

@@ -173,6 +173,7 @@ function ReaderUI:init()
-- hinting controller
local hinter = ReaderHinting:new{
dialog = self.dialog,
zoom = zoomer,
view = self[1],
ui = self,
document = self.document,

View File

@@ -153,11 +153,13 @@ function TextBoxWidget:_getVerticalList(alg)
-- build horizontal list
local h_list = {}
for words in self.text:gmatch("[\32-\127\192-\255]+[\128-\191]*") do
for w in words:gsplit("%s+", true) do
local word_box = {}
word_box.word = w
word_box.width = sizeUtf8Text(0, Screen:getWidth(), self.face, w, true).x
table.insert(h_list, word_box)
for word in words:gsplit("%s+", true) do
for w in word:gsplit("%p+", true) do
local word_box = {}
word_box.word = w
word_box.width = sizeUtf8Text(0, Screen:getWidth(), self.face, w, true).x
table.insert(h_list, word_box)
end
end
end