unifont-6.3.20131217.tar.gz
[unifont.git] / font / Makefile
1 #
2 # Makefile to build a version of GNU Unifont with the
3 # unifoundry.com GNU Unifont utilities.  This Makefile
4 # converts unifont-$(VERSION).hex and related files into a final
5 # GNU Unifont font file.
6 #
7 # This software is released under version 2.0 of the GNU Public License,
8 # or (at your option) a later version of the GPL.
9 #
10 # Paul Hardy, 7 July 2008
11 #
12 # commands will be interpreted with the Bourne Shell
13 #
14 SHELL = /bin/sh
15 INSTALL = install
16 FONTFORGE = fontforge
17 #
18 # assembly date of this version
19 #
20 MAJORVERSION = 6.3
21 DATE = 20131217
22 VERSION = $(MAJORVERSION).$(DATE)
23
24 COPYRIGHT = "Copyright (C) 2013 Roman Czyborra, Paul Hardy, et al.  \
25 Licensed under the GNU General Public License; either version 2, or \
26 (at your option) a later version, with the GNU Font Embedding Exception."
27
28 #
29 # Path to local unifont-bin utilities.  If your system doesn't
30 # use GNU's version of "make", use the first BINDIR definition.
31 # If using GNU's "make", use the second BINDIR definition.
32 #
33 # BINDIR = ../bin
34 BINDIR = $(CURDIR)/../bin
35 #
36 # The top-level directory for installing fonts on the system,
37 # and the installation directories for PCF and TrueType fonts.
38 #
39 FONTDEST = $(DESTDIR)/usr/share/fonts
40 PCFDEST = $(FONTDEST)/X11/misc
41 TTFDEST = $(FONTDEST)/truetype/unifont
42 #
43 # destination directory for compiled fonts
44 #
45 COMPILED_DIR = compiled
46 #
47 # destination directory for .bmp representation of font
48 #
49 BMPDIR = $(COMPILED_DIR)/bmp
50 #
51 # Directory with original unifont-$(VERSION).hex files
52 #
53 HEXDIR = hexsrc
54 #
55 # These are the files for building GNU Unifont with the Qianqian Fang's
56 # Wen Quan Yi CJK ideographs.  This version provides complete coverage
57 # of the Unicode Basic Multilingual Plane.
58 #
59 # If you want don't want to inlcude blank glyphs in unassigned code points,
60 # uncomment the UNASSIGNED definition or override from the make command line.
61 #
62 # Likewise, uncomment the PUA definiation if you want to use Private
63 # Use Area glyphs.
64 #
65 UNASSIGNED = $(HEXDIR)/unassigned.hex
66 # UNASSIGNED =
67
68 #
69 # Non-printing glyphs.  There are only about 100 of these, and many end
70 # users do want to print representations of these glyphs, so they are
71 # included as an optional assignment.
72 #
73 NONPRINTING = $(HEXDIR)/nonprinting.hex
74 # NONPRINTING =
75
76 #
77 # Private Use Area glyphs.  Uncomment to include four-digit hexadecimal glyphs
78 # or override from the make command line.
79 #
80 # PUA = $(HEXDIR)/pua.hex
81 PUA = 
82
83 # The remaining .hex files will be constant unless a customized font
84 # is being built.
85 UNIFONTBASE = $(HEXDIR)/unifont-base.hex
86 CJK         = $(HEXDIR)/wqy.hex
87 HANGUL      = $(HEXDIR)/hangul-syllables.hex
88 SPACES      = $(HEXDIR)/spaces.hex
89
90 UNIFILES = $(UNIFONTBASE) $(CJK) $(HANGUL) $(SPACES) $(UNASSIGNED) \
91            $(NONPRINTING) $(PUA)
92
93 #
94 # Location of the file containing a list of Unicode combining characters.
95 #
96 COMBINING = ttfsrc/combining.txt
97
98 VPATH = hexsrc ttfsrc
99
100 #
101 # Location of  TTF source directory, where TTF font is built.
102 #
103 TTFSRC = ttfsrc
104
105
106 all: compiled
107
108 compiled: $(UNIFILES) $(COMBINING)
109         make compiled-files
110
111 compiled-files: pcf bmp ttf bigpic coverage
112         install -p index.html $(COMPILED_DIR)/index.html
113
114 #
115 # Build the aggregate .hex font files
116 #
117 hex: distclean
118         if [ ! -d $(COMPILED_DIR) ] ; then \
119            mkdir -p $(COMPILED_DIR) ; \
120         fi
121         sort $(UNIFILES) >$(COMPILED_DIR)/unifont-$(VERSION).hex
122         (cd $(HEXDIR) ; sort *.hex) | \
123            $(BINDIR)/unigencircles ttfsrc/combining.txt hexsrc/nonprinting.hex \
124            > $(COMPILED_DIR)/unifont_sample-$(VERSION).hex
125
126 #
127 # Build a BDF font file from the final .hex file.
128 #
129 bdf: hex
130         # First make the default BDF font.  The font name will be "unifont".
131         $(BINDIR)/hex2bdf --version "$(VERSION)" --copyright $(COPYRIGHT) \
132            $(COMPILED_DIR)/unifont-$(VERSION).hex \
133            >$(COMPILED_DIR)/unifont-$(VERSION).bdf
134         gzip -f -9 <$(COMPILED_DIR)/unifont-$(VERSION).bdf \
135                    >$(COMPILED_DIR)/unifont-$(VERSION).bdf.gz
136         # Now make a version with combining circles.  The font name
137         # will be "unifont_sample" instead of "unifont" to distinguish
138         # it from the default font.
139         $(BINDIR)/hex2bdf --font "Unifont Sample" \
140            --version "$(VERSION)" --copyright $(COPYRIGHT) \
141              $(COMPILED_DIR)/unifont_sample-$(VERSION).hex \
142            > $(COMPILED_DIR)/unifont_sample-$(VERSION).bdf
143         gzip -f -9 <$(COMPILED_DIR)/unifont_sample-$(VERSION).bdf \
144                    >$(COMPILED_DIR)/unifont_sample-$(VERSION).bdf.gz
145
146 #
147 # Build a PCF font file from the final .hex file.
148 #
149 pcf: bdf
150         bdftopcf <$(COMPILED_DIR)/unifont-$(VERSION).bdf \
151                  >$(COMPILED_DIR)/unifont-$(VERSION).pcf
152         gzip -f -9 $(COMPILED_DIR)/unifont-$(VERSION).pcf
153         bdftopcf <$(COMPILED_DIR)/unifont_sample-$(VERSION).bdf \
154                  >$(COMPILED_DIR)/unifont_sample-$(VERSION).pcf
155         gzip -f -9 $(COMPILED_DIR)/unifont_sample-$(VERSION).pcf
156
157 #
158 # Print coverage of scripts in Basic Multilingual Plane in .txt file.
159 #
160 # Note: can't use this older version unless unassigned.hex is merged
161 # with the rest of the built unifont-$(VERSION).hex final file.
162 #
163 # coverage: $(COMPILED_DIR)/unifont-$(VERSION).hex $(BINDIR)/unicoverage
164 #       $(BINDIR)/unicoverage < $(COMPILED_DIR)/unifont-$(VERSION).hex \
165 #                   > $(COMPILED_DIR)/coverage.txt
166 #
167 # Use this version because "unassigned.hex" isn't part of the final
168 # .hex font by default now:
169 #
170 coverage:
171         sort $(HEXDIR)/*.hex | \
172                 $(BINDIR)/unicoverage > $(COMPILED_DIR)/coverage.txt
173
174 #
175 # Print HTML page coverage in Basic Multilingual Plane in .txt file.
176 #
177 pagecount: $(COMPILED_DIR)/unifont-$(VERSION).hex $(BINDIR)/unipagecount
178         $(BINDIR)/unipagecount -l < $(COMPILED_DIR)/unifont-$(VERSION).hex \
179                         > $(COMPILED_DIR)/pagecount.html
180
181 #
182 # Create the .bmp (Windows Bitmap) graphics versions of the glyphs.
183 #
184 bmp: hex $(BINDIR)/unihex2bmp
185         if [ ! -d $(BMPDIR) ] ; then \
186            mkdir -p $(BMPDIR) ; \
187         fi
188         for i in 0 1 2 3 4 5 6 7 8 9 A B C D E F; do \
189            for j in 0 1 2 3 4 5 6 7 8 9 A B C D E F; do \
190               $(BINDIR)/unihex2bmp -p$$i$$j \
191                  -i$(COMPILED_DIR)/unifont_sample-$(VERSION).hex \
192                  -o$(BMPDIR)/uni$$i$$j.bmp ; \
193            done ; \
194         done ; \
195         echo "Done creating $(BMPDIR)"
196
197 #
198 # Build one bitmap of the entire Unifont as a 4096 x 16 grid.
199 #
200 bigpic: $(COMPILED_DIR)/unifont_sample-$(VERSION).hex
201         cat $(COMPILED_DIR)/unifont_sample-$(VERSION).hex | \
202            $(BINDIR)/unifontpic -d120 > $(COMPILED_DIR)/unifont-$(VERSION).bmp
203
204 #
205 # Note that $(TTFSRC) must exist, because it contains some source files
206 # Perform a "make && make clean" because ALL of the files would consume
207 # over 200 Megabytes if left around.  The .sfd file is about 100 Megabytes,
208 # and it is created from merging "[0-F].sfd", which take up another 100 MB.
209 #
210
211 ttf:
212         # First copy the ordinary version, to make a TrueType font.
213         install -p \
214                 $(COMPILED_DIR)/unifont-$(VERSION).hex \
215                 $(TTFSRC)/unifont.hex
216         # Second copy unifont_sample.bdf, to make an SBIT font.
217         install -p \
218                 $(COMPILED_DIR)/unifont_sample-$(VERSION).bdf \
219                 $(TTFSRC)/unifont_sample.bdf
220         cd $(TTFSRC) ; make && make clean
221         mv $(TTFSRC)/unifont.sfd $(COMPILED_DIR)/unifont-$(VERSION).sfd 
222         mv $(TTFSRC)/unifont.ttf \
223                 $(COMPILED_DIR)/unifont-$(VERSION).ttf 
224         mv $(TTFSRC)/unifont_sample.ttf \
225                 $(COMPILED_DIR)/unifont_sample-$(VERSION).ttf 
226         gzip -f -9 $(COMPILED_DIR)/unifont-$(VERSION).sfd 
227
228 #
229 # Copy the newly created files from $(COMPILED_DIR) to the precompiled/
230 # directory.  This has to be called manually, because the precompiled/
231 # directory usually remains untouched.
232 #
233 precompiled: all
234         \rm -rf precompiled
235         install -m0755 -d precompiled
236         install -m0644 -p $(COMPILED_DIR)/unifont-$(VERSION).hex \
237                           $(COMPILED_DIR)/unifont-$(VERSION).bdf.gz \
238                           $(COMPILED_DIR)/unifont-$(VERSION).pcf.gz \
239                           $(COMPILED_DIR)/unifont-$(VERSION).ttf \
240                           $(COMPILED_DIR)/unifont_sample-$(VERSION).hex \
241                           $(COMPILED_DIR)/unifont_sample-$(VERSION).bdf.gz \
242                           $(COMPILED_DIR)/unifont_sample-$(VERSION).pcf.gz \
243                           $(COMPILED_DIR)/unifont_sample-$(VERSION).ttf \
244                           $(COMPILED_DIR)/coverage.txt \
245                           $(COMPILED_DIR)/unifont-$(VERSION).bmp \
246            precompiled
247
248 #
249 # This is set up for Debian.  Solaris places fonts in
250 # "/usr/share/fonts/TrueType".  Other unices use other directories.
251 # The original font format was BDF, but Debian doesn't use that and
252 # xfs should only need TrueType, so the BDF font isn't installed.
253 #
254 # The TrueType font is about 16 Megabytes.  To avoid duplication,
255 # the fonts are installed as symbolic links back to the original package.
256 # Alternatively, the fonts can be copied to the destination directory
257 # with "install -m0644" or moved there (but "mv" is a destructive
258 # one-time operation).
259 #
260 # After installing the new fonts, register them with X Window System using:
261 #
262 #      xset fp rehash
263 #
264 install:
265         if [ x$(CURDIR) = x ] ; \
266         then \
267            echo "Fatal Error: CURDIR not defined -- define in Makefile." ; \
268            exit 1 ; \
269         fi
270         $(INSTALL) -m0755 -d $(PCFDEST)
271         $(INSTALL) -m0755 -d $(TTFDEST)
272         if [ ! -d $(COMPILED_DIR) ] ; then \
273            $(INSTALL) -m0644 -p $(CURDIR)/precompiled/unifont-$(VERSION).pcf.gz $(PCFDEST)/unifont.pcf.gz ; \
274            $(INSTALL) -m0644 -p $(CURDIR)/precompiled/unifont_sample-$(VERSION).pcf.gz $(PCFDEST)/unifont_sample.pcf.gz ; \
275            $(INSTALL) -m0644 -p $(CURDIR)/precompiled/unifont-$(VERSION).ttf    $(TTFDEST)/unifont.ttf ; \
276            $(INSTALL) -m0644 -p $(CURDIR)/precompiled/unifont_sample-$(VERSION).ttf    $(TTFDEST)/unifont_sample.ttf ; \
277         else \
278            $(INSTALL) -m0644 -p $(CURDIR)/$(COMPILED_DIR)/unifont-$(VERSION).pcf.gz $(PCFDEST)/unifont.pcf.gz ; \
279            $(INSTALL) -m0644 -p $(CURDIR)/$(COMPILED_DIR)/unifont_sample-$(VERSION).pcf.gz $(PCFDEST)/unifont_sample.pcf.gz ; \
280            $(INSTALL) -m0644 -p $(CURDIR)/$(COMPILED_DIR)/unifont-$(VERSION).ttf    $(TTFDEST)/unifont.ttf ; \
281            $(INSTALL) -m0644 -p $(CURDIR)/$(COMPILED_DIR)/unifont_sample-$(VERSION).ttf    $(TTFDEST)/unifont_sample.ttf ; \
282         fi
283
284 clean:
285         \rm -rf $(COMPILED_DIR)/bmp
286         \rm -f $(COMPILED_DIR)/unifont-$(VERSION).hex
287         \rm -f $(COMPILED_DIR)/unifont-$(VERSION).bdf
288         \rm -f $(COMPILED_DIR)/unifont-$(VERSION).bdf.gz
289         \rm -f *~
290
291 #
292 # Note that distclean leaves precompiled/ alone.  This is intentional.
293 # The .DS files are created under Mac OS X.
294 #
295 distclean:
296         \rm -rf $(COMPILED_DIR)
297         $(MAKE) -C ttfsrc distclean
298         \rm -f *~
299         \rm -rf .DS* ._.DS*
300
301 .PHONY: all hex bdf pcf coverage pagecount bmp bigpic ttf precompiled install clean distclean