Replies: 1 comment
-
The easiest would be if there is already a zero-width glyph in the font. Then you could just add the U+200B Unicode to the existing glyph, by setting up entries in the from fontTools.ttLib import TTFont
def map_glyph_font(font, glyph_name, codepoints):
"""
Map glyph `glyph_name` in font object `font` to codepoints.
"""
for cmap in font["cmap"].tables:
if (cmap.platformID, cmap.platEncID) == (1, 0):
# Don't bother with Mac subtables
continue
for cp in codepoints:
if cp <= 0xFFFF or cmap.format == 12:
cmap.cmap[cp] = glyph_name
font = TTFont("/path/to/font.otf")
map_glyph_font(font, "existing_glyph_name", [0x200B])
font.save("/path/to/font_modified.otf") |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
question
I want to add the simple glyph
U+200B
to a font (OTF in different flavours), which lacks it. I want to edit the font as little as possible. Does anyone have an optimal approach for me? Gladly also completely in Python.my current workflow
ttx
to convert the font into the ttx-formatttx
to convert the font into otf-formatlooks in code like this:
XML
discussion
Beta Was this translation helpful? Give feedback.
All reactions