-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
80 lines (56 loc) · 2.11 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
FROM := Menlo
INTO := Monaco
RESULT := Menloco
EXTEND_BY := 150
TRIANGLE_OFFSET := 50
# Paths
OBJDIR := fonts
SUBSET := $(OBJDIR)/$(FROM)-subset.ttf
SUBSET_LIST := glyph-list.txt
# Programs that this makefile relies on to execute its tasks
NEEDED_TOOLS := perl fontforge python
NEEDED_ERROR := "ERROR: One or more required tools are unavailable:\n\t"
# Primary tasks
all: check clean extend merge preview
preview: $(OBJDIR)/preview.htm
xml: $(OBJDIR)/$(FROM).ttx
subset: $(SUBSET)
# Use FontForge to transfer fonts from Menlo into a copy of Monaco
merge: $(OBJDIR)/$(FROM).ttf $(OBJDIR)/$(INTO).ttf
@utils/ff-patch.py \
--from=$(OBJDIR)/$(FROM).ttf \
--into=$(OBJDIR)/$(INTO).ttf \
--save-to=$(OBJDIR)/$(RESULT).ttf \
--glyphs-file=$(SUBSET_LIST) \
--font-name=$(RESULT)
# Generates an HTML page displaying the generated font and opens it
$(OBJDIR)/preview.htm: tests/glyph-test.txt $(OBJDIR)/$(RESULT).ttf
@utils/preview-font.pl --old=$(INTO) --new=$(RESULT) --preview-file=$< > $@
@open $@
# Searches the system for a named font file, copying it to the objects directory
$(OBJDIR)/%.ttf:
@utils/find-font.sh "$*" "$@"
# Subset a range of glyphs designated by "glyph-list.txt"
$(SUBSET): $(SUBSET_LIST)
sfnttool -s "$$(perl -pe 's/\s//g' < $<)" $(OBJDIR)/$(FROM).ttf $@
# FontTools XML dump
$(OBJDIR)/%.ttx: $(SUBSET)
ttx -o $@ $<
perl -p -i -e 's/\x20{2}/\t/g' $@
# Extract every subsetted glyph as an SVG file
svg: $(OBJDIR)/$(FROM).ttf $(SUBSET_LIST)
@mkdir -p $(OBJDIR)/svg
@utils/ff-extract.py \
--font-file=$(OBJDIR)/$(FROM).ttf \
--save-to=$(OBJDIR)/svg \
--glyphs-file=$(SUBSET_LIST)
# Stretch the vertical extents of each box-drawing glyph
extend: $(OBJDIR)/$(FROM).ttf
@[ $(EXTEND_BY) -gt 0 ] && { utils/ff-extend.py $< $(EXTEND_BY) $(TRIANGLE_OFFSET); } ||:
# Wipe the slate clean
clean:
@rm -rf $(wildcard $(OBJDIR))
# Verifies the availability of programs needed to run these tasks
check:
@hash $(NEEDED_TOOLS) 2>/dev/null || { >&2 echo $(NEEDED_ERROR) $(NEEDED_TOOLS); exit 1; }
.PHONY: clean check