davelab6/Vollkorn-Typeface

Outlines: overlap of some bars

pichotta opened this issue · 10 comments

djrrb commented

@pichotta Would appreciate more context about these sorts of errors (such as the exact glyph or character, as well as browser/OS in which you are previewing).

I dragged the font onto the Gauntlet, hit Glyph Sets, entire font, and scrolled to what I thought you were looking at, and don’t see any overlapping issues for Đ or Smallcap ϴ in Safari or Chrome.

Is this just one of those unavoidable OS rendering issues that has been fixed in later versions of MacOS?

Screen Shot 2020-07-06 at 1 23 53 PM

Screen Shot 2020-07-06 at 1 23 49 PM

I will be mindful to give more context. The overlap issue is happening in 4-6 glyphs across styles in the static TTFs. The overlap issue can be visualized in Gauntlet in Chrome, or by converting the TTFs.

@djrrb @pichotta After a quick test, it looks like enabling the OVERLAP_COMPOUND bit on the flag of the first component fixes this.

See the glyf table:

Mask Name Description
0x0400 OVERLAP_COMPOUND Bit 10: If set, the components of the compound glyph overlap. Use of this flag is not required in OpenType — that is, it is valid to have components overlap without having this flag set. It may affect behaviors in some platforms, however. (See Apple’s specification for details regarding behavior in Apple platforms.) When used, it must be set on the flag word for the first component. See additional remarks, above, for the similar OVERLAP_SIMPLE flag used in simple-glyph descriptions.

I tested this by dumping the glyf table:

ttx -t glyf -o fonts/ttf/Vollkorn-Black.overlap_compound.ttx fonts/ttf/Vollkorn-Black.ttf

modifying the "o" component in "oslash":

     <TTGlyph name="oslash" xMin="21" yMin="-31" xMax="581" yMax="490">
-      <component glyphName="o" x="0" y="0" flags="0x204"/>
+      <component glyphName="o" x="0" y="0" flags="0x604"/>
       <component glyphName="_part.oslash" x="16" y="3" flags="0x4"/>
     </TTGlyph>

then merging the modified glyf table with the TTF:

ttx -m fonts/ttf/Vollkorn-Black.ttf fonts/ttf/Vollkorn-Black.overlap_compound.ttx

This before:
image

This is after the change on oslash:
Screenshot 2020-07-08 at 19 13 24

Running the following command to instantiate from the variable font fixes the issue:

python3 -m fontTools varLib.mutator -o fonts/ttf/Vollkorn-Black.mutator.ttf fonts/variable/Vollkorn\[wght\].ttf wght=900

fontTools.varLib.mutator sets “OVERLAP_SIMPLE and OVERLAP_COMPOUND glyf flags by default in instantiateVariableFont” since version 3.39.0.

The OVERLAP_SIMPLE is the equivalent of OVERLAP_COMPOUND for simple (outline) glyphs.

Oslash oslash oslash.sc (Oslashacute oslashacute oslashacute.sc)
Theta ThetaSymbol theta
Eth eth.sc

zero.lf.zero zero.tf.zero zero.tosf.zero zero.zero
zeroinferior.zero zero.dnom.zero zero.numr.zero
zerosuperior.zero zero.sc.zero

This is approximately what we added to the fontTools instantiator:

import sys

from fontTools.ttLib import TTFont

def main(argv):
    for fontpath in argv:
        tt = TTFont(fontpath)
        glyf = tt["glyf"]
        
        for glyph_name in glyf.keys():
	    glyph = glyf[glyph_name]
	    # Set OVERLAP_COMPOUND bit for compound glyphs
	    if glyph.isComposite():
	        glyph.components[0].flags |= 0x400
	    # Set OVERLAP_SIMPLE bit for simple glyphs
	    elif glyph.numberOfContours > 0:
	        glyph.flags[0] |= 0x40
        tt.save(fontpath)
        

if __name__ == "__main__":
    main(sys.argv[1:])

@djrrb I pushed the overlap-compound branch where the build scripts enables the OVERLAP_COMPOUND bit, similar to what @chrissimpkins is suggesting. Let me know if that works for you.

madig commented

@chrissimpkins FYI, OVERLAP_SIMPLE is 0x40, not 0x400.

Fixed, thanks Niko

We should revisit this as WOFF2 compression will not preserve the OVERLAP_SIMPLE and OVERLAP_COMPOUND flags, making the issue reappear in WOFF2s only.