unifont-6.3.20140204.tar.gz
[unifont.git] / font / ttfsrc / Makefile
1
2 SHELL = /bin/sh
3
4 BINDIR = ../../bin
5
6 FONTFORGE = fontforge
7
8 #
9 # Default values, if not set on the command line when make is invoked:
10 #
11 # FONTFILE:  Prefix of the file name for input and output files.
12 # FONTNAME:  Name of the font inside a TTF file.
13 # PSNAME:    PostScript name of the font inside a TTF file; can't have spaces.
14 # COMBINING: Prefix of the file containing a list of combining characters.
15 #
16 FONTFILE="unifont"
17 FONTNAME="Unifont"
18 PSNAME="Unifont"
19 COMBINING="combining"
20
21 #
22 # The PostScript name of a font can't contain spaces--remove them.
23 # Could also use bash string replacement if you know you're using bash.
24 #
25
26 COPYRIGHT = "Copyright (C) 2014 Roman Czyborra, Paul Hardy, Qianqian Fang, \
27 Andrew Miller, et al.  \
28 Licensed under the GNU General Public License; either version 2, or \
29 (at your option) a later version, with the GNU Font Embedding Exception."
30
31 VERSION = 6.3.20140204
32
33 #
34 # How to build unifont.ttf from GNU Unifont's unifont.hex
35 # -------------------------------------------------------
36 # Written by Luis Alejandro Gonzalez Miranda - http://www.lgm.cl/
37 #
38
39 #
40 # 2008 - Paul Hardy created this Makefile from Luis' original
41 # howto-build.sh and other bash scripts.  Those original scripts
42 # don't appear in this archive, but they can be retrieved from
43 # http://www.lgm.cl/.
44 #
45
46 # First of all, you need a Perl interpreter and FontForge.
47 #
48 # I don't remember all the steps, but I think it was as described by
49 # this script.
50
51 # This division is done only so the Simplify and RemoveOverlap
52 # operations don't use up too much memory, and because
53 # a .sfd generated from the whole unifont.hex would be too big to
54 # process all at once.
55
56 all: outline
57
58 #
59 # Commented out this operation on SFD file because not all applications
60 # correctly interpreted the settings:
61 #
62 #           SetFontNames("UnifontMedium", "GNU", "Unifont", "Medium", $(COPYRIGHT), "$(VERSION)"); \
63 #
64 # Convert unifont.hex to unifont.sfd as a single file, then generate
65 # an outline TrueType font.
66 #
67 outline: $(FONTFILE).hex $(BINDIR)/hex2sfd
68         echo "Converting font as a single file."
69         $(BINDIR)/hex2sfd $(COMBINING).txt < $(FONTFILE).hex > $(FONTFILE).sfd
70         $(FONTFORGE) -lang=ff -c \
71            'Open($$1); \
72             SetFontNames("$(PSNAME)Medium", \
73                 "$(FONTNAME)", "$(FONTNAME)", "Medium", \
74                 $(COPYRIGHT), "$(VERSION)"); \
75             SelectAll(); \
76             RemoveOverlap(); \
77             Simplify(64,1); \
78             Save($$1);' \
79            $(FONTFILE).sfd
80         echo "Converting .sfd font into .ttf font"
81         $(FONTFORGE) -lang=ff -c \
82            'Open($$1); \
83             Generate($$2)' $(FONTFILE).sfd $(FONTFILE).ttf
84         \rm -f $(FONTFILE).hex $(COMBINING).txt
85
86 #
87 # This fontforge script reads a BDF font file and generates an SBIT font file.
88 # Author: written by Qianqian Fang, given to Paul Hardy in 2008.
89 # The SBIT font is far smaller than the default outline TrueType font
90 # and takes far less time to build than the outline font.  However, it
91 # isn't scalable.  An SBIT font could be created and merged with the
92 # larger TTF font using fontforge, but I (Paul Hardy) haven't noticed
93 # any degradation in the screen rendering of just the outline TTF font
94 # that this Makefile produces as its final product.  This is with
95 # daily use of this Makefile's default TrueType font.
96 #
97 # This builds an SBIT font from the unifont_sample BDF font.  The
98 # BDF font already contains font name, etc., so they don't need to
99 # be set using SetFontNames; those parameters are left null so the
100 # existing font's values will be preserved.  However, Fontforge
101 # does not read the FONT_VERSION property so Paul Hardy added the
102 # the SetFontNames call.
103 #
104 # Commented out because not all applications correctly interpreted
105 # the settings:
106 #
107 #           SetFontNames("","","","","","$(VERSION)"); \
108
109 sbit: $(FONTFILE).bdf
110         $(FONTFORGE) -lang=ff -c \
111            'New(); \
112             Import($$1); \
113             SetFontNames("","","","","","$(VERSION)"); \
114             Generate($$2, "ttf"); \
115             Close()' \
116            $(FONTFILE).bdf $(FONTFILE).ttf
117         \rm -f $(FONTFILE).bdf
118
119 #
120 # Delete files copied into this directory to build TTF fonts.
121 #
122 clean:
123         \rm -f *.bdf *.hex *.txt
124
125 #
126 # Delete files created within this directory while building TTF fonts.
127 #
128 distclean: clean
129         \rm -f *.sfd *.ttf
130
131 .PHONY: all outline sbit clean distclean