mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Font menu: add symbols for default and fallback fonts (#3941)
Also allows for updating the fallback font and see results in real-time on the underlying document. Bump crengine for: fix updating fallback font Also adds a menu item to generate a html document showing some sample text rendered with each available font (only if the user has a file koreader/settings/fonts-test-sample.html with some HTML snippet of his choice).
This commit is contained in:
@@ -23,9 +23,9 @@ local CreDocument = Document:new{
|
||||
_cre_dom_version = nil,
|
||||
|
||||
line_space_percent = 100,
|
||||
default_font = G_reader_settings:readSetting("cre_font") or "Noto Serif",
|
||||
header_font = G_reader_settings:readSetting("header_font") or "Noto Sans",
|
||||
fallback_font = G_reader_settings:readSetting("fallback_font") or "Noto Sans CJK SC",
|
||||
default_font = "Noto Serif",
|
||||
header_font = "Noto Sans",
|
||||
fallback_font = "Noto Sans CJK SC",
|
||||
default_css = "./data/cr3.css",
|
||||
options = CreOptions,
|
||||
provider = "crengine",
|
||||
@@ -128,7 +128,8 @@ function CreDocument:init()
|
||||
self._document:adjustFontSizes(Screen:getDPI())
|
||||
|
||||
-- set fallback font face
|
||||
self._document:setStringProperty("crengine.font.fallback.face", self.fallback_font)
|
||||
self._document:setStringProperty("crengine.font.fallback.face",
|
||||
G_reader_settings:readSetting("fallback_font") or self.fallback_font)
|
||||
|
||||
-- We would have liked to call self._document:loadDocument(self.file)
|
||||
-- here, to detect early if file is a supported document, but we
|
||||
@@ -406,6 +407,22 @@ function CreDocument:setFontFace(new_font_face)
|
||||
end
|
||||
end
|
||||
|
||||
function CreDocument:setFallbackFontFace(new_fallback_font_face)
|
||||
if new_fallback_font_face then
|
||||
logger.dbg("CreDocument: set fallback font face", new_fallback_font_face)
|
||||
self._document:setStringProperty("crengine.font.fallback.face", new_fallback_font_face)
|
||||
-- crengine may not accept our fallback font, we need to check
|
||||
local set_fallback_font_face = self._document:getStringProperty("crengine.font.fallback.face")
|
||||
logger.dbg("CreDocument: crengine fallback font face", set_fallback_font_face)
|
||||
if set_fallback_font_face ~= new_fallback_font_face then
|
||||
logger.info("CreDocument:", new_fallback_font_face, "is not usable as a fallback font")
|
||||
return false
|
||||
end
|
||||
self.fallback_font = new_fallback_font_face
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function CreDocument:setHyphDictionary(new_hyph_dictionary)
|
||||
if new_hyph_dictionary then
|
||||
logger.dbg("CreDocument: set hyphenation dictionary", new_hyph_dictionary)
|
||||
|
||||
Reference in New Issue
Block a user