unifont-6.3.20131217.tar.gz
[unifont.git] / font / ttfsrc / Makefile
1
2 SHELL = /bin/sh
3
4 BINDIR = ../../bin
5
6 FONTFORGE = fontforge
7
8 COPYRIGHT = "Copyright (C) 2013 Roman Czyborra, Paul Hardy, et al.  \
9 Licensed under the GNU General Public License; either version 2, or \
10 (at your option) a later version, with the GNU Font Embedding Exception."
11
12 VERSION = 6.3.20131217
13
14 #
15 # How to build unifont.ttf from GNU Unifont's unifont.hex
16 # -------------------------------------------------------
17 # Written by Luis Alejandro Gonzalez Miranda - http://www.lgm.cl/
18 #
19
20 #
21 # 2008 - Paul Hardy created this Makefile from Luis' original
22 # howto-build.sh and other bash scripts.  Those original scripts
23 # don't appear in this archive, but they can be retrieved from
24 # http://www.lgm.cl/.
25 #
26
27 # First of all, you need a Perl interpreter and FontForge.
28 #
29 # I don't remember all the steps, but I think it was as described by
30 # this script.
31
32 # This division is done only so the Simplify and RemoveOverlap
33 # operations don't use up too much memory, and because
34 # a .sfd generated from the whole unifont.hex would be too big to
35 # process all at once.
36
37 all: hex2sfd merge sfd2ttf sbit
38
39 hex2sfd: unifont.hex $(BINDIR)/hex2sfd
40         echo "Separating unifont.hex into 16 parts"
41         for i in 0 1 2 3 4 5 6 7 8 9 A B C D E F ; \
42            do \
43            grep ^$$i unifont.hex > $$i.hex ; \
44            $(BINDIR)/hex2sfd < $$i.hex > $$i.sfd ; \
45         done
46         for i in 0 1 2 3 4 5 6 7 8 9 A B C D E F ; \
47            do \
48            $(FONTFORGE) -lang=ff -c \
49               'Open($$1); \
50                SelectAll(); \
51                RemoveOverlap(); \
52                Simplify(64,1); \
53                Save($$1);' \
54               $$i.sfd ; \
55            \rm -f $$i.hex ; \
56         done
57
58 # We join all the generated .sfd files into a single one,
59 # and generate the final TrueType font.
60
61 merge:
62         echo "Merging all .sfd files"
63         $(FONTFORGE) -script all.pe
64
65 sfd2ttf:
66         echo "Converting .sfd font into .ttf font"
67         $(FONTFORGE) -lang=ff -c \
68            'Open($$1); \
69             SetFontNames("UnifontMedium", "GNU", "Unifont", "Medium", $(COPYRIGHT), "$(VERSION)"); \
70             Generate($$2)' unifont.sfd unifont.ttf
71         \rm -f unifont.hex
72
73 #
74 # This fontforge script reads a BDF font file and generates an SBIT font file.
75 # Author: written by Qianqian Fang, given to Paul Hardy in 2008.
76 # The SBIT font is far smaller than the default outline TrueType font
77 # and takes far less time to build than the outline font.  However, it
78 # isn't scalable.  An SBIT font could be created and merged with the
79 # larger TTF font using fontforge, but I (Paul Hardy) haven't noticed
80 # any degradation in the screen rendering of just the outline TTF font
81 # that this Makefile produces as its final product.  This is with
82 # daily use of this Makefile's default TrueType font.
83 #
84 # This builds an SBIT font from the unifont_sample BDF font.  The
85 # BDF font already contains font name, etc., so they don't need to
86 # be set using SetFontNames; those parameters are left null so the
87 # existing font's values will be preserved.  However, Fontforge
88 # does not read the FONT_VERSION property so Paul Hardy added the
89 # the SetFontNames call.
90 #
91 sbit:
92         $(FONTFORGE) -lang=ff -c \
93            'New(); \
94             SetFontNames("","","","","","$(VERSION)"); \
95             Import($$1); \
96             Generate($$2, "ttf"); \
97             Close()' \
98            unifont_sample.bdf unifont_sample.ttf
99
100 clean:
101         \rm -f [0-9A-F].hex
102         \rm -f [0-9A-F].sfd
103         \rm -f *.bdf
104
105 distclean: clean
106         \rm -f unifont.bdf
107         \rm -f unifont.hex
108         \rm -f unifont.sfd
109         \rm -f unifont.ttf
110         \rm -f unifont-sbit.ttf
111
112 .PHONY: all hex2sfd merge sfd2ttf sbit clean distclean