diff options
author | Roozbeh Pournader <roozbeh@google.com> | 2014-06-11 09:16:42 -0700 |
---|---|---|
committer | Roozbeh Pournader <roozbeh@google.com> | 2014-06-11 09:16:42 -0700 |
commit | 24a9472fe5d23be9cf35e2084ef22b36e3817400 (patch) | |
tree | 8e77f98f832c9db44c1f1f2201f1576fefa45d87 /scripts | |
parent | 3d56ba1d903737d6975b83ea5a417e83d17f0d06 (diff) |
Add script for post-production touch up of fonts
Also update to touched up Roboto and Roboto Condensed fonts.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/final_touchup.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/final_touchup.py b/scripts/final_touchup.py new file mode 100755 index 0000000..5e02070 --- /dev/null +++ b/scripts/final_touchup.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +"""Post-build touch ups for Roboto.""" + +from os import path +import sys + +from fontTools import ttLib + + +def correct_font(source_font_name, target_font_name): + """Corrects metrics and other meta information.""" + font = ttLib.TTFont(source_font_name) + + head = font['head'] + head.yMax = 2163 + head.yMin = -555 + + hhea = font['hhea'] + hhea.ascent = 1900 + hhea.descent = -500 + hhea.lineGap = 0 + + basename = path.basename(source_font_name) + bold = ('Bold' in basename) or ('Black' in basename) + italic = 'Italic' in basename + head.macStyle = (italic << 1) | bold + + font.save(target_font_name) + + +def main(argv): + """Correct all fonts specified in the command line.""" + for font_name in argv[1:]: + correct_font(font_name, path.basename(font_name)) + + +if __name__ == "__main__": + main(sys.argv) |