Hi,
is there a way to generate a text file with a table of all glyphs of my font listing ID, name, Unicode and Unicode name?
Basically I need a text file of this:
Thanks for any hints.
H
Hi,
is there a way to generate a text file with a table of all glyphs of my font listing ID, name, Unicode and Unicode name?
Basically I need a text file of this:
Thanks for any hints.
H
Generate a csv table like this:
import csv
import unicodedata
def generate_glyph_csv(font, file_path):
with open(file_path, 'w', newline='', encoding='utf-8') as csvfile:
csv_writer = csv.writer(csvfile)
# Write header row
csv_writer.writerow(["ID", "Name", "Unicode Value", "Unicode Name"])
for index, glyph in enumerate(font.glyphs):
unicode_value = f"{glyph.unicode:04}" if glyph.unicode else "N/A"
if glyph.unicode:
try:
unicode_name = unicodedata.name(chr(int(glyph.unicode, 16)))
except ValueError:
unicode_name = "Unknown"
else:
unicode_name = "N/A"
csv_writer.writerow([index, glyph.name, unicode_value, unicode_name])
# Get the current font
font = Glyphs.font
# Generate and save the CSV file
file_path = "/users/YOUR_USER_NAME/Desktop/glyph_data.csv"
generate_glyph_csv(font, file_path)
print(f"CSV file has been generated and saved to: {file_path}")
Thanks.
Sebastian, you know my coding skills.
As if I would know what to do with this piece of code. Haha.
Simply paste it into the macro panel of Glyphs (Window > Show Macro Panel).
Replace YOUR_USER_NAME
with your Mac user name (sebastiancarewe in my case, maybe henningskibbe for you).
The script will generate a .CSV file on your desktop, which you can open with most common text applications (or transform into other formats with, for example, Google Sheets).
Oh beautiful. This sounds like even I might be able to handle it. Thanks a million. You are the sweetest. Cheers.