From a4dcfd2d529acf008b825f64a059b82cf28b0b2c Mon Sep 17 00:00:00 2001
From: jonnyl2 <95502269+jonnyl2@users.noreply.github.com>
Date: Fri, 18 Oct 2024 16:46:57 +0200
Subject: [PATCH] ReaderFont: fix "new" fonts in generated font test document
(#12646)
New fonts were not rendering in their own font because
the font names were modified directly in the face_list table.
---
frontend/apps/reader/modules/readerfont.lua | 23 ++++++++++++++-------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/frontend/apps/reader/modules/readerfont.lua b/frontend/apps/reader/modules/readerfont.lua
index cc421c62a..c2524537d 100644
--- a/frontend/apps/reader/modules/readerfont.lua
+++ b/frontend/apps/reader/modules/readerfont.lua
@@ -903,26 +903,33 @@ a { color: black; }
%s
]], _("Available fonts test document"), _("AVAILABLE FONTS")))
local face_list = cre.getFontFaces()
+ local new_font_idx = 1
if next(newly_added_fonts) then
-- Sort alphabetically, with new fonts first (as done in sortFaceList())
- local move_idx = 1
for i=1, #face_list do
if newly_added_fonts[face_list[i]] then
- face_list[i] = face_list[i] .. " [NEW]"
- table.insert(face_list, move_idx, table.remove(face_list, i))
- move_idx = move_idx + 1
+ table.insert(face_list, new_font_idx, table.remove(face_list, i))
+ new_font_idx = new_font_idx + 1
end
end
end
f:write("\n")
- for _, font_name in ipairs(face_list) do
+ for i, font_name in ipairs(face_list) do
local font_id = font_name:gsub(" ", "_"):gsub("'", "_")
- f:write(string.format("
\n", font_id, font_name))
+ if i < new_font_idx then -- New fonts prepended with NEW on summary page
+ f:write(string.format("
\n", font_id, font_name))
+ else
+ f:write(string.format("
\n", font_id, font_name))
+ end
end
f:write("
\n\n")
- for _, font_name in ipairs(face_list) do
+ for i, font_name in ipairs(face_list) do
local font_id = font_name:gsub(" ", "_"):gsub("'", "_")
- f:write(string.format("%s
\n", font_id, font_name))
+ if i < new_font_idx then -- New fonts prepended with NEW in titles and TOC
+ f:write(string.format("NEW: %s
\n", font_id, font_name))
+ else
+ f:write(string.format("%s
\n", font_id, font_name))
+ end
f:write(string.format("\n", font_name))
f:write(html_sample)
f:write("\n
\n\n")