From 6dc53df5b5349c7c96bbc20e5d9f749138db21f5 Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 20 Jul 2013 03:33:58 +0800 Subject: [PATCH] word gap is set to smallest when selcting CJK languages --- defaults.lua | 9 ++++++--- frontend/ui/data/koptoptions.lua | 6 ++++-- frontend/ui/reader/readerkopt.lua | 9 +++++++++ frontend/ui/widget/config.lua | 1 + 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/defaults.lua b/defaults.lua index 8a48a175c..4e19dd417 100644 --- a/defaults.lua +++ b/defaults.lua @@ -34,17 +34,20 @@ 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_WORD_SAPCING = 0.15 -- range from 0.05 to 0.5 DKOPTREADER_CONFIG_RENDER_QUALITY = 0.8 -- range from 0.5 to 1.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 DKOPTREADER_CONFIG_CONTRAST = 1.0 -- range from 0.2 to 2.0 +-- word spacing for reflow +DKOPTREADER_CONFIG_WORD_SAPCINGS = {0.05, 0.15, 0.375} -- range from 0.05 to 0.5 +DKOPTREADER_CONFIG_DEFAULT_WORD_SAPCING = 0.15 -- range from 0.05 to 0.5 -- document languages for OCR DKOPTREADER_CONFIG_DOC_LANGS_TEXT = {"English", "Chinese_S", "Chinese_T"} -DKOPTREADER_CONFIG_DOC_LANGS_CODE = {"eng", "chi_sim", "chi_tra"} -DKOPTREADER_CONFIG_DOC_DEFAULT_LANG_CODE = "eng" +DKOPTREADER_CONFIG_DOC_LANGS_CODE = {"eng", "chi_sim", "chi_tra"} -- ISO 639-3 language string, +DKOPTREADER_CONFIG_DOC_DEFAULT_LANG_CODE = "eng" -- and make sure you have corresponding training data + -- #################################################################### -- following features are not supported right now diff --git a/frontend/ui/data/koptoptions.lua b/frontend/ui/data/koptoptions.lua index e30b0a176..db93869ff 100644 --- a/frontend/ui/data/koptoptions.lua +++ b/frontend/ui/data/koptoptions.lua @@ -166,6 +166,8 @@ KoptOptions = { toggle = DKOPTREADER_CONFIG_DOC_LANGS_TEXT, values = DKOPTREADER_CONFIG_DOC_LANGS_CODE, default_value = DKOPTREADER_CONFIG_DOC_DEFAULT_LANG_CODE, + event = "DocLangUpdate", + args = DKOPTREADER_CONFIG_DOC_LANGS_CODE, }, { name="screen_rotation", @@ -178,8 +180,8 @@ KoptOptions = { name = "word_spacing", name_text = WORD_GAP_STR, toggle = {SMALL_STR, MEDIUM_STR, LARGE_STR}, - values = {0.05, 0.15, 0.375}, - default_value = DKOPTREADER_CONFIG_WORD_SAPCING, + values = DKOPTREADER_CONFIG_WORD_SAPCINGS, + default_value = DKOPTREADER_CONFIG_DEFAULT_WORD_SAPCING, }, { name = "defect_size", diff --git a/frontend/ui/reader/readerkopt.lua b/frontend/ui/reader/readerkopt.lua index 479f65fda..f52e92d4f 100644 --- a/frontend/ui/reader/readerkopt.lua +++ b/frontend/ui/reader/readerkopt.lua @@ -49,3 +49,12 @@ function ReaderKoptListener:onZoomUpdate(zoom) end end +-- misc koptoption handler +function ReaderKoptListener:onDocLangUpdate(lang) + if lang == "chi_sim" or lang == "chi_tra" or + lang == "jpn" or lang == "kor" then + self.document.configurable.word_spacing = DKOPTREADER_CONFIG_WORD_SAPCINGS[1] + else + self.document.configurable.word_spacing = DKOPTREADER_CONFIG_WORD_SAPCINGS[3] + end +end diff --git a/frontend/ui/widget/config.lua b/frontend/ui/widget/config.lua index 9de4a23d1..aaa26d2ae 100644 --- a/frontend/ui/widget/config.lua +++ b/frontend/ui/widget/config.lua @@ -502,6 +502,7 @@ end function ConfigDialog:onConfigEvent(option_event, option_arg) --DEBUG("config option event", option_event, option_arg) self.ui:handleEvent(Event:new(option_event, option_arg)) + self:onShowConfigPanel(self.panel_index) end function ConfigDialog:closeDialog()