From ac31b1bda349405af74879ea1bee3abc098bb6cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Offenh=C3=A4user?= Date: Mon, 9 Jan 2023 17:56:52 +0100 Subject: [PATCH] LibPDF: Make glyphs from standard 14 fonts show up in Type1Font Previously, we would assume that all standard 14 fonts use a TrueTypeFont dictionary. Now we render them in Type1Font as well, given that it doesn't contain a PostScript font program. --- Userland/Libraries/LibPDF/Fonts/Type1Font.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibPDF/Fonts/Type1Font.cpp b/Userland/Libraries/LibPDF/Fonts/Type1Font.cpp index 4fc4c8889e..67f1b17512 100644 --- a/Userland/Libraries/LibPDF/Fonts/Type1Font.cpp +++ b/Userland/Libraries/LibPDF/Fonts/Type1Font.cpp @@ -78,8 +78,15 @@ float Type1Font::get_char_width(u16 char_code) const void Type1Font::draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint point, float width, u32 char_code, Color color) { - if (!m_data.font_program) + if (!m_data.font_program) { + if (m_data.font) { + // Account for the reversed font baseline + auto position = point.translated(0, -m_data.font->baseline()); + painter.draw_glyph(position, char_code, *m_data.font, color); + } return; + } + auto translation = m_data.font_program->glyph_translation(char_code, width); point = point.translated(translation);