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.
This commit is contained in:
Julian Offenhäuser 2023-01-09 17:56:52 +01:00 committed by Linus Groh
parent a37f3390dc
commit ac31b1bda3
Notes: sideshowbarker 2024-07-17 17:40:13 +09:00

View file

@ -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);