From bee14674849edcaff4814a7f6f85dce2c584ed15 Mon Sep 17 00:00:00 2001 From: Peter Fern Date: Sat, 9 Mar 2013 18:15:24 +1100 Subject: [PATCH 1/2] Output in either otf or ttf (so we don't loose hinting/whatever) --- font/fontpatcher.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/font/fontpatcher.py b/font/fontpatcher.py index b0869843..2f2e4138 100755 --- a/font/fontpatcher.py +++ b/font/fontpatcher.py @@ -3,6 +3,7 @@ import argparse import sys +import os.path try: import fontforge @@ -100,7 +101,11 @@ class FontPatcher(object): target_font.em = target_font_em_original # Generate patched font - target_font.generate('{0}.otf'.format(target_font.fullname)) + extension = os.path.splitext(target_font.path)[1] + if extension.lower() not in ['.ttf', '.otf']: + # Default to OpenType if input is not TrueType/OpenType + extension = '.otf' + target_font.generate('{0}{1}'.format(target_font.fullname, extension)) fp = FontPatcher(args.source_font, args.target_fonts, args.rename_font) fp.patch() From 38e2368682c4abdf43cfe9e8ebb1110891399907 Mon Sep 17 00:00:00 2001 From: Peter Fern Date: Sat, 9 Mar 2013 18:55:22 +1100 Subject: [PATCH 2/2] Preserve style suffixes by inserting ForPowerline before any '-'s --- font/fontpatcher.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/font/fontpatcher.py b/font/fontpatcher.py index 2f2e4138..61663be1 100755 --- a/font/fontpatcher.py +++ b/font/fontpatcher.py @@ -3,6 +3,7 @@ import argparse import sys +import re import os.path try: @@ -41,7 +42,10 @@ class FontPatcher(object): if self.rename_font: target_font.familyname += ' for Powerline' target_font.fullname += ' for Powerline' - target_font.fontname += 'ForPowerline' + fontname, style = re.match("^([^-]*)(?:(-.*))?$", target_font.fontname).groups() + target_font.fontname = fontname + 'ForPowerline' + if style is not None: + target_font.fontname += style target_font.appendSFNTName('English (US)', 'Preferred Family', target_font.familyname) target_font.appendSFNTName('English (US)', 'Compatible Full', target_font.fullname)