googlefonts / fontc

Where in we pursue oxidizing (context: https://github.com/googlefonts/oxidize) fontmake.
Apache License 2.0
85 stars 14 forks source link

fontmake adds mac names for font-specific names #1105

Closed rsheeter closed 1 week ago

rsheeter commented 2 weeks ago

python resources/scripts/ttx_diff.py 'https://github.com/Omnibus-Type/Grenze-Gotisch#sources/GrenzeGotisch.glyphs' --compare gftools --config ~/.fontc_crater_cache/Omnibus-Type/Grenze-Gotisch/sources/config.yaml fails on name.

In poking at this it seems that fontmake adds mac (platformID="1" platEncID="0" langID="0x0") names for the font-specific (id >= 256) names while fontc does not. Amending fontc to do the same, e.g. to also insert a mac name at https://github.com/googlefonts/fontc/blob/5ba53cf1d77d28483e6853438f9300195acaa566/fontir/src/ir.rs#L438, makes ttx_diff pass but that seems odd.

# reduced fontc
cargo run ~/.fontc_crater_cache/Omnibus-Type/Grenze-Gotisch/sources/GrenzeGotisch.glyphs

# reduced fontmake
fontmake --output-path build/fontmake.ttf -o variable -g  ~/.fontc_crater_cache/Omnibus-Type/Grenze-Gotisch/sources/GrenzeGotisch.glyphs

# what's name look like?
$ ttx -o - -t name build/font.ttf
$ ttx -o - -t name build/fontmake.ttf

Perhaps this is a case where we should alter fontmake? Or is there a reason this behavior is correct?

For example:

  <name>
    <!-- fontmake only -->
    <namerecord nameID="256" platformID="1" platEncID="0" langID="0x0" unicode="True">
      Weight
    </namerecord>
    <namerecord nameID="257" platformID="1" platEncID="0" langID="0x0" unicode="True">
      Thin
    </namerecord>
    <namerecord nameID="258" platformID="1" platEncID="0" langID="0x0" unicode="True">
      ExtraLight
    </namerecord>
    <namerecord nameID="259" platformID="1" platEncID="0" langID="0x0" unicode="True">
      Light
    </namerecord>
    <namerecord nameID="260" platformID="1" platEncID="0" langID="0x0" unicode="True">
      Regular
    </namerecord>
    <namerecord nameID="261" platformID="1" platEncID="0" langID="0x0" unicode="True">
      Medium
    </namerecord>
    <namerecord nameID="262" platformID="1" platEncID="0" langID="0x0" unicode="True">
      SemiBold
    </namerecord>
    <namerecord nameID="263" platformID="1" platEncID="0" langID="0x0" unicode="True">
      Bold
    </namerecord>
    <namerecord nameID="264" platformID="1" platEncID="0" langID="0x0" unicode="True">
      ExtraBold
    </namerecord>
    <namerecord nameID="265" platformID="1" platEncID="0" langID="0x0" unicode="True">
      Black
    </namerecord>

    <!-- common -->
    <namerecord nameID="0" platformID="3" platEncID="1" langID="0x409">
      Copyright 2020 The Grenze Gotisch Project Authors (https://github.com/Omnibus-Type/Grenze-Gotisch)
    </namerecord>
    <namerecord nameID="1" platformID="3" platEncID="1" langID="0x409">
      Grenze Gotisch
    </namerecord>
    <namerecord nameID="2" platformID="3" platEncID="1" langID="0x409">
      Regular
    </namerecord>
    <namerecord nameID="3" platformID="3" platEncID="1" langID="0x409">
      1.002;OMNI;GrenzeGotisch-Regular
    </namerecord>
    <namerecord nameID="4" platformID="3" platEncID="1" langID="0x409">
      Grenze Gotisch Regular
    </namerecord>
    <namerecord nameID="5" platformID="3" platEncID="1" langID="0x409">
      Version 1.002
    </namerecord>
    <namerecord nameID="6" platformID="3" platEncID="1" langID="0x409">
      GrenzeGotisch-Regular
    </namerecord>
    <namerecord nameID="7" platformID="3" platEncID="1" langID="0x409">
      Grenze Gotisch is a trademark of Omnibus-Type.
    </namerecord>
    <namerecord nameID="8" platformID="3" platEncID="1" langID="0x409">
      Omnibus-Type
    </namerecord>
    <namerecord nameID="9" platformID="3" platEncID="1" langID="0x409">
      Renata Polastri
    </namerecord>
    <namerecord nameID="10" platformID="3" platEncID="1" langID="0x409">
      Grenze Gotisch: a peculiar version of Grenze, now presenting Blackletter uppercase letters and little dramatic details in certain lowercase letters, which intensify its expressive burden.
    </namerecord>
    <namerecord nameID="11" platformID="3" platEncID="1" langID="0x409">
      www.omnibus-type.com
    </namerecord>
    <namerecord nameID="12" platformID="3" platEncID="1" langID="0x409">
      www.omnibus-type.com
    </namerecord>
    <namerecord nameID="13" platformID="3" platEncID="1" langID="0x409">
      This Font Software is licensed under the SIL Open Font License, Version 1.1. This license is available with a FAQ at: http://scripts.sil.org/OFL
    </namerecord>
    <namerecord nameID="14" platformID="3" platEncID="1" langID="0x409">
      http://scripts.sil.org/OFL
    </namerecord>
    <namerecord nameID="256" platformID="3" platEncID="1" langID="0x409">
      Weight
    </namerecord>
    <namerecord nameID="257" platformID="3" platEncID="1" langID="0x409">
      Thin
    </namerecord>
    <namerecord nameID="258" platformID="3" platEncID="1" langID="0x409">
      ExtraLight
    </namerecord>
    <namerecord nameID="259" platformID="3" platEncID="1" langID="0x409">
      Light
    </namerecord>
    <namerecord nameID="260" platformID="3" platEncID="1" langID="0x409">
      Regular
    </namerecord>
    <namerecord nameID="261" platformID="3" platEncID="1" langID="0x409">
      Medium
    </namerecord>
    <namerecord nameID="262" platformID="3" platEncID="1" langID="0x409">
      SemiBold
    </namerecord>
    <namerecord nameID="263" platformID="3" platEncID="1" langID="0x409">
      Bold
    </namerecord>
    <namerecord nameID="264" platformID="3" platEncID="1" langID="0x409">
      ExtraBold
    </namerecord>
    <namerecord nameID="265" platformID="3" platEncID="1" langID="0x409">
      Black
    </namerecord>
  </name>
anthrotype commented 2 weeks ago

You asked the very same question one year ago :)

https://github.com/googlefonts/fontmake/issues/1003#issuecomment-1571665084

It's a workaround for some ancient macOS which didn't even officially support OT variations, we can choose not to follow fonttools and prune these in ttx_diff.py

The reason we haven't changed it in fonttools is because nobody bothered. We could, but not huge priority

anthrotype commented 2 weeks ago

This issue may also be relevant https://github.com/googlefonts/fontmake/issues/360

rsheeter commented 2 weeks ago

LOL I'm err ... consistent :D

behdad commented 2 weeks ago

The MacRoman is smaller since it encodes as 8bit; name table doesn't support UTF-8, so otherwise we'd be encoding as UTF-16.

rsheeter commented 2 weeks ago

The MacRoman is smaller

If we only did Mac Roman, sure, but we're inconsistently (only for font-specific names) doing it in addition to windows names. From reading the associated issues this seems undesirable, maybe we can fix Python?

rsheeter commented 2 weeks ago

Maybe fontmake should only add mac for font-specific names if it has mac names for other names? - exploratory hackery in https://github.com/fonttools/fonttools/pull/3688 to exhibit

behdad commented 2 weeks ago

Maybe fontmake should only add mac for font-specific names if it has mac names for other names? - exploratory hackery in fonttools/fonttools#3688 to exhibit

I'm inclined to say we should add only MacRoman if name is ASCII.

anthrotype commented 1 week ago

I'm inclined to say we should add only MacRoman if name is ASCII.

I believe it's safer to just use Windows Unicode names for all nowadays, even if it cost a few extra bytes.

m4rc1e commented 1 week ago

Since the name IDs are greater than 256, I reckon it's coming from the stat builder https://github.com/fonttools/fonttools/blob/main/Lib/fontTools/otlLib/builder.py#L2694.

anthrotype commented 1 week ago

thanks marc for reminding of that. I think in the particular example that Rod used (GrenzeGotisch.glyphs), the otlLib.buildStatTable is not called, because that's only used by varLib when the input is a designspace v5 with STAT-related attributes and glyphsLib which created the DS+UFOs doesn't export those. But yeah https://github.com/fonttools/fonttools/pull/3688 ought to take care of those too.