e14e35f22926ddc78e216e063d24f3aa138b2cb0
[unifont.git] / font / ttfsrc / Makefile
1
2 SHELL = /bin/sh
3
4 BINDIR = ../../bin
5
6 FONTFORGE = fontforge
7
8 #
9 # Luis' original scripts were invoked with "-lang=ff" on the command
10 # line.  This was not supported by the version of FontForge in
11 # the current Debian stable release (Etch), so it was removed.
12 # However, the latest (as of July 2008) version of Debian (Sid)
13 # needed the language defined.  Setting FONTFORGE_LANGUAGE gets
14 # around this conflict between the old and new FontForge command
15 # line options -- thanks to Anthony Fok for this solution.
16 #
17 export FONTFORGE_LANGUAGE = ff
18
19 #
20 # How to build unifont.ttf from GNU Unifont's unifont.hex
21 # -------------------------------------------------------
22 # Written by Luis Alejandro Gonzalez Miranda - http://www.lgm.cl/
23 #
24
25 #
26 # 2008 - Paul Hardy created this Makefile from Luis' original
27 # howto-build.sh and other bash scripts.  Those original scripts
28 # don't appear in this archive, but they can be retrieved from
29 # http://www.lgm.cl/.
30 #
31
32 # First of all, you need a Perl interpreter and FontForge.
33 #
34 # I don't remember all the steps, but I think it was as described by
35 # this script.
36
37 # This division is done only so the Simplify and RemoveOverlap
38 # operations don't use up too much memory, and because
39 # a .sfd generated from the whole unifont.hex would be too big to
40 # process all at once.
41
42 all: hex2sfd merge sfd2ttf
43
44 hex2sfd: unifont.hex $(BINDIR)/hex2sfd
45         echo "Separating unifont.hex into 16 parts"
46         for i in 0 1 2 3 4 5 6 7 8 9 A B C D E F ; \
47            do \
48            grep ^$$i unifont.hex > $$i.hex ; \
49            $(BINDIR)/hex2sfd < $$i.hex > $$i.sfd ; \
50         done
51         for i in 0 1 2 3 4 5 6 7 8 9 A B C D E F ; \
52            do \
53            $(FONTFORGE) -c 'Open($$1); SelectAll(); RemoveOverlap(); Simplify(-1,1); Save($$1);' $$i.sfd ; \
54            \rm -f $$i.hex ; \
55         done
56
57 # We join all the generated .sfd files on a single one,
58 # and generate the final TrueType font
59
60 merge:
61         echo "Merging all .sfd files"
62         $(FONTFORGE) -script all.pe
63
64 sfd2ttf:
65         echo "Converting .sfd font into .ttf font"
66         $(FONTFORGE) -c 'Open($$1); Generate($$2)' unifont.sfd unifont.ttf
67         \rm -f unifont.hex
68
69 #
70 # This fontforge script reads a BDF font file and generates an SBIT font file.
71 # Author: written by Qianqian Fang, given to Paul Hardy in 2008.
72 # Right now nothing calls this; it is just here for experimentation.
73 # The SBIT font is far smaller than the default outline TrueType font
74 # and takes far less time to build than the outline font.  However, it
75 # isn't scalable.  An SBIT font could be created and merged with the
76 # larger TTF font using fontforge, but I (Paul Hardy) haven't noticed
77 # any degradation in the screen rendering of just the outline TTF font
78 # that this Makefile produces as its final product.  This is with
79 # daily use of this Makefile's default TrueType font.  Note that there
80 # is no file in this directory called "unifont.bdf" -- copy a BDF font
81 # here from ../compiled and name it "unifont.bdf".
82 #
83 sbit:
84         $(FONTFORGE) -c 'New(); Import($$1); Generate($$2, "ttf"); Close()' \
85                 unifont.bdf unifont-sbit.ttf
86
87 clean:
88         \rm -f [0-9A-F].hex
89         \rm -f [0-9A-F].sfd
90
91 distclean: clean
92         \rm -f unifont.bdf
93         \rm -f unifont.hex
94         \rm -f unifont.sfd
95         \rm -f unifont.ttf
96         \rm -f unifont-sbit.ttf
97
98 .PHONY: all hex2sfd merge sfd2ttf sbit clean distclean