-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·184 lines (159 loc) · 6.16 KB
/
configure
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
#!/usr/bin/env python3
import csv
BASE_MAKEFILE = """
.SECONDARY:
"""
BASE_RULES = """
SMALL_GLYPHS=$(PLACEHOLDERS_SMALL) $(SCALED_SMALL) $(TRACE_SMALL)
LARGE_GLPYHS=$(PLACEHOLDERS_LARGE) $(SCALED_LARGE) $(TRACE_LARGE)
default: outp/thermal-sans-mono-17/thermal-sans-mono-17.png \\
outp/thermal-sans-mono-24/thermal-sans-mono-24.png \\
outp/thermal-sans-mono-17/thermal-sans-mono-17.pcf \\
outp/thermal-sans-mono-24/thermal-sans-mono-24.pcf
# Generate montages of glyphs
outp/thermal-sans-mono-17/thermal-sans-mono-17.png: $(SMALL_GLYPHS)
mkdir -p $(@D)
mkdir -p build/montage/17px
@echo $^ > build/montage/17px/inputs-unsorted.txt
php ./utils/montage/montage-sort.php \
build/montage/17px/inputs-unsorted.txt \
build/montage/17px/montage-command-list.txt 18x17+0+0
parallel < build/montage/17px/montage-command-list.txt
convert build/montage/17px/**.pbm -append $@
outp/thermal-sans-mono-24/thermal-sans-mono-24.png: $(LARGE_GLPYHS)
mkdir -p $(@D)
mkdir -p build/montage/24px
@echo $^ > build/montage/24px/inputs-unsorted.txt
php ./utils/montage/montage-sort.php \
build/montage/24px/inputs-unsorted.txt \
build/montage/24px/montage-command-list.txt 24x24+0+0
parallel < build/montage/24px/montage-command-list.txt
convert build/montage/24px/**.pbm -append $@
outp/thermal-sans-mono-24/thermal-sans-mono-24.bdf: $(LARGE_GLPYHS)
mkdir -p $(@D)
mkdir -p build/bdf/24px
@echo $^ > build/bdf/24px/inputs-unsorted.txt
php ./utils/pbm2bdf/pbm2bdf.php \
build/bdf/24px/inputs-unsorted.txt 24 $@
outp/thermal-sans-mono-17/thermal-sans-mono-17.bdf: $(SMALL_GLYPHS)
mkdir -p $(@D)
mkdir -p build/bdf/17px
@echo $^ > build/bdf/17px/inputs-unsorted.txt
php ./utils/pbm2bdf/pbm2bdf.php \
build/bdf/17px/inputs-unsorted.txt 17 $@
# Wrap scaling program
build/trace/24px/%.bold.pbm: build/scale/16px/%.pbm definitions/thermalsans24.csv
mkdir -p $(@D)
if [ "$$(identify -format '%w' $<)" -eq "8" ]; then \
php ./utils/fontscale-wrapper/fontscale-wrapper.php $(basename $(@F)) $@ $^ $(UNIFONT_PATH) 12x24 20; \
else \
php ./utils/fontscale-wrapper/fontscale-wrapper.php $(basename $(@F)) $@ $^ $(UNIFONT_PATH) 24x24 20; \
fi
build/trace/17px/%.bold.pbm: build/scale/16px/%.pbm definitions/thermalsans17.csv
mkdir -p $(@D)
if [ "$$(identify -format '%w' $<)" -eq "8" ]; then \
php ./utils/fontscale-wrapper/fontscale-wrapper.php $(basename $(@F)) $@ $^ $(UNIFONT_PATH) 9x17 20; \
else \
php ./utils/fontscale-wrapper/fontscale-wrapper.php $(basename $(@F)) $@ $^ $(UNIFONT_PATH) 18x17 20; \
fi
# Generate raw scaled glyphs
build/scale/24px/%.pbm: build/scale/16px/%.pbm
mkdir -p $(@D)
if [ "$$(identify -format '%w' $<)" -eq "8" ]; then \
convert $< -resize 12x24 $@; \
else \
convert $< -resize 24x24 $@; \
fi
build/scale/17px/%.pbm: build/scale/16px/%.pbm
mkdir -p $(@D)
if [ "$$(identify -format '%w' $<)" -eq "8" ]; then \
convert $< -resize 9x17 $@; \
else \
convert $< -resize 18x17 $@; \
fi
# Actual Unifont extraction
build/scale/16px/%.pbm:
mkdir -p $(@D)
php ./utils/hex2pbm/hex2pbm.php $(UNIFONT_PATH) $(basename $(@F)) $@
# Generate placeholder glpyhs
build/placeholder/24px/%.pbm:
mkdir -p $(@D)
php ./utils/placeholder/placeholder.php $(basename $(@F)) large $@
build/placeholder/17px/%.pbm:
mkdir -p $(@D)
php ./utils/placeholder/placeholder.php $(basename $(@F)) small $@
# Conversion
%.pcf: %.bdf
bdftopcf -o $@ $<
#%.gz: %
# gzip $< > $@
clean:
rm -Rf build/ outp/
"""
placeholderSmallTargets = []
placeholderLargeTargets = []
scaleSmallTargets = []
scaleLargeTargets = []
traceSmallTargets = []
traceLargeTargets = []
def dirInfo(prefix, codePoint, suffix):
prefix.append(codePoint[0])
prefix.append(codePoint[1])
dirname = "/".join(prefix)
fn = codePoint + suffix
return {
'dirname': dirname,
'path': dirname + "/" + fn
}
def registerPlaceholder(height, codePoint, method, args):
path = dirInfo(["build", "placeholder", height + "px"], codePoint, ".pbm")
if(height == '17'):
placeholderSmallTargets.append(path['path'])
elif height == '24':
placeholderLargeTargets.append(path['path'])
def registerScale(height, codePoint, method, args):
path = dirInfo(["build", "scale", height + "px"], codePoint, ".pbm")
if(height == '17'):
scaleSmallTargets.append(path['path'])
elif height == '24':
scaleLargeTargets.append(path['path'])
def registerTrace(height, codePoint, method, args):
if(height == '17'):
# TODO allow use of bold or regular based on individual glyph.
path = dirInfo(["build", "trace", height + "px"], codePoint, ".bold.pbm")
traceSmallTargets.append(path['path'])
elif height == '24':
path = dirInfo(["build", "trace", height + "px"], codePoint, ".bold.pbm")
traceLargeTargets.append(path['path'])
def registerGlyph(height, codePoint, method, args):
if(method == "placeholder"):
registerPlaceholder(height, codePoint, method, args)
elif(method == "scale"):
registerScale(height, codePoint, method, args)
elif(method == "trace"):
registerTrace(height, codePoint, method, args)
else:
raise Exception("Unknown method '" + method + "' for codePoint " + codePoint + " at height " + height + "px")
print("Reading glyph definitions ..")
for height in ['17', '24']:
fn = 'definitions/thermalsans' + height + '.csv'
print(" " + fn)
with open(fn, newline='') as csvfile:
rdr = csv.DictReader(csvfile, delimiter=',', quotechar='\"')
for row in rdr:
registerGlyph(height, row['codePoint'], row['method'], {
'trace': row['traceArgs'],
'rasterSrc': row['rasterSrcArgs'],
'rasterDest': row['rasterDestArgs']
});
print("Outputting Makefile ..")
with open('Makefile', 'w') as makefile:
makefile.write(BASE_MAKEFILE)
makefile.write("UNIFONT_PATH=/usr/share/unifont/unifont.hex\n")
makefile.write("PLACEHOLDERS_SMALL=" + " ".join(placeholderSmallTargets) + "\n")
makefile.write("PLACEHOLDERS_LARGE=" + " ".join(placeholderLargeTargets) + "\n")
makefile.write("SCALED_SMALL=" + " ".join(scaleSmallTargets) + "\n")
makefile.write("SCALED_LARGE=" + " ".join(scaleLargeTargets) + "\n")
makefile.write("TRACE_SMALL=" + " ".join(traceSmallTargets) + "\n")
makefile.write("TRACE_LARGE=" + " ".join(traceLargeTargets) + "\n")
makefile.write(BASE_RULES)