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 supported categories are cid, cmap, truetype and type1.
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 beginning 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 ends with the end line. The begin line also specifies which font is 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 /path/to/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 /path/to/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 /path/to/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 the 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.
Some Type1 fonts contain multiple charsets in a single pfa/pfb file, and TrueType Collection fonts (.ttc) contain multiple faces in a single ttc file. It means individual hints are needed for each face/charset. To realize this, defoma provides subhints mechanism.
This is an example of a hintfile for a type1 font with multiple encoding. The font a.pfa (Helvetica) is usually accessed in ISO8859-1 encoding, but by re-encoding the font, it can also be accessed in ISO8859-2 and KOI8-R encodings.
category type1 begin /font/a.pfa FaceNum = 3 Inherit = Weight Shape Width Priorty Family GeneralFamily FontName = Helvetica Charset = ISO8859-1 Weight = Medium Shape = Upright NoSerif Family = Helvetica GeneralFamily = SansSerif Priority = 20 X-FontName = -foo-bar-medium-r-normal--0-0-0-0-p-0-iso8859-1 FontName1 = Helvetica-ISO8859-2 Charset1 = ISO8859-2 X-FontName1 = -foo-bar-medium-r-normal--0-0-0-0-p-0-iso8859-2 FontName2 = Helvetica-KOI8-R Charset2 = KOI8-R X-FontName2 = -foo-bar-medium-r-normal--0-0-0-0-p-0-koi8-r end
You will find out unfamiliar hinttype FaceNum and Inherit, and numbered hinttypes.
Non-numbered hints contain hints for the default charset ISO8859-1 in the same way as usual Type1 fonts. Hints can be inherited to subhints, and Inherit hinttype decides which hinttypes to be inherited, so hints that are common to most of the subhints like Family, Weight and Shape, you should set the hinttype Inherit.
FaceNum hinttype specifies how many subhints the hints contain. In this example, there are two subhints plus default hints, so its value is set to 3.
Numbered hints are called subhints, which consist of charset specific hints. In this example, subhints only contains FontName, Charset and X-FontName. Other important hinttypes are inherited from Non-numbered hints.
Here's another example for a Unicode Type1 font, which is usually accessed in Unicode encoding, and by re-encoding the font, it can also be accessed in ISO8859-1, ISO8859-2 and ISO8859-3.
category type1 begin /font/b.pfa FaceNum = 4 Inherit = Weight Shape Width Proirty Family GeneralFamily FontName = Helvetica-Unicode Charset = ISO10646-1 UniCharset = ISO8859-1 ISO8859-2 ISO8859-3 Weight = Medium Shape = Upright NoSerif Family = Helvetica GeneralFamily = SansSerif Priority = 20 X-FontName = -foo-bar-medium-r-normal--0-0-0-0-p-0-iso10646-1 FontName1 = Helvetica-ISO8859-1 Charset1 = ISO8859-1 X-FontName1 = -foo-bar-medium-r-normal--0-0-0-0-p-0-iso8859-1 FontName2 = Helvetica-ISO8859-2 Charset2 = ISO8859-2 X-FontName1 = -foo-bar-medium-r-normal--0-0-0-0-p-0-iso8859-2 FontName1 = Helvetica-ISO8859-3 Charset1 = ISO8859-3 X-FontName1 = -foo-bar-medium-r-normal--0-0-0-0-p-0-iso8859-3 end
Note that the value of non-numbered Charset is ISO10646-1 and UniCharset represents what charsets the Unicode Type1 font actually consists of.
This is an example for Unicode TrueType fonts whose glyphs are correspondent to a collection of ISO8859-1, ISO8859-2 and ISO8859-3.
category truetype begin /font/c.ttf FontName = Verdy-Bold Charset = ISO8859-1 ISO8859-2 ISO8859-3 ISO10646-1 UniCharset = ISO8859-1 ISO8859-2 ISO8859-3 Encoding = Unicode Location = English Slovenian Turkish Weight = Bold Shape = NoSerif GeneralFamily = SansSerif Family = Verdy end
No subhint is needed to represent multiple charsets of TrueType fonts. Setting Charset to the available charsets will do.
Now let's build a Defoma-aware font package. To make things easier, using debhelper is strongly recommended. Following tutorial describes about a debhelper-based package.
Since defoma 0.7.0, it provides a debhelper program for defoma named dh_installdefoma. Using this program makes it much easier to defoma-ize a package.
mv fonts/hintfile debian/defoma-hints
(ex: debian/rules) binary-indep: build install dh_testdir dh_testroot dh_installdebconf dh_installdefoma dh_installdocs ...
(ex: debian/control) Build-Depends: defoma (>= 0.7.0) ... Depends: defoma ...
Although using dh_installdefoma is strongly recommended, sometimes you have to do what dh_installdefoma does manually. Following lists describes this ordinal way of defoma-izing.
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 reregister-all $FILE fi
(ex: debian/prerm) ... FILE='/etc/defoma/hints/<package-name>.hints' if [ "$1" = remove ]; then /usr/bin/defoma-font purge-all $FILE fi
(ex: debian/control) ... Depends: defoma ...