psb1558 / ygt

A graphical and cross-platform TrueType hinting program
Apache License 2.0
58 stars 1 forks source link

Can we retain untouched ttf hints? #12

Open 100amps opened 1 year ago

100amps commented 1 year ago

Would it be possible to export to TTF retaining existing TTF hints, overwriting only the glyph hints that have been touched by ygt? I'm thinking of a workflow that allows me to use ttfauothint and only manually hint the glyphs that need improvement.

psb1558 commented 1 year ago

Funny you should mention that. Xgridfit (the backend for Ygt) has a thing called "merge mode," which adds hints to a font that already has them, appending new instructions after the ones already in the font, new control program code after the existing code, and new CVs after the existing ones. It's meant for exactly the situation where ttfautohint does a good job in general, but you want to replace certain glyph programs that aren't cutting it. Sooner or later I'll implement "merge mode" from within Ygt, but even now you can use it. Just hint the glyphs you want to hint and save in a YAML file (or copy the file data/org.ygthinting/source out of your UFO). Run Xgridfit against the YAML file like this:

xgridfit -y myfile.yaml myfile.xgf

Xgridfit will produce a file myfile.xgf in its own native language. Then run the file myfile.xgf against the autohinted .ttf font in merge mode:

xgridfit -m myfile.xgf

Xgridfit will produce a .ttf font with your hints layered on top of the ones that ttfautohint added to the font.

I should mention that Ygt can't edit glyph programs added by ttfautohint: their ways of doing things are just too different. Ygt can only replace glyph programs.

I'll make this much easier when I can. In the meantime, the procedure I've outlined should work.

100amps commented 1 year ago

Thank you.

psb1558 commented 1 year ago

This is done now. See the section "Merge Mode" in YGT-Intro.pdf. If you can, try out the new binary releases on this site: one for the M1 Mac and the other for x86-64 Windows machines. Otherwise, the new version will be on PyPi later today or tomorrow.