mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Adds ReaderTypography (replaces ReaderHyphenation) (#6072)
Replace Hyphenation menu with Typography menu. This works mostly like before: - typography/hyphenation is chosen according to the book metadata language, - one can set a default or a fallback language, - hyphenation is now just a subset of typography, and can be disabled while still setting a language and enabling the other features, - the typography language enables newly added features to crengine: per-language line breaking rules and per-language Harfbuzz glyph selection.
This commit is contained in:
@@ -617,6 +617,41 @@ function CreDocument:setFallbackFontFace(new_fallback_font_face)
|
||||
end
|
||||
end
|
||||
|
||||
-- To use the new crengine language typography facilities (hyphenation, line breaking,
|
||||
-- OpenType fonts locl letter forms...)
|
||||
function CreDocument:setTextMainLang(lang)
|
||||
if lang then
|
||||
logger.dbg("CreDocument: set textlang main lang", lang)
|
||||
self._document:setStringProperty("crengine.textlang.main.lang", lang)
|
||||
end
|
||||
end
|
||||
|
||||
function CreDocument:setTextEmbeddedLangs(toggle)
|
||||
logger.dbg("CreDocument: set textlang embedded langs", toggle)
|
||||
self._document:setStringProperty("crengine.textlang.embedded.langs.enabled", toggle and 1 or 0)
|
||||
end
|
||||
|
||||
function CreDocument:setTextHyphenation(toggle)
|
||||
logger.dbg("CreDocument: set textlang hyphenation enabled", toggle)
|
||||
self._document:setStringProperty("crengine.textlang.hyphenation.enabled", toggle and 1 or 0)
|
||||
end
|
||||
|
||||
function CreDocument:setTextHyphenationSoftHyphensOnly(toggle)
|
||||
logger.dbg("CreDocument: set textlang hyphenation soft hyphens only", toggle)
|
||||
self._document:setStringProperty("crengine.textlang.hyphenation.soft.hyphens.only", toggle and 1 or 0)
|
||||
end
|
||||
|
||||
function CreDocument:setTextHyphenationForceAlgorithmic(toggle)
|
||||
logger.dbg("CreDocument: set textlang hyphenation force algorithmic", toggle)
|
||||
self._document:setStringProperty("crengine.textlang.hyphenation.force.algorithmic", toggle and 1 or 0)
|
||||
end
|
||||
|
||||
function CreDocument:getTextMainLangDefaultHyphDictionary()
|
||||
local main_lang_tag, main_lang_active_hyph_dict, loaded_lang_infos = cre.getTextLangStatus() -- luacheck: no unused
|
||||
return loaded_lang_infos[main_lang_tag] and loaded_lang_infos[main_lang_tag].hyph_dict_name
|
||||
end
|
||||
|
||||
-- To use the old crengine hyphenation manager (only one global hyphenation method)
|
||||
function CreDocument:setHyphDictionary(new_hyph_dictionary)
|
||||
if new_hyph_dictionary then
|
||||
logger.dbg("CreDocument: set hyphenation dictionary", new_hyph_dictionary)
|
||||
|
||||
Reference in New Issue
Block a user