diff --git a/base b/base
index a5ee5e14e..f4a56a7a3 160000
--- a/base
+++ b/base
@@ -1 +1 @@
-Subproject commit a5ee5e14ed077a9d76700929b10f40d35a508982
+Subproject commit f4a56a7a319496f207f9bd93d5f21bdf07aa3508
diff --git a/frontend/apps/reader/modules/readerfont.lua b/frontend/apps/reader/modules/readerfont.lua
index bd01359b8..12ae63f60 100644
--- a/frontend/apps/reader/modules/readerfont.lua
+++ b/frontend/apps/reader/modules/readerfont.lua
@@ -1,4 +1,5 @@
local CenterContainer = require("ui/widget/container/centercontainer")
+local ConfirmBox = require("ui/widget/confirmbox")
local Device = require("device")
local Event = require("ui/event")
local Input = Device.input
@@ -51,12 +52,25 @@ function ReaderFont:init()
local face_list = cre.getFontFaces()
for k,v in ipairs(face_list) do
table.insert(self.face_table, {
- text = v,
+ text_func = function()
+ -- defaults are hardcoded in credocument.lua
+ local default_font = G_reader_settings:readSetting("cre_font") or self.ui.document.default_font
+ local fallback_font = G_reader_settings:readSetting("fallback_font") or self.ui.document.fallback_font
+ local text = v
+ if v == default_font then
+ text = text .. " ★"
+ end
+ if v == fallback_font then
+ text = text .. " �"
+ end
+ return text
+ end,
callback = function()
self:setFont(v)
end,
- hold_callback = function()
- self:makeDefault(v)
+ hold_may_update_menu = true,
+ hold_callback = function(refresh_menu_func)
+ self:makeDefault(v, refresh_menu_func)
end,
checked_func = function()
return v == self.font_face
@@ -64,6 +78,20 @@ function ReaderFont:init()
})
face_list[k] = {text = v}
end
+ if self:hasFontsTestSample() then
+ self.face_table[#self.face_table].separator = true
+ table.insert(self.face_table, {
+ text = _("Generate fonts test HTML document"),
+ callback = function()
+ UIManager:show(ConfirmBox:new{
+ text = _("Would you like to generate an HTML document showing some sample text rendered with each available font?");
+ ok_callback = function()
+ self:buildFontsTestDocument()
+ end
+ })
+ end
+ })
+ end
self.ui.menu:registerToMainMenu(self)
end
@@ -100,10 +128,12 @@ end
function ReaderFont:onReadSettings(config)
self.font_face = config:readSetting("font_face")
+ or G_reader_settings:readSetting("cre_font")
or self.ui.document.default_font
self.ui.document:setFontFace(self.font_face)
self.header_font_face = config:readSetting("header_font_face")
+ or G_reader_settings:readSetting("header_font")
or self.ui.document.header_font
self.ui.document:setHeaderFont(self.header_font_face)
@@ -256,17 +286,22 @@ function ReaderFont:setFont(face)
end
end
-function ReaderFont:makeDefault(face)
+function ReaderFont:makeDefault(face, refresh_menu_func)
if face then
UIManager:show(MultiConfirmBox:new{
- text = T( _("Set %1 as fallback font? Characters not found in the active font are shown in the fallback font instead."), face),
+ text = T( _("Would you like %1 to be used as the default font (★), or the fallback font (�)?\n\nCharacters not found in the active font are shown in the fallback font instead."), face),
choice1_text = _("Default"),
choice1_callback = function()
G_reader_settings:saveSetting("cre_font", face)
+ if refresh_menu_func then refresh_menu_func() end
end,
choice2_text = _("Fallback"),
choice2_callback = function()
- G_reader_settings:saveSetting("fallback_font", face)
+ if self.ui.document:setFallbackFontFace(face) then
+ G_reader_settings:saveSetting("fallback_font", face)
+ self.ui:handleEvent(Event:new("UpdatePos"))
+ end
+ if refresh_menu_func then refresh_menu_func() end
end,
})
end
@@ -302,4 +337,63 @@ function ReaderFont:onAdjustPinch(ges)
return true
end
+function ReaderFont:hasFontsTestSample()
+ local font_test_sample = require("datastorage"):getSettingsDir() .. "/fonts-test-sample.html"
+ local lfs = require("libs/libkoreader-lfs")
+ return lfs.attributes(font_test_sample, "mode") == "file"
+end
+
+function ReaderFont:buildFontsTestDocument()
+ local font_test_sample = require("datastorage"):getSettingsDir() .. "/fonts-test-sample.html"
+ local f = io.open(font_test_sample, "r")
+ if not f then return nil end
+ local html_sample = f:read("*all")
+ f:close()
+ local dir = G_reader_settings:readSetting("home_dir")
+ if not dir then dir = require("apps/filemanager/filemanagerutil").getDefaultDir() end
+ if not dir then dir = "." end
+ local fonts_test_path = dir .. "/fonts-test-all.html"
+ f = io.open(fonts_test_path, "w")
+ -- Using