From 406f3d72da44f355d08a7cf6cbe831299f70da8e Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Fri, 7 Sep 2012 16:26:05 +0200 Subject: [PATCH] fallback to default fonts when loading reader configuration Since we are adding and renaming fonts, we need to make sure that all fonts which reader uses are defined. This allows us to add fonts and not break when users load old configuration files close #252 --- reader.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/reader.lua b/reader.lua index ccd057661..ecfc315a0 100755 --- a/reader.lua +++ b/reader.lua @@ -124,7 +124,14 @@ Screen.native_rotation_mode = Screen.cur_rotation_mode G_reader_settings = DocSettings:open(".reader") fontmap = G_reader_settings:readSetting("fontmap") if fontmap ~= nil then - Font.fontmap = fontmap + -- we need to iterate over all fonts used in reader to support upgrade from older configuration + for name,path in pairs(fontmap) do + if Font.fontmap[name] then + Font.fontmap[name] = path + else + Debug("missing "..name.." in user configuration, using default font "..path) + end + end end -- set up the mode to manage files