From 9e44aa5cf423bda9a953f7dceac2f2ebaab6da29 Mon Sep 17 00:00:00 2001 From: poire-z Date: Sat, 21 Mar 2026 08:56:54 +0100 Subject: [PATCH] Footnote popup: add option to justify (or not) text (#15129) --- frontend/apps/reader/modules/readerlink.lua | 15 +++++++++++++++ frontend/ui/widget/footnotewidget.lua | 9 +++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/frontend/apps/reader/modules/readerlink.lua b/frontend/apps/reader/modules/readerlink.lua index 053d80e04..58a25c926 100644 --- a/frontend/apps/reader/modules/readerlink.lua +++ b/frontend/apps/reader/modules/readerlink.lua @@ -437,6 +437,21 @@ The recommended value is -2.]]), help_text = _([[ The footnote popup font adjusts to the font size you've set for the document. This allows you to specify how much smaller or larger it should be relative to the document font size.]]), + separator = true, + }, + { + text = _("Justify text in popups"), + enabled_func = function() + return isFootnoteLinkInPopupEnabled() and + (isTapToFollowLinksOn() or isSwipeToFollowNearestLinkEnabled()) + end, + checked_func = function() + return G_reader_settings:nilOrTrue("footnote_popup_justify") + end, + callback = function() + G_reader_settings:flipNilOrTrue("footnote_popup_justify") + end, + help_text = _([[Justify text in footnote popup.]]), }, } return temp_menu_items diff --git a/frontend/ui/widget/footnotewidget.lua b/frontend/ui/widget/footnotewidget.lua index c02712c82..b4c4e4558 100644 --- a/frontend/ui/widget/footnotewidget.lua +++ b/frontend/ui/widget/footnotewidget.lua @@ -34,6 +34,7 @@ local PAGE_CSS = [[ } %6 %7 +%8 ]] -- Make default MuPDF styles (source/html/html-layout.c) a bit @@ -44,7 +45,6 @@ body { margin: 0; /* MuPDF: margin: 1em */ padding: 0; line-height: 1.3; /* MuPDF defaults to 1.2 */ - text-align: justify; } /* We keep left and right margin the same so it also displays as expected in RTL */ h1, h2, h3, h4, h5, h6 { margin: 0; } /* MuPDF: margin: XXem 0 , vary with level */ @@ -264,6 +264,11 @@ function FootnoteWidget:init() end end + local text_align_css = "" + if G_reader_settings:nilOrTrue("footnote_popup_justify") then + text_align_css = "body { text-align: justify; }\n" + end + -- We want to display the footnote text with the same margins as -- the document, but keep the scrollbar in the right margin, so -- both small footnotes (without scrollbar) and longer ones (with @@ -278,7 +283,7 @@ function FootnoteWidget:init() end local css = T(PAGE_CSS, "0", html_right_margin, "0", html_left_margin, -- top right bottom left - self.font_face, font_css, DEFAULT_CSS) + self.font_face, font_css, DEFAULT_CSS, text_align_css) if self.css then -- add any provided css css = css .. "\n" .. self.css end