-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
202 lines (155 loc) · 5.1 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
GIT := $(shell which git)
FONTFORGE := $(shell which fontforge)
BASE := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PATH_DIST := $(BASE)/dist
PATH_SRC := $(BASE)/src
PATH_TMP := $(BASE)/tmp
.PHONY: all
all: support build
# Support commands
support: prepare-src update-framework dependencies-install
update-framework:
ifeq (,$(GIT))
@echo "update-framework: It seems that you don't have git on this computer... Its a must!!";
else
@$(GIT) remote | grep framework > /dev/null || $(GIT) remote add framework https://github.com/findhit/font-framework.git;
@$(GIT) fetch framework;
@$(GIT) rebase framework/master;
endif
dependencies-install:
# Linux
ifeq ($(UNAME_S),Linux)
# Update packages
sudo apt-get -y update
# Install packages
sudo apt-get -y install fontforge ttfautohint ttf2eot
endif
# Mac OS
ifeq ($(UNAME_S),Darwin)
# Install brew if not installed
ifeq (,$(shell which brew))
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@brew install ruby python
endif
# Update packages
@brew update
# Install packages
@brew install fontforge || brew reinstall fontforge
@brew install ttfautohint || brew reinstall ttfautohint
@brew install ttf2eot || brew reinstall ttf2eot
endif
skeleton:
define SKELETON
example/sans-serif/regular/2 \
example/sans-serif/regular/4 \
example/sans-serif/regular/7 \
example/sans-serif/italic/2 \
example/sans-serif/italic/4 \
example/sans-serif/italic/7 \
example/serif/regular/2 \
example/serif/regular/4 \
example/serif/regular/7
endef
# We must drive some changes here yet
@for x in $(SKELETON); do \
mkdir -p "$(PATH_SRC)/$${x}/glyphs"; \
done
# for each one we will create glyphs from resources
@if [ -f "$(BASE)/resources/glyph-baseline.svg" ]; then \
for x in $(SKELETON); do \
for g in 0041 0042 0043 0061 0062 0063; do \
cp "resources/glyph-baseline.svg" "$(PATH_SRC)/$${x}/glyphs/$${g}.svg"; \
done \
done \
fi
@echo "We've created an example skeleton for you!!";
@echo "If you want to build it, run: make build";
@echo "Otherwise, you could clean **src/** folder by running: make clean-src";
# Prepare commands
prepare-src:
mkdir -p $(PATH_SRC)
prepare-dist:
mkdir -p $(PATH_DIST)
# Clean things
clean: clean-src clean-dist
clean-src:
@echo "Heyyy!!! Did you mean that you want to clean all the SOURCES!?!? Are you really sure?? If yes write on upper case [YES I DO]:"
@read TMP; if [ "$$TMP" == "YES I DO" ]; then \
rm -fR $(PATH_SRC)/*; \
fi
clean-dist:
rm -fR $(PATH_DIST)/*
# Check things
check:
@echo "Not ready yet... sorry...";
# General build commands
build: check build-font build-webfont
build-font: prepare-dist build-font-svg build-font-ttf build-font-eot build-font-otf build-font-woff
build-webfont: prepare-dist build-webfont-eot build-webfont-svg build-webfont-ttf build-webfont-otf build-webfont-woff
built-tmp-fonts: prepare-src
@echo "Generating fonts:";
-@rm -fR $(PATH_TMP)/
@mkdir -p $(PATH_TMP)/
@for FAMILY in `ls "$(PATH_SRC)"`; do \
PATH_FAMILY="$(PATH_SRC)/$$FAMILY"; \
for MEMBER in `ls "$$PATH_FAMILY"`; do \
PATH_MEMBER="$$PATH_FAMILY/$$MEMBER"; \
for TYPE in `ls "$$PATH_MEMBER"`; do \
PATH_TYPE="$$PATH_MEMBER/$$TYPE"; \
for WEIGHT in `ls "$$PATH_TYPE"`; do \
PATH_WEIGHT="$$PATH_TYPE/$$WEIGHT"; \
WEIGHT="$${WEIGHT}00"; \
PATH_FONT="$(PATH_TMP)/$${FAMILY}-$${MEMBER}-$${TYPE}-$${WEIGHT}.sfdir"; \
[ -f "$${PATH_FONT}" ] && rm -fR "$${PATH_FONT}"; \
\
echo " - $${FAMILY} $${MEMBER} $${TYPE} $${WEIGHT}"; \
\
CMDS="New()\n"; \
CMDS+="SetFontNames(\"$$MEMBER\", \"$$FAMILY\", \"$$FAMILY $$MEMBER $$TYPE\", \"$$WEIGHT\")\n"; \
for GLYPH in `ls "$$PATH_WEIGHT/glyphs"`; do \
PATH_GLYPH="$$PATH_WEIGHT/glyphs/$$GLYPH"; \
UNICODE="`echo $$GLYPH | tr -d .svg`"; \
CMDS+="Select( 0u$$UNICODE )\n"; \
CMDS+="Import( \"$$PATH_GLYPH\", 16 )\n"; \
done; \
CMDS+="Save(\"$${PATH_FONT}\")\n"; \
echo "$$CMDS" | $(FONTFORGE) > /dev/null; \
done; \
done; \
done; \
done;
# Commands for building ttf font-format
ttf: build-ttf
build-ttf: build-font-ttf build-webfont-ttf
build-font-ttf: built-tmp-fonts
@echo "Not ready yet... sorry...";
build-webfont-ttf:
@echo "Not ready yet... sorry...";
# Commands for building eot font-format
eot: build-eot
build-eot: build-font-eot build-webfont-eot
build-font-eot: built-tmp-fonts
@echo "Not ready yet... sorry...";
build-webfont-eot:
@echo "Not ready yet... sorry...";
# Commands for building svg font-format
svg: build-svg
build-svg: build-font-svg build-webfont-svg
build-font-svg: built-tmp-fonts
@echo "Not ready yet... sorry...";
build-webfont-svg:
@echo "Not ready yet... sorry...";
# Commands for building otf font-format
otf: build-otf
build-otf: build-font-otf build-webfont-otf
build-font-otf: built-tmp-fonts
@echo "Not ready yet... sorry...";
build-webfont-otf:
@echo "Not ready yet... sorry...";
# Commands for building woff font-format
woff: build-woff
build-woff: build-font-woff build-webfont-woff
build-font-woff: built-tmp-fonts
@echo "Not ready yet... sorry...";
build-webfont-woff:
@echo "Not ready yet... sorry...";