Last active
August 8, 2020 06:44
-
-
Save zesty/c16053143f0362b076bcfbfe8a9677b6 to your computer and use it in GitHub Desktop.
afm fonts have odd font weights
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
# inspect the afm fonts | |
# I punted and went with: matplotlib.font_manager.weight_dict | |
# see: https://gist.github.com/zesty/de6f872908add8aca3c3a156431baa3b for the pretty stuff | |
# ref: Commonly used names for CSS font-weight values https://gist.github.com/lukaszgrolik/5849599 | |
import pandas as pd | |
import matplotlib.font_manager | |
df = pd.DataFrame( | |
# [(f.name, f.stretch, f.style, f.variant, f.weight, f.size) for f in matplotlib.font_manager.fontManager.ttflist] + | |
[(f.name, f.stretch, f.style, f.variant, f.weight, f.size) for f in matplotlib.font_manager.fontManager.afmlist]) | |
df.columns = ['name', 'stretch', 'style', 'variant', 'weight', 'size'] | |
pd.options.display.max_rows = None | |
for col in df.columns: | |
if col == 'name': | |
continue | |
print(df[col].value_counts()) | |
print() | |
df.sort_values(['name',"weight", 'style']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment