adobe-type-tools / afdko

Adobe Font Development Kit for OpenType
https://adobe-type-tools.github.io/afdko/
Other
1.05k stars 167 forks source link

Merge chars font with last-resort font #1573

Closed dy closed 1 year ago

dy commented 2 years ago

I'm trying to merge wavefont over AdobeBlank2 to make wavefont last-resort font, mapping any chars out of range to blank.

mergefonts wavefont.full.otf wavefont.otf AdobeBlank2VF.otf
mergefonts: (cfw) unhinted <.notdef>
mergefonts: (cfw) glyph skipped - same name, different charstring as glyph in font <.notdef>

But the resutling font is seemingly corrupted:

image

I wonder if that use-case is something the program is capable of? Do I have to specify glyph map maybe?

If that's impossible with mergefonts - I'd like to ask for advice what would be the good way to make such filling all chars with blanks? I tried reproducing method from Adobe Blank - patching the tables, but I don't understand where the binary chunks for cmap/gsub are coming from and how to properly modify them / regenerate for wavefont with changed subranges. That doesn't seem to be possible via feature-file, does it?

Thanks for any help...

punchcutter commented 1 year ago

I don't think mergefonts is the right tool for this at the moment. It sounds like it should do what you want, but it could use some updates for variable fonts for sure. There are other tools like fontTools merge which are more up to date with this kind of merging, but I tried that and it also failed. AdobeBlank is an unusual font in the first place so that's probably part of the issue. However, it's really a simple font. The binary GSUB and cmap don't really matter. There's nothing in the GSUB and the cmap is just scripted to point every codepoint to the single glyph. I did a quick test that I think does what you want.

ttx -t cmap wavefont.otf ttx -t cmap AdobeBlank2VF.otf

The AdobeBlank cmap will point to uni0000 for everything, but you want to use what's in wavefont already so replace all uni0000 with _0 . Then copy the entries from the wavefont cmap format 4 and paste them at the very end of the AdobeBlank cmap format 13.

Then run

ttx -m wavefont.otf updated-cmap.ttx and you should have a format 13 where everything points to _0 except for what you want mapped to the wavefont glyphs.

dy commented 1 year ago

Implemented that method in wavefont by just generating cmap format13 table from scratch and replacing it during the build. Works perfectly.

That was helpful, many thanks!