FONTFORGE = fontforge
#
-# Luis' original scripts were invoked with "-lang=ff" on the command
-# line. This was not supported by the version of FontForge in
-# the current Debian stable release (Etch), so it was removed.
-# However, the latest (as of July 2008) version of Debian (Sid)
-# needed the language defined. Setting FONTFORGE_LANGUAGE gets
-# around this conflict between the old and new FontForge command
-# line options -- thanks to Anthony Fok for this solution.
+# Default values, if not set on the command line when make is invoked:
#
-export FONTFORGE_LANGUAGE = ff
+# FONTFILE: Prefix of the file name for input and output files.
+# FONTNAME: Name of the font inside a TTF file.
+# PSNAME: PostScript name of the font inside a TTF file; can't have spaces.
+# COMBINING: Prefix of the file containing a list of combining characters.
+#
+FONTFILE="unifont"
+FONTNAME="Unifont"
+PSNAME="Unifont"
+COMBINING="combining"
+
+#
+# The PostScript name of a font can't contain spaces--remove them.
+# Could also use bash string replacement if you know you're using bash.
+#
+
+COPYRIGHT = "Copyright (C) 2014 Roman Czyborra, Paul Hardy, Qianqian Fang, \
+Andrew Miller, et al. \
+Licensed under the GNU General Public License; either version 2, or \
+(at your option) a later version, with the GNU Font Embedding Exception."
+
+UNICODE_VERSION = 7.0
+PKG_REV = 02
+VERSION = $(UNICODE_VERSION).$(PKG_REV)
#
# How to build unifont.ttf from GNU Unifont's unifont.hex
# a .sfd generated from the whole unifont.hex would be too big to
# process all at once.
-all: hex2sfd merge sfd2ttf
-
-hex2sfd: unifont.hex $(BINDIR)/hex2sfd
- echo "Separating unifont.hex into 16 parts"
- for i in 0 1 2 3 4 5 6 7 8 9 A B C D E F ; \
- do \
- grep ^$$i unifont.hex > $$i.hex ; \
- $(BINDIR)/hex2sfd < $$i.hex > $$i.sfd ; \
- done
- for i in 0 1 2 3 4 5 6 7 8 9 A B C D E F ; \
- do \
- $(FONTFORGE) -c 'Open($$1); SelectAll(); RemoveOverlap(); Simplify(-1,1); Save($$1);' $$i.sfd ; \
- \rm -f $$i.hex ; \
- done
-
-# We join all the generated .sfd files on a single one,
-# and generate the final TrueType font
-
-merge:
- echo "Merging all .sfd files"
- $(FONTFORGE) -script all.pe
-
-sfd2ttf:
+all: outline
+
+#
+# Commented out this operation on SFD file because not all applications
+# correctly interpreted the settings:
+#
+# SetFontNames("UnifontMedium", "GNU", "Unifont", "Medium", $(COPYRIGHT), "$(VERSION)"); \
+#
+# Convert unifont.hex to unifont.sfd as a single file, then generate
+# an outline TrueType font.
+#
+outline: $(FONTFILE).hex $(BINDIR)/hex2sfd
+ echo "Converting font as a single file."
+ $(BINDIR)/hex2sfd $(COMBINING).txt < $(FONTFILE).hex > $(FONTFILE).sfd
+ $(FONTFORGE) -lang=ff -c \
+ 'Open($$1); \
+ SetFontNames("$(PSNAME)Medium", \
+ "$(FONTNAME)", "$(FONTNAME)", "Medium", \
+ $(COPYRIGHT), "$(VERSION)"); \
+ SelectAll(); \
+ RemoveOverlap(); \
+ Simplify(64,1); \
+ Save($$1);' \
+ $(FONTFILE).sfd
echo "Converting .sfd font into .ttf font"
- $(FONTFORGE) -c 'Open($$1); Generate($$2)' unifont.sfd unifont.ttf
- \rm -f unifont.hex
+ $(FONTFORGE) -lang=ff -c \
+ 'Open($$1); \
+ Generate($$2)' $(FONTFILE).sfd $(FONTFILE).ttf
+ \rm -f $(FONTFILE).hex $(COMBINING).txt
#
# This fontforge script reads a BDF font file and generates an SBIT font file.
# Author: written by Qianqian Fang, given to Paul Hardy in 2008.
-# Right now nothing calls this; it is just here for experimentation.
# The SBIT font is far smaller than the default outline TrueType font
# and takes far less time to build than the outline font. However, it
# isn't scalable. An SBIT font could be created and merged with the
# larger TTF font using fontforge, but I (Paul Hardy) haven't noticed
# any degradation in the screen rendering of just the outline TTF font
# that this Makefile produces as its final product. This is with
-# daily use of this Makefile's default TrueType font. Note that there
-# is no file in this directory called "unifont.bdf" -- copy a BDF font
-# here from ../compiled and name it "unifont.bdf".
+# daily use of this Makefile's default TrueType font.
+#
+# This builds an SBIT font from the unifont_sample BDF font. The
+# BDF font already contains font name, etc., so they don't need to
+# be set using SetFontNames; those parameters are left null so the
+# existing font's values will be preserved. However, Fontforge
+# does not read the FONT_VERSION property so Paul Hardy added the
+# the SetFontNames call.
+#
+# Commented out because not all applications correctly interpreted
+# the settings:
#
-sbit:
- $(FONTFORGE) -c 'New(); Import($$1); Generate($$2, "ttf"); Close()' \
- unifont.bdf unifont-sbit.ttf
+# SetFontNames("","","","","","$(VERSION)"); \
+
+sbit: $(FONTFILE).bdf
+ $(FONTFORGE) -lang=ff -c \
+ 'New(); \
+ Import($$1); \
+ SetFontNames("","","","","","$(VERSION)"); \
+ Generate($$2, "ttf"); \
+ Close()' \
+ $(FONTFILE).bdf $(FONTFILE).ttf
+ \rm -f $(FONTFILE).bdf
+#
+# Delete files copied into this directory to build TTF fonts.
+#
clean:
- \rm -f [0-9A-F].hex
- \rm -f [0-9A-F].sfd
+ \rm -f *.bdf *.hex *.txt
+#
+# Delete files created within this directory while building TTF fonts.
+#
distclean: clean
- \rm -f unifont.bdf
- \rm -f unifont.hex
- \rm -f unifont.sfd
- \rm -f unifont.ttf
- \rm -f unifont-sbit.ttf
+ \rm -f *.sfd *.ttf
-.PHONY: all hex2sfd merge sfd2ttf sbit clean distclean
+.PHONY: all outline sbit clean distclean