caryll / otfcc

Optimized OpenType builder and inspector.
Apache License 2.0
422 stars 63 forks source link

otfcc 0.9.6 on macOS x64 yields invalid OTF font after simple roundtrip #68

Open rsms opened 4 years ago

rsms commented 4 years ago

repro:

# fetch https://github.com/caryll/otfcc/archive/v0.9.6.tar.gz and unarchive
./dep/bin-osx/premake5 ninja
cd build/ninja
ninja otfccdump_release_x64 otfccbuild_release_x64
./bin/release-x64/otfccdump -o Inter-Regular.json Inter-Regular.otf
./bin/release-x64/otfccbuild -o Inter-Regular-otfccbuild.otf Inter-Regular.json

The input file Inter-Regular.otf is from the Inter v3.11 release and is verified to work correctly in a variety of font parsers (also it passes the macOS Font Book validator)

However the output file is not only MUCH larger in size but also does not work on macOS. Font Book validation fails with “System Validation” error:

Screen Shot 2020-01-22 at 08 34 27

Attached here is the input font file, resulting output font file and the JSON dump, to save you some time: otfs-and-json.zip

Here are TTX dumps with a diff: ttx-with-diff.zip

I also tried building the latest master from git which yields the exact same results.

Env:

$ uname -rsv
Darwin 18.7.0 Darwin Kernel Version 18.7.0: Sun Dec  1 18:59:03 PST 2019; root:xnu-4903.278.19~1/RELEASE_X86_64
$ ./bin/release-x64/otfccdump -v
This is otfccdump, version 0.9.6.
$ shasum Inter-Regular.otf
389bb3dbdb1bc81c96b000688ed672180b3ee78d  Inter-Regular.otf
rsms commented 4 years ago

I tried disabling everything I could think of with otfccbuild and still the same issue:

./bin/release-x64/otfccbuild -O0 --keep-unicode-ranges --keep-modified-time \
  --dont-merge-features --dont-merge-lookups --keep-average-char-width \
  -o Inter-Regular-otfccbuild.otf Inter-Regular.json

I ran OTS 7.1.7 on the font files and no combinations of options yields a readable font file. E.g. ots-validator-checker Inter-Regular-otfccbuild.otffont renderer couldn't open the transcoded font (whereas with the original input file ots-validator-checker Inter-Regular.otffont renderer didn't crash which is OTS’s way of saying that it succeeded. OTS is used in Chrome to validate fonts.)

be5invis commented 4 years ago

Strange. I do not have dev environment for otfcc now since it has been stalled for pretty a while. Note that if you want to fix https://github.com/rsms/inter/issues/228 by round-tripping with otfcc then it won't. otfcc's bounding box definition is also wrong.

rsms commented 4 years ago

Thanks for chiming in @be5invis. I’m working on a project unrelated to Inter where I’d like to use otfcc. I used its code in a C project and kept getting invalid font files as an output; thought it was my code that somehow used the otfcc functions incorrectly, so I tried just compiling with master and latest stable release. Turned out there’s an issue in otfcc :–)