question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose bit 6 of the `glyf` first outline flags byte

See original GitHub issue

My 160413-EvenOddTT issue exposes a problem that the macOS Sierra rasterizer sometimes displays overlapping TT (glyf) contours as “white”. This behavior can be suppressed if one sets “bit 6 of the first Outline Flag byte to 1”. While the official Apple TrueType spec and the OpenType spec treat this bit as “reserved”, Apple’s introductory chapter to AAT explains that this bit is actually used to control the rendering of overlapping contours in the Apple rasterizer. Currently, no easy-to-use tools expose this bit, so setting it requires binary work.

It would be useful if this bit was exposed to fontTools and/or to the .ttx dump.

I’m not sure how to do it elegantly, especially since the contour.pt structure in fontTools is not a straight binary dump but is a bit prettified. Since the official spec treats the flag as reserved, and the AAT chapter only mentions the first flags byte of a glyph, an option in fontTools could trigger .ttx to dump/merge the following syntax, and of course a .flag6 boolean attribute could be added to the pt object:

<TTGlyph name="O" xMin="59" yMin="0" xMax="768" yMax="702">
      <contour>
        <pt x="674" y="440" on="1" flag6="1"/>
        <pt x="674" y="269" on="1"/>
        <pt x="140" y="269" on="1"/>
        <pt x="140" y="440" on="1"/>
      </contour>
      <instructions><assembly>
        </assembly></instructions>
    </TTGlyph>

A prettier implementation would be to introduce a boolean attribute on a fontTools.ttLib.tables._g_l_y_f.Glyph level, akin to isComposite but named hasOvelaps or hasOverlapsAAT, that would conditionally appear in the .ttx dump as an optional attribute of the <TTGlyph> element (if it is set in the font), and would be coordinated with the bit 6 of the first flag byte of the glyf strucutre for the glyph. The name hasOverlapsAAT would hint at its origin.

<TTGlyph name="O" xMin="59" yMin="0" xMax="768" yMax="702" hasOverlapsAAT="1">
      <contour>
        <pt x="674" y="440" on="1"/>
        <pt x="674" y="269" on="1"/>
        <pt x="140" y="269" on="1"/>
        <pt x="140" y="440" on="1"/>
      </contour>
      <instructions><assembly>
        </assembly></instructions>
    </TTGlyph>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

github_iconTop Results From Across the Web

Glyf data table (OpenType 1.8) - Typography - Microsoft Learn
BYTE, flags[n], Array of flags for each coordinate in outline; n is the number of flags. BYTE or SHORT, xCoordinates[ ], First coordinates ......
Read more >
WOFF File Format 2.0 - W3C
The bit 6 flag (OVERLAP_SIMPLE) is different, it can only be set once on the first flag of the glyph. If set, it...
Read more >
The 'glyf' table - TrueType Reference Manual - Apple Developer
The meanings associated with each bit in that byte are given in Table 16 below. Table 16: Outline flags. Flags, Bit (0 is...
Read more >
The X Font Service Protocol - X.Org
Font servers are responsible for providing data in the bit and byte orders requested by the client. The set of requests and events...
Read more >
The TrueType Font File
Consequently, the table begins with an array that maps the first byte to a 4-word ... Glyph bitmap format 6 is the same...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found