From 7fb169660a8d85d0c4a666cd2d8a69f8dafc5715 Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 14 Sep 2013 12:55:13 +0800 Subject: [PATCH 1/7] update koreader-base --- koreader-base | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koreader-base b/koreader-base index 7266a9276..1940f8bd8 160000 --- a/koreader-base +++ b/koreader-base @@ -1 +1 @@ -Subproject commit 7266a9276b7cb62b44b31291ce54c58cf96005a1 +Subproject commit 1940f8bd8b7c3c7c855d4fc7e1e86ea3f148c015 From f2cf10a015864b807d854c22eab420088e0f01e8 Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 14 Sep 2013 12:56:10 +0800 Subject: [PATCH 2/7] refactoring koptcontext creation function --- frontend/document/koptinterface.lua | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/frontend/document/koptinterface.lua b/frontend/document/koptinterface.lua index 50422d185..1fa2f01a1 100644 --- a/frontend/document/koptinterface.lua +++ b/frontend/document/koptinterface.lua @@ -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() From 979d4c5d4811a85eb759c8c6e0edb8d2e2a60b52 Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 14 Sep 2013 15:27:11 +0800 Subject: [PATCH 3/7] add DHINTCOUNT in defaults.lua It controls how many number of pages will be hinted in background after one page has been drawn. Default DHINTCOUNT is 2. --- defaults.lua | 6 +++++- frontend/ui/reader/readerhinting.lua | 17 ++++++++++++++++- frontend/ui/reader/readerzooming.lua | 13 ------------- frontend/ui/readerui.lua | 1 + koreader-base | 2 +- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/defaults.lua b/defaults.lua index 1eefe2292..c78a6492b 100644 --- a/defaults.lua +++ b/defaults.lua @@ -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 diff --git a/frontend/ui/reader/readerhinting.lua b/frontend/ui/reader/readerhinting.lua index 1fad17ba1..cc16c0c6e 100644 --- a/frontend/ui/reader/readerhinting.lua +++ b/frontend/ui/reader/readerhinting.lua @@ -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 \ No newline at end of file +end diff --git a/frontend/ui/reader/readerzooming.lua b/frontend/ui/reader/readerzooming.lua index d9618f1c8..073818e39 100644 --- a/frontend/ui/reader/readerzooming.lua +++ b/frontend/ui/reader/readerzooming.lua @@ -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 diff --git a/frontend/ui/readerui.lua b/frontend/ui/readerui.lua index 171283245..699470024 100644 --- a/frontend/ui/readerui.lua +++ b/frontend/ui/readerui.lua @@ -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, diff --git a/koreader-base b/koreader-base index 1940f8bd8..88c26d984 160000 --- a/koreader-base +++ b/koreader-base @@ -1 +1 @@ -Subproject commit 1940f8bd8b7c3c7c855d4fc7e1e86ea3f148c015 +Subproject commit 88c26d984c3232cdd6d03b19a0da5f6c49351810 From f207c285ff3f1b823ed7494f3de932efc8dee5a3 Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 14 Sep 2013 15:38:40 +0800 Subject: [PATCH 4/7] set default render quality in reflowing to 1.0 which should be a good tradeoff between speed and quality. --- defaults.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults.lua b/defaults.lua index c78a6492b..f49ada314 100644 --- a/defaults.lua +++ b/defaults.lua @@ -38,7 +38,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 From f12869d5874685bfd89fd45763aa0f7af25284d1 Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 14 Sep 2013 18:40:00 +0800 Subject: [PATCH 5/7] split text string with even finer granularity --- frontend/ui/widget/text.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/ui/widget/text.lua b/frontend/ui/widget/text.lua index c063cc1ac..fe6f50adb 100644 --- a/frontend/ui/widget/text.lua +++ b/frontend/ui/widget/text.lua @@ -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 From 0b7554b1d8d40f581602500da9f85908cbc5e681 Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 14 Sep 2013 19:35:32 +0800 Subject: [PATCH 6/7] add DSHOWOVERLAP in defaults.lua Turn off "show overlap" by default since scroll mode can replace it in most cases where "show overlap" is used. And the dimmed area often make new users confused. It's better to leave this feature to more advanced users. --- defaults.lua | 4 ++++ frontend/ui/reader/readerpaging.lua | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/defaults.lua b/defaults.lua index f49ada314..396bf842e 100644 --- a/defaults.lua +++ b/defaults.lua @@ -30,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 diff --git a/frontend/ui/reader/readerpaging.lua b/frontend/ui/reader/readerpaging.lua index 0ce9c14ee..0df23431c 100644 --- a/frontend/ui/reader/readerpaging.lua +++ b/frontend/ui/reader/readerpaging.lua @@ -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} } From 9f0154f7bf64a2f0698d8a8fb885cdebeddb2a41 Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 14 Sep 2013 19:46:45 +0800 Subject: [PATCH 7/7] fix wrong indentation --- frontend/ui/widget/text.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/ui/widget/text.lua b/frontend/ui/widget/text.lua index fe6f50adb..f29a6273b 100644 --- a/frontend/ui/widget/text.lua +++ b/frontend/ui/widget/text.lua @@ -154,12 +154,12 @@ function TextBoxWidget:_getVerticalList(alg) local h_list = {} for words in self.text:gmatch("[\32-\127\192-\255]+[\128-\191]*") do 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 + 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