Created
June 26, 2022 17:42
-
-
Save mslw/9cd6b4acee8ceda366a6c10cb5503477 to your computer and use it in GitHub Desktop.
A quick way of generating font samples in svg
This file contains 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
import svgwrite | |
# Catppuccin frappe, see https://github.com/catppuccin/catppuccin | |
base = svgwrite.rgb(48, 52, 70) | |
text = svgwrite.rgb(198, 208, 245) | |
blue = svgwrite.rgb(140, 170, 238) | |
green = svgwrite.rgb(166, 209, 137) | |
red = svgwrite.rgb(231, 130, 132) | |
fs_big=50 | |
fs = 42 | |
to_draw = [ | |
'Cormorant', | |
('Poltawski Nowy', 'Półtawski Nowy'), | |
'Hack', | |
'Anonymous Pro', | |
'Iosevka', | |
'Lato', | |
'Carlito', | |
'Vollkorn', | |
] | |
# alt. “The quick onyx goblin jumps over the lazy dwarf”: Flavor text from an Unhinged Magic Card. (39 letters) | |
for f in to_draw: | |
# disp_name can be used to display font name, currently unused | |
if isinstance(f, tuple): | |
font_fam, disp_name = f | |
else: | |
font_fam = disp_name = f | |
dwg = svgwrite.Drawing('{}.svg'.format(font_fam.replace(' ', '_')), (800, 115)) | |
dwg.add(dwg.rect(insert=(0, 0), size=(800,115), fill=base)) | |
dwg.add(dwg.text('Cwm fjord bank glyphs vext quiz', insert=(10, 45), fill=text, font_size=fs, font_family=font_fam)) | |
dwg.add(dwg.text('Aa Qq Rr Łł Żż', insert=(10, 95), fill=red, font_size=fs, font_family=font_fam)) | |
dwg.add(dwg.text('1234567890', insert=(790, 95), fill=green, font_size=fs, font_family=font_fam, text_anchor='end')) | |
dwg.save(font_fam.replace(' ', '_') + '.svg') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment