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