diff --git a/FiraCode-Medium.otf b/FiraCode-Medium.otf deleted file mode 100644 index a13550d..0000000 Binary files a/FiraCode-Medium.otf and /dev/null differ diff --git a/fira/FiraCode-Bold.otf b/fira/FiraCode-Bold.otf new file mode 100644 index 0000000..37fe2b5 Binary files /dev/null and b/fira/FiraCode-Bold.otf differ diff --git a/fira/FiraCode-Light.otf b/fira/FiraCode-Light.otf new file mode 100644 index 0000000..1eb728b Binary files /dev/null and b/fira/FiraCode-Light.otf differ diff --git a/fira/FiraCode-Medium.otf b/fira/FiraCode-Medium.otf new file mode 100644 index 0000000..89f0e33 Binary files /dev/null and b/fira/FiraCode-Medium.otf differ diff --git a/fira/FiraCode-Regular.otf b/fira/FiraCode-Regular.otf new file mode 100644 index 0000000..6a4f953 Binary files /dev/null and b/fira/FiraCode-Regular.otf differ diff --git a/fira/FiraCode-Retina.otf b/fira/FiraCode-Retina.otf new file mode 100644 index 0000000..82210b5 Binary files /dev/null and b/fira/FiraCode-Retina.otf differ diff --git a/ligaturize.py b/ligaturize.py index 0621aea..e8effd6 100644 --- a/ligaturize.py +++ b/ligaturize.py @@ -1,9 +1,11 @@ #!/usr/bin/env python # -# usage: fontforge -lang=py ligaturize.py +# usage: fontforge -lang=py ligaturize.py [ligature file] # # It will copy input to output, updating the embedded font name and splicing -# in the ligatures from FiraCode-Medium.otf (which must be in $PWD). +# in the ligatures from FiraCode-Medium.otf (which must be in $PWD). If the +# ligature file is not specified, it will try to guess an appropriate Fira Code +# OTF based on the name of the output file. # # See ligatures.py for a list of all the ligatures that will be copied. @@ -19,9 +21,21 @@ COPYRIGHT = ''' Programming ligatures added by Ilya Skriblovsky from FiraCode FiraCode Copyright (c) 2015 by Nikita Prokopov''' -config = { - 'firacode_ttf': 'FiraCode-Medium.otf', -} +def get_ligature_source(fontname): + if len(sys.argv) > 3: + # User explicitly told us which source to use. + return sys.argv[3] + + for weight in ['Bold', 'Retina', 'Medium', 'Regular', 'Light']: + if fontname.endswith('-' + weight): + # Exact match for one of the Fira Code weights + return 'fira/FiraCode-%s.otf' % weight + + # No exact match. Guess that we want 'Bold' if the font name has 'Bold' in + # it, and 'Regular' otherwise. + if 'Bold' in fontname: + return 'fira/FiraCode-Bold.otf' + return 'fira/FiraCode-Regular.otf' def get_output_font_details(fontpath): fontname = path.splitext(path.basename(fontpath))[0] @@ -140,7 +154,9 @@ output_font_path = sys.argv[2] output_font = get_output_font_details(output_font_path) font = fontforge.open(input_font_path) -firacode = fontforge.open(config['firacode_ttf']) +ligature_font_path = get_ligature_source(output_font['fontname']) +print('Reading ligatures from %s' % ligature_font_path) +firacode = fontforge.open(ligature_font_path) firacode.em = font.em creator = LigatureCreator(font, firacode)