googlefonts/fontations

Examples for write_fonts

expenses opened this issue · 3 comments

It'd be great to have a minimal example for how to write out a font from a set of glyphs. I'm specifically interested in unicode CJK characters.

cmyr commented

what format are your glyphs in initially? Assuming you have outlines in some raw format (i.e. not from an existing font) this is not a trivial task, and amounts to writing a font compiler. We're working on one of those over at https://github.com/googlefonts/fontc, and that code uses write-fonts as a dependency.

fontc seems like a great recommendation, thanks! I'm attempting to add pronunciation ligatures for CJK characters (mostly chinese with pinyin at the moment) similar to https://github.com/parlr/hanzi-pinyin-font/releases. For this I want to be able to take an existing font, shrink down the character outlines, position a string of glyphs for the ligature (with the same font) and combine the outlines.

My current approach is to use fontforge to convert a .ttf font to .svg, modify that and then convert it back. This is slow though and leads to some precision issues.

If you have sources it might be better to transform the sources. If you only have a binary then you could likely write a FontTools python tool that takes in the binary, makes the desired modifications, and emits an updated binary.