[Interest] Bug#1070406: Qt5: badly clips some fonts when rendering to PDFs

Thorsten Glaser tg at mirbsd.de
Sun May 5 23:16:55 CEST 2024


Hi,

I don’t have the means to open a formal bug report (I hope my
packagers do that and will backport an eventual fix) but the
PDF font embedding is all wrong (besides quite a number of
other WTFs like hardcoding /Flags 4) as it just copies the
whole OS/2 table and the metrics from the hhea table but
scales the rest to 2048 ppem.

>This is used in things like…
>
>    font.hhea.maxAdvanceWidth = TO_TTF(fontEngine->maxCharWidth());
>
>… but not in…
>
>    font.hhea.ascender = qRound(properties.ascent);
>    font.hhea.descender = -qRound(properties.descent);
>    font.hhea.lineGap = qRound(properties.leading);
>
>… and of course not when the OS/2 table is copied:
>
>    if (!noEmbed) {
>        QTtfTable os2;
>        os2.tag = MAKE_TAG('O', 'S', '/', '2');
>        os2.data = fontEngine->getSfntTable(os2.tag);
>        if (!os2.data.isEmpty())
>            tables.append(os2);
>    }
>
>(all examples from stretch’s Qt, as the oldest I had at hand)

See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1070406
(report against Qt with my packagers) for more of the story,
https://github.com/mate-desktop/atril/issues/610 for preceding
debugging and https://musescore.org/en/node/300603 for the
bugreport I (as the last person to care about the MScore font)
received initially.

Ideally don’t scale, but if you have to, fixup all the tables
*and* the /FontBBox please ☺ (The OS/2 table notably has more
than one version and 17 (or so) values that need to be scaled…)

Looking at the font/PDF/embed bugs reported so far in Jira, it
seems previously developers and users only cared about horizontal
metrics. Some PDF viewers and even printers(!) cut off, though,
if the vertical metrics are wrong.

Thanks,
//mirabilos
-- 
22:20⎜<asarch> The crazy that persists in his craziness becomes a master
22:21⎜<asarch> And the distance between the craziness and geniality is
only measured by the success 18:35⎜<asarch> "Psychotics are consistently
inconsistent. The essence of sanity is to be inconsistently inconsistent


More information about the Interest mailing list