How can I reliably retrieve the weight classification of a font (Condensed, Compressed, Expanded, Wide, Etc.) using FontTools / TTX / FontForge CLI? #3157
Unanswered
futuremotiondev
asked this question in
Q&A
Replies: 1 comment 2 replies
-
What you are trying to do, If I well understood, is sorting fonts in folders. Since you have already installed ftCLI, you can just use https://github.com/ftCLI#ftcli-utils-font-organizer If the fonts are not grouped as a superfamily (width style is in Family Name, not in Subfamily Name), it will do exactly what asked. Otherwise, the question is a bit more complex. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am writing a script that aims to reliably sort a font family into it's individual weights if present. For instance:
After the script runs, it should create the following directories:
Condensed
,ExtraCondensed
,SemiCondensed
,Wide
- and then move the appropriate fonts to these folders.The small dataset above is just for illustration, obviously I could just search for these keywords in the filenames but this isn't at all reliable as many fonts are named more cryptically or follow different naming conventions.
I've got a Python VENV set up with
FontTools
,TTX
, andftcli
set up in an attempt to extract metadata so I can make more informed decisions in my script.I have a script that uses
ttLib
to extract theOS/2
usWidthClass:And a script to dump metadata using
FontMeta
:But I've found the usWidthClass to be hit or miss. A lot of typographers just set this value as
5
(Normal) no matter what width the font is. And the data extracted from FontMeta doesn't really supply any useful information for this problem.I could really use some guidance on how to move forward and scrape the information I need. Right now I'm just doing regex gymnastics on the supplied filenames and suspect there is a much more reliable way to go about this.
Any help greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions