Dispatcher: Set font

Closes: #8531
reviewable/pr8559/r1
yparitcher 2 years ago
parent 46f1f3eb5e
commit 035be38430

@ -82,7 +82,7 @@ function ReaderFont:init()
end end
end, end,
callback = function() callback = function()
self:setFont(v) self:onSetFont(v)
end, end,
hold_callback = function(touchmenu_instance) hold_callback = function(touchmenu_instance)
self:makeDefault(v, touchmenu_instance) self:makeDefault(v, touchmenu_instance)
@ -283,7 +283,7 @@ function ReaderFont:onSaveSettings()
self.ui.doc_settings:saveSetting("gamma_index", self.gamma_index) self.ui.doc_settings:saveSetting("gamma_index", self.gamma_index)
end end
function ReaderFont:setFont(face) function ReaderFont:onSetFont(face)
if face and self.font_face ~= face then if face and self.font_face ~= face then
self.font_face = face self.font_face = face
self.ui.document:setFontFace(face) self.ui.document:setFontFace(face)

@ -133,6 +133,7 @@ local settingsList = {
panel_zoom_toggle = {category="none", event="TogglePanelZoomSetting", title=_("Toggle panel zoom"), paging=true, separator=true}, panel_zoom_toggle = {category="none", event="TogglePanelZoomSetting", title=_("Toggle panel zoom"), paging=true, separator=true},
-- rolling reader settings -- rolling reader settings
set_font = {category="string", event="SetFont", title=_("Set font"), rolling=true, args_func=require("fontlist").getFontArgFunc,},
increase_font = {category="incrementalnumber", event="IncreaseFontSize", min=0.5, max=255, step=0.5, title=_("Increase font size by %1"), rolling=true}, increase_font = {category="incrementalnumber", event="IncreaseFontSize", min=0.5, max=255, step=0.5, title=_("Increase font size by %1"), rolling=true},
decrease_font = {category="incrementalnumber", event="DecreaseFontSize", min=0.5, max=255, step=0.5, title=_("Decrease font size by %1"), rolling=true}, decrease_font = {category="incrementalnumber", event="DecreaseFontSize", min=0.5, max=255, step=0.5, title=_("Decrease font size by %1"), rolling=true},
@ -288,6 +289,7 @@ local dispatcher_menu_order = {
"book_description", "book_description",
"book_cover", "book_cover",
"set_font",
"increase_font", "increase_font",
"decrease_font", "decrease_font",
"font_size", "font_size",

@ -233,4 +233,14 @@ function FontList:getLocalizedFontName(file, index)
return altname return altname
end end
function FontList:getFontArgFunc()
require("document/credocument"):engineInit()
local toggle = {}
local face_list = cre.getFontFaces()
for k,v in ipairs(face_list) do
table.insert(toggle, FontList:getLocalizedFontName(cre.getFontFaceFilenameAndFaceIndex(v)) or v)
end
return face_list, toggle
end
return FontList return FontList

Loading…
Cancel
Save