From b4e7dc947c94e9d2d5803482f88b6863e51d747c Mon Sep 17 00:00:00 2001 From: poire-z Date: Fri, 18 Aug 2017 16:40:48 +0200 Subject: [PATCH] Added TextBoxWidget.has_split_inside_word flag Used by coverbrowser's Text covers to choose the best font size. --- frontend/ui/widget/textboxwidget.lua | 3 +++ plugins/coverbrowser.koplugin/mosaicmenu.lua | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/frontend/ui/widget/textboxwidget.lua b/frontend/ui/widget/textboxwidget.lua index 9ad9f16f1..2cec3cff3 100644 --- a/frontend/ui/widget/textboxwidget.lua +++ b/frontend/ui/widget/textboxwidget.lua @@ -138,6 +138,9 @@ function TextBoxWidget:_splitCharWidthList() -- either a very long english word ocuppying more than one line, -- or the excessive char is itself splittable: -- we let that excessive char for next line + if adjusted_idx == offset then -- let the fact a long word was splitted be known + self.has_split_inside_word = true + end cur_line_text = table.concat(self.charlist, "", offset, idx - 1) cur_line_width = cur_line_width - self.char_width_list[idx].width elseif c == " " then diff --git a/plugins/coverbrowser.koplugin/mosaicmenu.lua b/plugins/coverbrowser.koplugin/mosaicmenu.lua index ae953ec09..602a25e20 100644 --- a/plugins/coverbrowser.koplugin/mosaicmenu.lua +++ b/plugins/coverbrowser.koplugin/mosaicmenu.lua @@ -194,10 +194,6 @@ function FakeCover:init() end inter_pad = math.floor(free_height / 2) - -- XXX We can benefit from adding to ui/widget/textboxwidget.lua at line 141 - -- ("either a very long english word"): - -- if adjusted_idx == offset then self.has_split_inside_word = true end - -- The following as no effect till then local textboxes_ok = true if (authors_wg and authors_wg.has_split_inside_word) or (title_wg and title_wg.has_split_inside_word) then -- We may get a nicer cover at next lower font size