1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:57:35 +00:00

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.
This commit is contained in:
Nico Weber 2024-02-25 13:28:23 -05:00 committed by Andreas Kling
parent 448eaa2966
commit 83d29b3e45

View file

@ -141,8 +141,10 @@ PDFErrorOr<void> TrueTypePainter::draw_glyph(Gfx::Painter& painter, Gfx::FloatPo
Optional<float> 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)