Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static fonts from single-master sources have overlaps, skewing glyf ttx diff #975

Open
anthrotype opened this issue Oct 1, 2024 · 4 comments
Milestone

Comments

@anthrotype
Copy link
Member

anthrotype commented Oct 1, 2024

Following #971, ttx_diff.py now invokes fontmake -o ttf instead of -o variable when the input source contains only one master, in order to avoid fontmake adding unnecessary empty/noop variable tables (googlefonts/fontmake#1125).

But fontmake -o ttf also passes the source through the ufo2ft's remove overlaps filter (using booleanOperations by default, or skia-pathops if requested via --overlaps-backend pathops).

fontc being variable-first font compile does not attempt nor support removing the overlaps (as it would destroy master compatibility for a VF target).

Therefore comparing fontc-built single-master sources vs fontmake-built ones will usually produce several glyph diffs in glyph-related tables like glyf, maxp, etc. because the number of outline points when glyphs contain overlapping contours will be different between the two fonts.

For example, take this test font, containing only one glyph "T" with overlapping contours, and compare it with ttx_diff.py:

SingleMaster.glyphs.zip

--- build/default/fontc.ttf
+++ build/default/fontmake.ttf
@@ -12,12 +12,12 @@
     <!-- Most of this table will be recalculated by the compiler -->
     <tableVersion value="1.0"/>
     <fontRevision value="1.0"/>
-    <checkSumAdjustment value="0x0"/>
+    <checkSumAdjustment value="0xd88e9083"/>
     <magicNumber value="0x5f0f3cf5"/>
     <flags value="00000000 00000011"/>
     <unitsPerEm value="1000"/>
     <created value="Mon Sep 30 16:38:24 2024"/>
-    <modified value="Tue Oct  1 10:17:24 2024"/>
+    <modified value="Tue Oct  1 10:17:25 2024"/>
     <xMin value="26"/>
     <yMin value="-200"/>
     <xMax value="574"/>
@@ -53,7 +53,7 @@
     <!-- Most of this table will be recalculated by the compiler -->
     <tableVersion value="0x10000"/>
     <numGlyphs value="3"/>
-    <maxPoints value="10"/>
+    <maxPoints value="8"/>
     <maxContours value="2"/>
     <maxCompositePoints value="0"/>
     <maxCompositeContours value="0"/>
@@ -169,12 +169,10 @@
         <pt x="26" y="723" on="1"/>
         <pt x="574" y="723" on="1"/>
         <pt x="574" y="578" on="1"/>
-        <pt x="363" y="578" on="1"/>
-        <pt x="408" y="623" on="1"/>
+        <pt x="408" y="578" on="1"/>
         <pt x="408" y="0" on="1"/>
         <pt x="209" y="0" on="1"/>
-        <pt x="209" y="623" on="1"/>
-        <pt x="254" y="578" on="1"/>
+        <pt x="209" y="578" on="1"/>
         <pt x="26" y="578" on="1"/>
       </contour>
       <instructions/>
@anthrotype anthrotype changed the title static fonts from single-master sources have overlaps, skewing glyf/gvar ttx diff static fonts from single-master sources have overlaps, skewing glyf ttx diff Oct 1, 2024
@jenskutilek
Copy link

Why not add --keep-overlaps to the fontmake call? It won't do any harm on the variable font build.

@anthrotype
Copy link
Member Author

of couse we can do that for the time being, until we have remove overlaps in rust, but the comparison would not be fair/realistic, since most static builds do/should have overlaps removed.

anthrotype added a commit that referenced this issue Oct 2, 2024
Fixes #975 (until we also have the ability to remove overlaps)
@anthrotype
Copy link
Member Author

after applying #979, ttx_diff'ing the above SingleMaster.glyphs test file yields "output is identical", though it feels a bit like cheating to me :)

I defer to @rsheeter

@rsheeter
Copy link
Contributor

rsheeter commented Oct 3, 2024

@raphlinus just noted https://github.com/GraphiteEditor/Graphite/tree/master/libraries/path-bool is now a thing, seems to be a port of a js pathops library. This one is new to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants