From f9e06c8d8b54b7d97dd65a1fb5fac4b0795f8139 Mon Sep 17 00:00:00 2001 From: poire-z Date: Sat, 3 Oct 2020 10:41:56 +0200 Subject: [PATCH] Font: fix possible messy font sizes when geometry/dpi change --- frontend/ui/font.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/ui/font.lua b/frontend/ui/font.lua index 79d66a005..5c3bbf26a 100644 --- a/frontend/ui/font.lua +++ b/frontend/ui/font.lua @@ -237,8 +237,18 @@ function Font:getFace(font, size) local hash = realname..size local face_obj = self.faces[hash] - -- build face if not found - if not face_obj then + if face_obj then + -- Font found + if face_obj.orig_size ~= orig_size then + -- orig_size has changed (which may happen on small orig_size variations + -- mapping to a same final size, but more importantly when geometry + -- or dpi has changed): keep it updated, so code that would re-use + -- it to fetch another font get the current original font size and + -- not one from the past + face_obj.orig_size = orig_size + end + else + -- Build face if not found local builtin_font_location = FontList.fontdir.."/"..realname local ok, face = pcall(Freetype.newFace, builtin_font_location, size)