From 83d29b3e454962e36b9dbe35895f2460580652c5 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 25 Feb 2024 13:28:23 -0500 Subject: [PATCH] LibPDF: Hack around a FIXME in TrueTypePainter::get_glyph_width() This will need further thought once we implement support for the truetype 'post' table, but for now it's correct most of the time, and better than not doing it. --- Userland/Libraries/LibPDF/Fonts/TrueTypeFont.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.cpp b/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.cpp index 86792fae0c..fb5c5d0f68 100644 --- a/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.cpp +++ b/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.cpp @@ -141,8 +141,10 @@ PDFErrorOr TrueTypePainter::draw_glyph(Gfx::Painter& painter, Gfx::FloatPo Optional TrueTypePainter::get_glyph_width(u8 char_code) const { - // FIXME: Make this use the char_code lookup method used in draw_glyph(). - return m_font->glyph_width(char_code); + // FIXME: Make this use the full char_code lookup method used in draw_glyph() once that's complete. + auto char_name = m_encoding->get_name(char_code); + u32 unicode = glyph_name_to_unicode(char_name).value_or(char_code); + return m_font->glyph_width(unicode); } void TrueTypePainter::set_font_size(float font_size)