googlefonts / ufo2ft

A bridge from UFOs to FontTools objects (and therefore, OTFs and TTFs).
MIT License
152 stars 43 forks source link

Add quantized mark feature writer #513

Closed simoncozens closed 3 years ago

simoncozens commented 3 years ago

So, this is something of an experimental one. It's the same as the normal mark feature writer, but before emitting the anchor positions it quantises them to a given number of units. When you add this to your feature writers lib key:

        <dict>
          <key>module</key>
          <string>ufo2ft.featureWriters.quantizedMarkFeatureWriter</string>
          <key>class</key>
          <string>QuantizedMarkFeatureWriter</string>
          <key>options</key>
          <dict>
            <key>mode</key>
            <string>skip</string>
            <key>quantization</key>
            <integer>10</integer>
          </dict>
        </dict>

the anchors will be quantised to the nearest ten units. In a large file, this allows "nearby" anchors to share anchor subtables, reducing the file size quite impressively, at a slight cost in visual fidelity.

behdad commented 3 years ago

Please make the default or suggested quantization a power of 2. That would save even more in WOFF/WOFF2...

behdad commented 3 years ago

I think we should add the quanitzation parameter to existing feature-writer, not add a separate one.

anthrotype commented 3 years ago

I think we should add the quanitzation parameter to existing feature-writer, not add a separate one.

+1