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