Font packages should register their fonts to Defoma if the font may be used by various applications. Registration and Unregistration should be performed at postinst and postrm respectively of a font package, so maintainers need to edit them. In addition, each font may have various information called hints which represents its appearance and other data used to achieve appropriate configuration for a specific application, so maintainers need to generate hints.
Hintfile describes several fonts and their hints in a single file. Generally registration and unregistration of fonts are performed through Hintfile, so creating one is the first step to Defoma-ize a font package.
First of all, enter a package's top directory. If the fonts of the package are located under subdirectory, please enter there, and run the following command.
defoma-hints <category> <font>... 2> hintfile
This command asks various questions for each font listed in <font> which must belong to the specified <category>, and will output Hintfile to hintfile. The hintfile will contain definitions for all the fonts.
If categories of the fonts are partly different, you must run the command and create a hintfile for each category. In other words, category of the fonts described in a single hintfile must be unified.
Note that this command sometimes fails unfortunately because hints-generating routines are not provided for some categories. Currently cid, cmap, truetype and type1 categories are supported.
For example, if your font package is placed under ~/font-foo-0.1/, and the type1 fonts foo1.pfa, foo2.pfa and foo3.pfa are located at fonts/ subdirectory, please enter there and run the command like following.
cd ~/font-foo-0.1/fonts
defoma-hints type1 foo1.pfa foo2.pfa foo3.pfa > hintfile
After creating Hintfile, you may possibly want to edit one because mechanically created hints are sometimes not enough. This section describes how to modify a hintfile and its syntax.
Hintfile may contain three elements: category declaration, font definitions and comments. Font definitions and comments are permitted to appear in a single hintfile any number of times, while category declaration must not exist more than once.
Category declaration is generally put at the beggining of a hintfile because it must be put before font definitions. Its syntax is:
category <category-name>
Font definition describes one font and its hints. It starts with the begin line and end up with the end line. The begin line also specifies which font is going to be defined. Lines between these two lines describes hints of the font. Hintfile must not contain more than one font definition of a single font. The syntax of font definition is:
begin <font>
<HintTypeA> = <hintA1>
<HintTypeB> = <hintB1> <hintB2>
...
end
Lines starting with `#' are considered as comments.
Following is the generated hintfile of the mentioned example.
category type1
begin foo1.pfa
FontName = Foo-Regular
Family = Foo
Weight = Medium
Shape = Upright NoSerif
GeneralFamily = SansSerif
Charset = ISO8859-1
Alias = Foo
Priority = 30
X-FontName = -adobe-foo-medium-r-normal--0-0-0-0-p-0-iso8859-1
end
begin foo2.pfa
FontName = Foo-Bold
Family = Foo
Weight = Bold
Shape = Upright NoSerif
GeneralFamily = SansSerif
Charset = ISO8859-1
Alias = FooBold
Priority = 30
X-FontName = -adobe-foo-bold-r-normal--0-0-0-0-p-0-iso8859-1
end
begin foo3.pfa
FontName = Foo-Italic
Family = Foo
Weight = Medium
Shape = Italic NoSerif
GeneralFamily = SansSerif
Charset = ISO8859-1
Alias = FooItalic
Priority = 30
X-FontName = -adobe-foo-medium-i-normal--0-0-0-0-p-0-iso8859-1
end
The first thing you have to do is to change filenames of fonts to the full paths where these fonts are actually installed. Let's asuume that the font-foo.deb installs these fonts into /usr/share/fonts/type1, then the hintfile goes like this:
category type1
begin /usr/share/fonts/type1/foo1.pfa
..
begin /usr/share/fonts/type1/foo2.pfa
..
begin /usr/share/fonts/type1/foo3.pfa
After this necessary work done, you may want to change or add some hints. The Syntax of describing hints is:
<HintType> = <hint>...
where <HintType> decides what type of information is described, and <hint> is a value of the <HintType>. You can specify more than one <hint> for one <HintType> by separating them with space.
Hints include information about the appearance. This information should be correctly set to have better results of substituion by Defoma font substitution mechanism. HintTypes for appearance and their description are listed below.
In addition, essential information is also included in hints. As the word `essential' tells, this information is required for most categories. The values for some of the essential HintTypes are predefined. Following is a list of essential information.
Charset .. represents standards of collections of characters which the font contains. The values for this HintType is predefined and is listed below.
Finally, additional information is also included in hints.
NOTE: x-ttcidfont-conf manages configuration of TrueType and CID fonts for X through Defoma framework, so font packages for these fonts do not or should not install the font to X separately. Instead, just register fonts to Defoma.
Now let's build a Defoma-aware font pacakge. To make things easier, using debhelper is strongly recommended. Following tutorial describes about a debhelper-based package.
mv fonts/hintfile debian/
(ex: debian/rules)
PKG = <package-name>
DIR = `pwd`/debian/$(PKG)
install: build
...
install -m 644 debian/hintfile \
$(DIR)/etc/defoma/hints/$(PKG).hints
(ex: debian/dirs)
etc/defoma/hints
(ex: debian/conffiles)
/etc/defoma/hints/<package-name>.hints
(ex: debian/postinst)
...
FILE='/etc/defoma/hints/<package-name>.hints'
if [ "$1" = configure ]; then
/usr/bin/defoma-font -t reregister-all $FILE
fi
(ex: debian/prerm)
...
FILE='/etc/defoma/hints/<package-name>.hints'
if [ "$1" = remove ]; then
/usr/bin/defoma-font -t purge-all $FILE
fi
(ex: debian/control)
...
Depends: defoma
...