From cdc0cc58e755d880b6a37452f3ef812b297132bd Mon Sep 17 00:00:00 2001 From: poire-z Date: Thu, 5 Dec 2024 01:34:09 +0100 Subject: [PATCH] CreDocument: tweak when the default font is set (#12846) Reseting the default font each time we refresh metadata (ie. when refreshing a cover in History) could cause the rendering hash of the currently opened document to be messed up, with strange effects. Hoping setting one in engineInit() is enough to avoid the crashes the removed comment talks about. --- frontend/document/credocument.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/frontend/document/credocument.lua b/frontend/document/credocument.lua index d15a3c6c8..e490e5c72 100644 --- a/frontend/document/credocument.lua +++ b/frontend/document/credocument.lua @@ -150,6 +150,10 @@ function CreDocument:engineInit() -- and bold text with the font_base_weight setting set to its default value of 0 (=400). cre.regularizeRegisteredFontsWeights(true) -- true to print what modifications were made + -- Let our default font (even if we don't have a document) be known to crengine's FontManager + -- (self:setFontFace(self.default_font) would need a credocument to be loaded) + cre.setAsPreferredFontWithBias(self.default_font, 1 + 128*5 + 256*5) + -- Set up bias for some specific fonts self:setOtherFontBiases() @@ -320,11 +324,6 @@ function CreDocument:loadDocument(full_document) if not self._loaded then local only_metadata = full_document == false logger.dbg("CreDocument: loading document...") - if only_metadata then - -- Setting a default font before loading document - -- actually do prevent some crashes - self:setFontFace(self.default_font) - end if self._document:loadDocument(self.file, only_metadata) then self._loaded = true logger.dbg("CreDocument: loading done.")