diff --git a/Userland/Libraries/LibPDF/Fonts/SimpleFont.cpp b/Userland/Libraries/LibPDF/Fonts/SimpleFont.cpp index 4e05ec78ad..69c94f8c8a 100644 --- a/Userland/Libraries/LibPDF/Fonts/SimpleFont.cpp +++ b/Userland/Libraries/LibPDF/Fonts/SimpleFont.cpp @@ -52,11 +52,11 @@ PDFErrorOr SimpleFont::draw_string(Gfx::Painter& painter, Gfx:: // and use the default width for the given font otherwise. float glyph_width; if (auto width = m_widths.get(char_code); width.has_value()) - glyph_width = font_size * width.value() / 1000.0f; + glyph_width = font_size * width.value() * m_font_matrix.x_scale(); else if (auto width = get_glyph_width(char_code); width.has_value()) glyph_width = width.value(); else - glyph_width = m_missing_width; + glyph_width = m_missing_width; // FIXME: times m_font_matrix.x_scale() probably? TRY(draw_glyph(painter, glyph_position, glyph_width, char_code, paint_color)); diff --git a/Userland/Libraries/LibPDF/Fonts/SimpleFont.h b/Userland/Libraries/LibPDF/Fonts/SimpleFont.h index 783fb1e1a2..47673d7671 100644 --- a/Userland/Libraries/LibPDF/Fonts/SimpleFont.h +++ b/Userland/Libraries/LibPDF/Fonts/SimpleFont.h @@ -22,11 +22,18 @@ protected: RefPtr& encoding() { return m_encoding; } RefPtr const& encoding() const { return m_encoding; } + Gfx::AffineTransform& font_matrix() { return m_font_matrix; } + private: RefPtr m_encoding; RefPtr m_to_unicode; HashMap m_widths; u16 m_missing_width { 0 }; + + // "For all font types except Type 3, the units of glyph space are one-thousandth of a unit of text space; + // for a Type 3 font, the transformation from glyph space to text space is defined by a font matrix specified + // in an explicit FontMatrix entry in the font." + Gfx::AffineTransform m_font_matrix { 1.0f / 1000.0f, 0, 0, 1.0f / 1000.0f, 0, 0 }; }; }