-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
120 lines (99 loc) · 3.64 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
## Example Makefile for Sahel font
## Copy SFD source files to SRCDIR
## Copy TTF Latin fonts to LATDIR
## https://github.com/rastikerdar/sahel-font/tree/master/source
## https://github.com/google/fonts/tree/master/apache/opensans
NAME = Sahel
LATIN = OpenSans
## Font weights are 400, 700, 900
FONTS = Sahel Sahel-Bold Sahel-Black
## Font weights are 400, 700, 800
LATINWEIGHTS = Regular Bold ExtraBold
## Directories
SRCDIR = source/farsi
LATDIR = source/latin
TOOLDIR = tools
RESDIR = res
DISTDIR = out/fonts
DOCDIR = out/doc
WEBDIR = out/webfonts
SFD = sfd
PY ?= python
BUILD = $(TOOLDIR)/build.py
MAKETAB = $(TOOLDIR)/maketextable.py
MAKEWEB = $(TOOLDIR)/makeweb.py
MAKECSS = $(TOOLDIR)/makecss.py
LATDEP = $(LATDIR)/$(LATIN)-$(word 1,$(LATINWEIGHTS)).ttf
FDFEA = $(RESDIR)/digits.fea
OTF = $(FONTS:%=$(DISTDIR)/%.otf)
WLOTF = $(FONTS:%=$(DISTDIR)/%-WOL.otf)
FDOTF = $(FONTS:%=$(DISTDIR)/%-FD.otf)
WTTF = $(FONTS:%=$(WEBDIR)/%.ttf)
WOFF = $(FONTS:%=$(WEBDIR)/%.woff)
WOF2 = $(FONTS:%=$(WEBDIR)/%.woff2)
WEOT = $(FONTS:%=$(WEBDIR)/%.eot)
CSS = $(WEBDIR)/$(NAME).css
DOCS = $(DOCDIR)/sample.pdf $(DOCDIR)/table.pdf
## Comment the second line to see the build errors
SUPPRESS =
SUPPRESS = 2> /dev/null
all: otf doc
.PHONY: all
otf: $(WLOTF) $(OTF) $(FDOTF)
web: $(WTTF) $(WOFF) $(WOF2) $(WEOT) $(CSS)
doc: $(DOCS)
SHELL=/usr/bin/env bash
## Plain build of the font without mixing in the Latin digits
$(DISTDIR)/%-WOL.otf $(DISTDIR)/%-WOL.ttf: $(SRCDIR)/%.$(SFD) $(BUILD)
@echo GEN $@
@$(PY) $(BUILD) --arabic-file=$< --out-file=$@ $(SUPPRESS)
## Merge Latin chars into the font
$(DISTDIR)/%.otf $(DISTDIR)/%.ttf: $(SRCDIR)/%.$(SFD) $(BUILD) $(LATDEP)
@echo GEN $@
@export LATW=`$(PY) -c "a='$(FONTS)'; \
b='$(LATINWEIGHTS)'; \
print ''.join([y for x, y in zip(a.split(), b.split()) \
if x == '$(notdir $(basename $@)' ]))"`; \
$(PY) $(BUILD) --arabic-file=$< --out-file=$@ \
--latin-file=$(LATDIR)/$(LATIN)-$$LATW.ttf \
--merge-type plain $(SUPPRESS)
## Merge Latin chars into the font and convert Latin digits to Farsi
$(DISTDIR)/%-FD.otf $(DISTDIR)/%-FD.ttf: $(SRCDIR)/%.$(SFD) $(BUILD) $(FDFEA) $(LATDEP)
@echo GEN $@
@export LATW=`$(PY) -c "a='$(FONTS)'; \
b='$(LATINWEIGHTS)'; \
print ''.join([y for x, y in zip(a.split(), b.split()) \
if x == '$(subst -FD,,$(notdir $(basename $@)' ])))"`; \
$(PY) $(BUILD) --arabic-file=$< --out-file=$@ \
--latin-file=$(LATDIR)/$(LATIN)-$$LATW.ttf --merge-type plain \
--digits-feature-file=$(FDFEA) $(SUPPRESS)
## Sample text typeset via this font
## WARNING: Font name and weights are encoded in the TeX file in RESDIR
$(DOCDIR)/sample.pdf: $(RESDIR)/sample.tex otf
@echo GEN $@
@-mkdir -p $(DOCDIR)
@xetex -output-directory=$(DOCDIR) --interaction=batchmode $< &> /dev/null
@-rm -f $(basename $@).log
## A table of all characters defined in the font
$(DOCDIR)/table.pdf: otf $(MAKETAB)
@echo GEN $@
@$(PY) $(MAKETAB) --font $(DISTDIR)/$(NAME).otf > $(DOCDIR)/table.tex $(SUPPRESS)
@xelatex -output-directory=$(DOCDIR) --interaction=batchmode $(DOCDIR)/table.tex &> /dev/null
@-rm -f $(basename $@).log $(basename $@).aux $(basename $@).tex
## Three flavors (ttf, woff, woff2) are created at once
$(WEBDIR)/%.ttf $(WEBDIR)/%.woff $(WEBDIR)/%.woff2: $(DISTDIR)/%.ttf $(MAKEWEB)
@echo " WEB $*"
@mkdir -p $(WEBDIR)
@$(PY) $(MAKEWEB) $< $(WEBDIR)
## Generate the EOT webfont via ttf2eot
$(WEBDIR)/%.eot: $(DISTDIR)/%.ttf $(MAKEWEB)
@echo " EOT $*"
@mkdir -p $(WEBDIR)
@ttf2eot $< > $@
## CSS file for webfonts
$(WEBDIR)/%.css: $(WTTF) $(MAKECSS)
@echo " GEN $@"
@mkdir -p $(WEBDIR)
@$(PY) $(MAKECSS) --css=$@ --fonts="$(WTTF)"
clean:
@-rm -fr $(DISTDIR) $(DOCDIR) $(WEBDIR)