Skip to content

Instantly share code, notes, and snippets.

Created November 1, 2020 00:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save erraticgenerator/ab3dcaf4ab0eb7ba50378fe17bc1f97f to your computer and use it in GitHub Desktop.
from IPython.display import clear_output
# display images
monitor = False
# font filtering
df = pd.read_csv('./google-fonts-annotaion.csv')
paths = filter_fonts_get_paths(df, root=ROOT, subsets=['latin'], variants=['bold'], category='serif')
# text setup
text = "G"
y = IMG_HEIGHT*3/4
text_size = 400
# create save directory
target_dir = f'./fonts-images/{text}'
!mkdir -p $target_dir
# drawing setup
canvas ='RGB', (IMG_WIDTH, IMG_HEIGHT), "black")
draw = ImageDraw.Draw(canvas)
for i, path in enumerate(paths):
font = ImageFont.truetype(path, text_size)
draw.text((x, y), text, 'white', font, anchor='ms')'{target_dir}/{i:05}.png', "PNG")
if monitor:
if i % 200 == 0:
print(f'exporting {i:05}th of {len(paths)}')
print('Exporting completed.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment