Skip to content

Commit

Permalink
Add some useful targets to Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
ToxicFrog committed Sep 4, 2021
1 parent bfa324d commit c5e95a6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
31 changes: 30 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
# To build with different settings (e.g. turn on character glyph copying),
# edit build.py and then "make".

all:
default: without-characters

all: without-characters with-characters

clean:
rm -rf fonts/output/* fonts/output-with-characters/* Ligaturized*.zip

release: clean all pack

pack:
zip -r -9 -j LigaturizedFonts.zip fonts/output/
zip -r -9 -j LigaturizedFontsWithCharacters.zip fonts/output-with-characters/

without-characters:
fontforge -lang=py -script build.py 2>&1 \
| grep -Fv 'This contextual rule applies no lookups.' \
| grep -Fv 'Bad device table'

with-characters:
fontforge -lang=py -script build.py --copy-character-glyphs 2>&1 \
| grep -Fv 'This contextual rule applies no lookups.' \
| grep -Fv 'Bad device table'

ligature-list:
luajit name2dict.lua < fonts/fira/FiraCode.glyphs

testpattern:
grep -F "{ #" ligatures.py \
| grep -v absent \
| cut -d'#' -f2 \
| tr -d ' ' \
| egrep '.' \
| sed -E 's,\\,\\\\,g' \
| xargs printf '| %6s %6s %6s %6s %6s %6s %6s %6s |\n'

.PHONY: testpattern
14 changes: 12 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

# Should we copy some individual punctuations characters like &, ~, and <>,
# as well as ligatures? The full list is in ligatures.py.
# You can also override this (and OUTPUT_DIR) automatically by passing
# --copy-character-glyphs on the command line.
COPY_CHARACTER_GLYPHS = False

# If copying individual characters, how different in width (relative to the font
Expand All @@ -19,6 +21,9 @@
# effectively disable this feature.
SCALE_CHARACTER_GLYPHS_THRESHOLD = 0.1

# Where to put the generated fonts.
OUTPUT_DIR = 'fonts/output/'

#### Fonts that should be prefixed with "Liga" when ligaturized. ####
# Don't put fonts licensed under UFL here, and don't put fonts licensed under
# SIL OFL here either unless they haven't specified a Reserved Font Name.
Expand Down Expand Up @@ -86,14 +91,19 @@
from glob import glob
from ligaturize import ligaturize_font

if '--copy-character-glyphs' in sys.argv:
COPY_CHARACTER_GLYPHS=True
OUTPUT_DIR='fonts/output-with-characters'


for pattern in prefixed_fonts:
files = glob(pattern)
if not files:
print("Error: pattern '%s' didn't match any files." % pattern)
sys.exit(1)
for input_file in files:
ligaturize_font(
input_file, ligature_font_file=None, output_dir='fonts/output/',
input_file, ligature_font_file=None, output_dir=OUTPUT_DIR,
prefix=LIGATURIZED_FONT_NAME_PREFIX, output_name=None,
copy_character_glyphs=COPY_CHARACTER_GLYPHS,
scale_character_glyphs_threshold=SCALE_CHARACTER_GLYPHS_THRESHOLD)
Expand All @@ -105,7 +115,7 @@
sys.exit(1)
for input_file in files:
ligaturize_font(
input_file, ligature_font_file=None, output_dir='fonts/output/',
input_file, ligature_font_file=None, output_dir=OUTPUT_DIR,
prefix=None, output_name=name,
copy_character_glyphs=COPY_CHARACTER_GLYPHS,
scale_character_glyphs_threshold=SCALE_CHARACTER_GLYPHS_THRESHOLD)
1 change: 1 addition & 0 deletions fonts/output-with-characters/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
8 changes: 1 addition & 7 deletions testpattern
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ QWERTYUIOP{}| qwertyuiop[]\
ASDFGHJKL:" asdfghjkl;'
ZXCVBNM< >? zxcvbnm,./

regenerate with
fgrep '{ #' ligatures.py \
| grep -v absent \
| cut -d'#' -f2 \
| tr -d ' ' \
| egrep '.' \
| xargs printf '| %6s %6s %6s %6s %6s %6s %6s %6s |\n' >> testpattern
regenerate with 'make testpattern >> testpattern'

| { { { { { { && ^= |
| ~~ ~~> ~@ ~= ~> ~- ** *** |
Expand Down

0 comments on commit c5e95a6

Please sign in to comment.