diff --git a/Userland/Libraries/LibPDF/Fonts/SimpleFont.cpp b/Userland/Libraries/LibPDF/Fonts/SimpleFont.cpp index 060e334922..dcc546882c 100644 --- a/Userland/Libraries/LibPDF/Fonts/SimpleFont.cpp +++ b/Userland/Libraries/LibPDF/Fonts/SimpleFont.cpp @@ -48,13 +48,14 @@ PDFErrorOr SimpleFont::initialize(Document* document, NonnullRefPtr SimpleFont::draw_string(Gfx::Painter& painter, Gfx::FloatPoint glyph_position, ByteString const& string, Renderer const& renderer) { - auto const& text_rendering_matrix = renderer.calculate_text_rendering_matrix(); - auto font_size = text_rendering_matrix.x_scale() * renderer.text_state().font_size; - - auto character_spacing = text_rendering_matrix.x_scale() * renderer.text_state().character_spacing; - auto word_spacing = text_rendering_matrix.x_scale() * renderer.text_state().word_spacing; auto horizontal_scaling = renderer.text_state().horizontal_scaling; + auto const& text_rendering_matrix = renderer.calculate_text_rendering_matrix(); + auto font_size = text_rendering_matrix.x_scale() * renderer.text_state().font_size / horizontal_scaling; + + auto character_spacing = text_rendering_matrix.x_scale() * renderer.text_state().character_spacing / horizontal_scaling; + auto word_spacing = text_rendering_matrix.x_scale() * renderer.text_state().word_spacing / horizontal_scaling; + for (auto char_code : string.bytes()) { // Use the width specified in the font's dictionary if available, // and use the default width for the given font otherwise. diff --git a/Userland/Libraries/LibPDF/Renderer.cpp b/Userland/Libraries/LibPDF/Renderer.cpp index 955b8cc7ac..4fe98cea55 100644 --- a/Userland/Libraries/LibPDF/Renderer.cpp +++ b/Userland/Libraries/LibPDF/Renderer.cpp @@ -487,7 +487,7 @@ RENDERER_HANDLER(text_set_font) text_state().font_size = args[1].to_float(); auto& text_rendering_matrix = calculate_text_rendering_matrix(); - auto font_size = text_rendering_matrix.x_scale() * text_state().font_size; + auto font_size = text_rendering_matrix.x_scale() * text_state().font_size / text_state().horizontal_scaling; auto resources = extra_resources.value_or(m_page.resources); auto fonts_dictionary = MUST(resources->get_dict(m_document, CommonNames::Font)); @@ -545,7 +545,7 @@ RENDERER_HANDLER(text_set_matrix_and_line_matrix) // Settings the text/line matrix retroactively affects fonts if (text_state().font) { auto new_text_rendering_matrix = calculate_text_rendering_matrix(); - text_state().font->set_font_size(text_state().font_size * new_text_rendering_matrix.x_scale()); + text_state().font->set_font_size(text_state().font_size * new_text_rendering_matrix.x_scale() / text_state().horizontal_scaling); } return {};