From f29ee8475eb4807d3f61026a3954ee0600a92f1a Mon Sep 17 00:00:00 2001 From: poire-z Date: Sun, 5 Jun 2022 12:36:31 +0200 Subject: [PATCH] Style tweaks: add "Tailor widths and text-indent for CJK" Also add a timeout to the "Changed language for typography rules" InfoMessages. --- frontend/apps/reader/modules/readertypography.lua | 4 ++++ frontend/ui/data/css_tweaks.lua | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/frontend/apps/reader/modules/readertypography.lua b/frontend/apps/reader/modules/readertypography.lua index 4c5fbcf26..e102120c5 100644 --- a/frontend/apps/reader/modules/readertypography.lua +++ b/frontend/apps/reader/modules/readertypography.lua @@ -234,8 +234,11 @@ When the book's language tag is not among our presets, no specific features will return text end, callback = function() + -- We use an InfoMessage because the text might be too long for a Notification. + -- Use a small timeout (but long enough to read) as this might be bothering. UIManager:show(InfoMessage:new{ text = T(_("Changed language for typography rules to %1."), BD.wrap(lang_name)), + timeout = 2, }) self.text_lang_tag = lang_tag self.ui.document:setTextMainLang(lang_tag) @@ -783,6 +786,7 @@ function ReaderTypography:onPreRenderDocument(config) callback = function() UIManager:show(InfoMessage:new{ text = T(_("Changed language for typography rules to book language: %1."), BD.wrap(self.book_lang_tag)), + timeout = 2, }) self.text_lang_tag = self.book_lang_tag self.ui.doc_settings:saveSetting("text_lang", self.text_lang_tag) diff --git a/frontend/ui/data/css_tweaks.lua b/frontend/ui/data/css_tweaks.lua index 9c5612b38..19d59a4f9 100644 --- a/frontend/ui/data/css_tweaks.lua +++ b/frontend/ui/data/css_tweaks.lua @@ -430,6 +430,13 @@ p { margin-bottom: 1em; } ]], + }, + { + id = "cjk_tailored"; + title = _("Tailor widths and text-indent for CJK"), + description = _([[ +Adjust paragraph width and text-indent to be an integer multiple of the font size, so that lines of Chinese and Japanese characters don't need space added between glyphs for text justification.]]), + css = [[ body { -cr-hint: cjk-tailored; }]], -- This hint is inherited separator = true, }, {