LibPDF: Tweak vertical position of truetype fonts

The vertical coordinates for truetype fonts are different somehow.
We compensated a bit for that; now we compensate some more.

This is still not 100% perfect, but much better than before.
This commit is contained in:
Nico Weber 2024-01-16 20:25:07 -05:00 committed by Sam Atkins
parent b5aef8e404
commit 13f007aadb
Notes: sideshowbarker 2024-07-17 07:16:27 +09:00
2 changed files with 3 additions and 2 deletions

View File

@ -53,7 +53,8 @@ PDFErrorOr<void> TrueTypeFont::draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint
auto style = renderer.state().paint_style;
// Account for the reversed font baseline
auto position = point.translated(0, -m_font->baseline());
auto position = point.translated(0, -m_font->pixel_metrics().descent - m_font->baseline());
if (style.has<Color>()) {
painter.draw_glyph(position, char_code, *m_font, style.get<Color>());
} else {

View File

@ -71,7 +71,7 @@ PDFErrorOr<void> Type1Font::draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint po
if (!m_font_program) {
// Account for the reversed font baseline
auto position = point.translated(0, -m_font->baseline());
auto position = point.translated(0, -m_font->pixel_metrics().descent - m_font->baseline());
// FIXME: Bounding box and sample point look to be pretty wrong
if (style.has<Color>()) {
painter.draw_glyph(position, char_code, *m_font, style.get<Color>());