summaryrefslogtreecommitdiff
path: root/scripts/touchup_for_web.py
diff options
context:
space:
mode:
authorJames Godfrey-Kittle <jamesgk@google.com>2015-09-29 13:50:44 -0700
committerJames Godfrey-Kittle <jamesgk@google.com>2015-09-29 13:50:44 -0700
commit5bd6d2475816d8f2220ed44d4f503a051e06e0a4 (patch)
tree78cf7ac665bad07a749bc09bec3e669be6fdcb35 /scripts/touchup_for_web.py
parent74bdf5953a7c20cdca0442e1b70a2d3b24072d01 (diff)
Provide a hotfix for webfont names.
This ensures that we'll only have four fonts with family name "Roboto" (regular, bold, italic, and bold italic), which is necessary for Windows compatibility. Other styles have their weight appended to the family name. Also ensures that the macStyle bold bit is set for weight Black, to be consistent with older Roboto binaries.
Diffstat (limited to 'scripts/touchup_for_web.py')
-rwxr-xr-xscripts/touchup_for_web.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/scripts/touchup_for_web.py b/scripts/touchup_for_web.py
index c4f75c1..3e29e58 100755
--- a/scripts/touchup_for_web.py
+++ b/scripts/touchup_for_web.py
@@ -47,9 +47,21 @@ def apply_web_specific_fixes(font, family_name):
family_name += ' Condensed'
full_name = family_name + ' ' + subfamily_name
- # Family name
- font_data.set_name_record(font, 1, family_name)
+ # macStyle
+ bold = subfamily_name.startswith(('Bold', 'Black'))
+ italic = subfamily_name.endswith('Italic')
+ macStyle = (italic << 1) | bold
+ font['head'].macStyle = macStyle
+
+ # Family, subfamily names
font_data.set_name_record(font, 16, family_name)
+ style_map = ['Regular', 'Bold', 'Italic', 'Bold Italic']
+ if subfamily_name in style_map:
+ font_data.set_name_record(font, 1, family_name)
+ else:
+ weight = subfamily_name.split()[0]
+ font_data.set_name_record(font, 1, '%s %s' % (family_name, weight))
+ font_data.set_name_record(font, 2, style_map[macStyle])
# Unique identifier and full name
font_data.set_name_record(font, 3, full_name)