woff_info.py
- Python WOFF Font Inspector¶
Provides a number of functions that can be used to extract the 'name' data from .woff (web font) files.
Note
In most cases .woff files have the metadata stripped (to save space) which is why this module only grabs the 'name' records from the snft (font data) tables.
Example:
>>> from pprint import pprint
>>> from woff_info import woff_name_data
>>> woff_path = '/opt/gateone/applications/terminal/static/fonts/ubuntumono-normal.woff'
>>> pprint(woff_info(woff_path))
{'Compatible Full': 'Ubuntu Mono',
'Copyright': 'Copyright 2011 Canonical Ltd. Licensed under the Ubuntu Font Licence 1.0',
'Designer': 'Dalton Maag Ltd',
'Designer URL': 'http://www.daltonmaag.com/',
'Font Family': 'Ubuntu Mono',
'Font Subfamily': 'Regular',
'Full Name': 'Ubuntu Mono',
'ID': 'Ubuntu Mono Regular Version 0.80',
'Manufacturer': 'Dalton Maag Ltd',
'Postscript Name': 'UbuntuMono-Regular',
'Preferred Family': 'Ubuntu Mono',
'Preferred Subfamily': 'Regular',
'Trademark': 'Ubuntu and Canonical are registered trademarks of Canonical Ltd.',
'Vendor URL': 'http://www.daltonmaag.com/',
'Version': 'Version 0.80'}
This script can also be executed on the command line to display the name information for any given WOFF file:
user@modern-host:~ $ ./woff_info static/fonts/ubuntumono-normal.woff { "Compatible Full": "Ubuntu Mono", "Copyright": "Copyright 2011 Canonical Ltd. Licensed under the Ubuntu Font Licence 1.0", "Designer": "Dalton Maag Ltd", "Designer URL": "http://www.daltonmaag.com/", "Font Family": "Ubuntu Mono", "Font Subfamily": "Regular", "Full Name": "Ubuntu Mono", "ID": "Ubuntu Mono Regular Version 0.80", "Manufacturer": "Dalton Maag Ltd", "Postscript Name": "UbuntuMono-Regular", "Preferred Family": "Ubuntu Mono", "Preferred Subfamily": "Regular", "Trademark": "Ubuntu and Canonical are registered trademarks of Canonical Ltd.", "Vendor URL": "http://www.daltonmaag.com/", "Version": "Version 0.80" }
..note:
The command line output is JSON so it can be easily used by other programs.