A Python utility that renames OpenType (.otf
) and TrueType (.ttf
) fonts using the fonttools library. This forked version of Chris Simpkins' fontname.py script has been packaged to allow simple installation as a global command line tool using pipx
.
Font renaming script for OpenType tables in CFF (.otf) and OT TrueType (.ttf) fonts
- Python 3.6 or later
- fonttools Python library (4.0.0 or later)
Once installed globally, fontnamer
can be used as follows:
$ fontnamer family_name font_file...
The fontnamer
command updates the name table records of .ttf
and .otf
files with appropriately formatted font names given the user-provided family_name
and the style definition found within each font_file
.
A few things to keep in mind:
- You can provide multiple
font_file
arguments - Use quotes around
family_name
arguments that include spaces - This tool edits the font files in place, so make copies beforehand if you you would like to preserve the fonts with their former names. (You can always rewrite them with the previous name if you forget or change your mind.)
To apply a new family name to a font file, fontnamer
updates the following entries in its name
table: Family Name (name ID 1).
Full Name (name ID 4), PostScript name (id 6), Typographic Family (id 16). For OpenType fonts with Compact Font Format data, fonttools
also updates the FontName
, FullName
, and FamilyName
records in the CFF
table.
$ fontnamer "Hack DEV" Hack-Regular.ttf
$ fontnamer "Source Code Pro DEV" SourceCodePro-Regular.otf
$ fontnamer "DejaVu Sans Mono DEV" DejaVuSansMono-Bold.ttf
These should all be detected as "different" fonts so that you can install them side-by-side with the pre-modified versions.
Many fonts have licences prohibiting modifications of any kind, including changes to font family names and other metadata. Please make sure to understand and respect the licenses of any fonts you wish to rename.