Inconsistencies in exported mark glyph advances

With Glyphs 3.0.5 (3130) I’m seeing an odd issue: glyphs with Mark, Nonspacing and no outlines have their advance width set to zero in CFF table but not hmtx, while glyphs with outlines have the advance width set to zero in both tables as expected.

(if you are wondering how I found about this, this was causing wired glyph displacement issues when exporting PDF from LibreOffice, after lots of debugging, turns out parts of the code read the advances from hmtx table while others read it from the the CFF table, resulting in pad advance adjustments in the PDF).

I used this script to correct the hmtx advances and I confirm it fixes the LibreOffice issue:

import sys
from fontTools.ttLib import TTFont
from fontTools.pens.recordingPen import RecordingPen

font = TTFont(sys.argv[1])
metrics = font["hmtx"].metrics
charStrings = font["CFF "].cff[0].CharStrings

for g in metrics:
    m = metrics[g]
    w = m[0]
    c = charStrings[g]
    p = RecordingPen()
    c.draw(p)
    if w != c.width:
        print(g, m, c.width)
        metrics[g] = (c.width, m[1])

font.save("a.otf")

Thanks for reporting. :+1:

1 Like

Thanks. Fixed it.

2 Likes