bdaf1565d96b19fe2139ac20c7731e95ade35d8c
[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.20131221
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 #
66 # Commented out because not all applications correctly interpreted
67 # the settings:
68 #
69 #           SetFontNames("UnifontMedium", "GNU", "Unifont", "Medium", $(COPYRIGHT), "$(VERSION)"); \
70 sfd2ttf:
71         echo "Converting .sfd font into .ttf font"
72         $(FONTFORGE) -lang=ff -c \
73            'Open($$1); \
74             Generate($$2)' unifont.sfd unifont.ttf
75         \rm -f unifont.hex
76
77 #
78 # This fontforge script reads a BDF font file and generates an SBIT font file.
79 # Author: written by Qianqian Fang, given to Paul Hardy in 2008.
80 # The SBIT font is far smaller than the default outline TrueType font
81 # and takes far less time to build than the outline font.  However, it
82 # isn't scalable.  An SBIT font could be created and merged with the
83 # larger TTF font using fontforge, but I (Paul Hardy) haven't noticed
84 # any degradation in the screen rendering of just the outline TTF font
85 # that this Makefile produces as its final product.  This is with
86 # daily use of this Makefile's default TrueType font.
87 #
88 # This builds an SBIT font from the unifont_sample BDF font.  The
89 # BDF font already contains font name, etc., so they don't need to
90 # be set using SetFontNames; those parameters are left null so the
91 # existing font's values will be preserved.  However, Fontforge
92 # does not read the FONT_VERSION property so Paul Hardy added the
93 # the SetFontNames call.
94 #
95 # Commented out because not all applications correctly interpreted
96 # the settings:
97 #
98 #           SetFontNames("","","","","","$(VERSION)"); \
99 sbit:
100         $(FONTFORGE) -lang=ff -c \
101            'New(); \
102             Import($$1); \
103             Generate($$2, "ttf"); \
104             Close()' \
105            unifont_sample.bdf unifont_sample.ttf
106
107 clean:
108         \rm -f [0-9A-F].hex
109         \rm -f [0-9A-F].sfd
110         \rm -f *.bdf
111
112 distclean: clean
113         \rm -f unifont.bdf
114         \rm -f unifont.hex
115         \rm -f unifont.sfd
116         \rm -f unifont.ttf
117         \rm -f unifont-sbit.ttf
118
119 .PHONY: all hex2sfd merge sfd2ttf sbit clean distclean