Skip to content

Commit

Permalink
bump crengine: fix handling of soft-hyphens (koreader#4025)
Browse files Browse the repository at this point in the history
Adds a new Hyphenation method: Soft-hyphens only.
Adds a new toggable option, usable with Algorithm and language
based methods: Trust soft hyphens (if enabled, if soft hyphens
found in word: use them and skip regular method).
  • Loading branch information
poire-z committed Jun 28, 2018
1 parent 6877ade commit d3d30c4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base
27 changes: 26 additions & 1 deletion frontend/apps/reader/modules/readerhyphenation.lua
Expand Up @@ -54,6 +54,29 @@ function ReaderHyphenation:init()
enabled_func = function()
return self.hyph_alg ~= "@none"
end,
})
table.insert(self.hyph_table, {
text = _("Trust soft hyphens"),
callback = function()
G_reader_settings:flipNilOrFalse("hyph_trust_soft_hyphens")
self.ui.document:setTrustSoftHyphens(G_reader_settings:isTrue("hyph_trust_soft_hyphens"))
self.ui.toc:onUpdateToc()
self.ui:handleEvent(Event:new("UpdatePos"))
end,
checked_func = function()
-- for @none and @softhyphens, set the checkbox to reflect how
-- these trust soft hyphens, no matter what our setting is
if self.hyph_alg == "@none" then
return false
elseif self.hyph_alg == "@softhyphens" then
return true
else
return G_reader_settings:isTrue("hyph_trust_soft_hyphens")
end
end,
enabled_func = function()
return self.hyph_alg ~= "@none" and self.hyph_alg ~= "@softhyphens"
end,
separator = true,
})

Expand Down Expand Up @@ -113,7 +136,8 @@ function ReaderHyphenation:init()
end,
checked_func = function()
return v.filename == self.hyph_alg
end
end,
separator = v.separator,
})

self.lang_table[v.language] = v.filename
Expand Down Expand Up @@ -192,6 +216,7 @@ function ReaderHyphenation:onPreRenderDocument(config)
local hyph_settings = self.hyph_algs_settings[self.hyph_alg] or {}
self.ui.document:setHyphLeftHyphenMin(G_reader_settings:readSetting("hyph_left_hyphen_min") or hyph_settings.left_hyphen_min)
self.ui.document:setHyphRightHyphenMin(G_reader_settings:readSetting("hyph_right_hyphen_min") or hyph_settings.right_hyphen_min)
self.ui.document:setTrustSoftHyphens(G_reader_settings:isTrue("hyph_trust_soft_hyphens"))
end

function ReaderHyphenation:addToMainMenu(menu_items)
Expand Down
5 changes: 5 additions & 0 deletions frontend/document/credocument.lua
Expand Up @@ -454,6 +454,11 @@ function CreDocument:setHyphRightHyphenMin(value)
self._document:setIntProperty("crengine.hyphenation.right.hyphen.min", value or 2)
end

function CreDocument:setTrustSoftHyphens(toggle)
logger.dbg("CreDocument: set hyphenation trust soft hyphens", toggle and 1 or 0)
self._document:setIntProperty("crengine.hyphenation.trust.soft.hyphens", toggle and 1 or 0)
end

function CreDocument:clearSelection()
logger.dbg("clear selection")
self._document:clearSelection()
Expand Down

0 comments on commit d3d30c4

Please sign in to comment.