Footnote popups: allow setting an absolute font size

In the "Set footnote popup font size", allow toggling
between setting a relative (to the document) font size
and setting an absolute font size (that won't change
with the document font size).
reviewable/pr6682/r1
poire-z 4 years ago
parent fca426c17c
commit b4214d3f16

@ -271,8 +271,35 @@ From the footnote popup, you can jump to the footnote location in the book by sw
end,
keep_menu_open = true,
callback = function()
local spin_widget
local get_font_size_widget
get_font_size_widget = function(show_absolute_font_size_widget)
local SpinWidget = require("ui/widget/spinwidget")
UIManager:show(SpinWidget:new{
if show_absolute_font_size_widget then
spin_widget = SpinWidget:new{
width = math.floor(Screen:getWidth() * 0.75),
value = G_reader_settings:readSetting("footnote_popup_absolute_font_size")
or Screen:scaleBySize(self.ui.font.font_size),
value_min = 12,
value_max = 255,
precision = "%d",
ok_text = _("Set font size"),
title_text = _("Set footnote popup font size"),
info_text = _([[
The footnote popup font can adjust to the font size you've set for the document, but you can specify here a fixed absolute font size to be used instead.]]),
callback = function(spin)
G_reader_settings:delSetting("footnote_popup_relative_font_size")
G_reader_settings:saveSetting("footnote_popup_absolute_font_size", spin.value)
end,
extra_text = _("Set a relative font size instead"),
extra_callback = function()
UIManager:close(spin_widget)
spin_widget = get_font_size_widget(false)
UIManager:show(spin_widget)
end,
}
else
spin_widget = SpinWidget:new{
width = math.floor(Screen:getWidth() * 0.75),
value = G_reader_settings:readSetting("footnote_popup_relative_font_size") or -2,
value_min = -10,
@ -286,9 +313,22 @@ You can specify here how much smaller or larger it should be relative to the doc
A negative value will make it smaller, while a positive one will make it larger.
The recommended value is -2.]]),
callback = function(spin)
G_reader_settings:delSetting("footnote_popup_absolute_font_size")
G_reader_settings:saveSetting("footnote_popup_relative_font_size", spin.value)
end,
})
extra_text = _("Set an absolute font size instead"),
extra_callback = function()
UIManager:close(spin_widget)
spin_widget = get_font_size_widget(true)
UIManager:show(spin_widget)
end,
}
end
return spin_widget
end
local show_absolute_font_size_widget = G_reader_settings:readSetting("footnote_popup_absolute_font_size") ~= nil
spin_widget = get_font_size_widget(show_absolute_font_size_widget)
UIManager:show(spin_widget)
end,
help_text = _([[
The footnote popup font adjusts to the font size you've set for the document.

@ -225,7 +225,12 @@ function FootnoteWidget:init()
-- We may use a font size a bit smaller than the document one (because
-- footnotes are usually smaller, and because NotoSans is a bit on the
-- larger size when compared to other fonts at the same size)
local font_size = self.doc_font_size + (G_reader_settings:readSetting("footnote_popup_relative_font_size") or -2)
local font_size = G_reader_settings:readSetting("footnote_popup_absolute_font_size")
if font_size then
font_size = Screen:scaleBySize(font_size)
else
font_size = self.doc_font_size + (G_reader_settings:readSetting("footnote_popup_relative_font_size") or -2)
end
-- We want to display the footnote text with the same margins as
-- the document, but keep the scrollbar in the right margin, so

Loading…
Cancel
Save