Last active
June 10, 2023 05:26
-
-
Save frankrolf/a4601673207d2a84e8027c7b91d60620 to your computer and use it in GitHub Desktop.
DrawBot script to write image files for each glyph contained in a given font file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use absolute or relative path. This can be OTF or TTF. | |
font_path = 'my_font.otf' | |
# set the current font to be the one specified above, so we can list its glyph names: | |
font(font_path) | |
# loop through the list of glyph names: | |
for gid, g_name in enumerate(listFontGlyphNames()): | |
# the new page is 1000 by 1000 points by default | |
newPage() | |
fs = FormattedString( | |
font=font_path, | |
fontSize=500, | |
align='center', | |
) | |
# writing the glyph name into the formatted string | |
fs.appendGlyph(g_name) | |
# a text box in which the string is used | |
textBox(fs, (0, 0, 1000, 800)) | |
# using the GID for the file name, because macOS is not case sensitive: | |
saveImage(f'~/Desktop/{gid}_{g_name}.png') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment