[ Abstract ] [ Copyright Notice ] [ Contents ] [ next ]

Developers' Documents of Defoma
Chapter 1 Font Package's TODO


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.


1.1 Creating Hintfile.

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


1.2 Editting 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.

Finally, additional information is also included in hints.


1.3 Packaging.

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.

  1. Put hintfile(s) into debian/ subdirectory.
         		  mv fonts/hintfile debian/
    
  2. Edit the debian/rules file to install the hintfile(s) into etc/defoma/hints/ directory as <package-name>.hints.
         		  (ex: debian/rules)
         		  PKG = <package-name>
         		  DIR = `pwd`/debian/$(PKG)
         		  install: build
         		          ...
         		          install -m 644 debian/hintfile \
         		            $(DIR)/etc/defoma/hints/$(PKG).hints
    
  3. To create the etc/defoma/hints directory before actually installing the hintfile there, edit debian/dirs.
         		  (ex: debian/dirs)
         		  etc/defoma/hints
    
  4. The hintfile must be conffile, so edit debian/conffiles.
         		  (ex: debian/conffiles)
         		  /etc/defoma/hints/<package-name>.hints
    
  5. Registration of fonts must be performed at postinst. Edit debian/postinst to call defoma-font with reregister-all command. NOTE that the command is not register-all. Using this command is able to not only just register fonts described in a hintfile, but also update revised hints to Defoma, so this command is used for both newly installing and upgrading purpose.
         		  (ex: debian/postinst)
         		  ...
         		  FILE='/etc/defoma/hints/<package-name>.hints'
         		  if [ "$1" = configure ]; then
         		    /usr/bin/defoma-font -t reregister-all $FILE
         		  fi
    
  6. Unregistration of fonts must be performed at prerm when the package is going to be removed. Edit debian/prerm to call defoma-font with purge-all command.
         		  (ex: debian/prerm)
         		  ...
         		  FILE='/etc/defoma/hints/<package-name>.hints'
         		  if [ "$1" = remove ]; then
         		    /usr/bin/defoma-font -t purge-all $FILE
         		  fi
    
  7. Edit debian/control to make the package depend on defoma.
         		  (ex: debian/control)
         		  ...
         		  Depends: defoma
         		  ...
    


[ Abstract ] [ Copyright Notice ] [ Contents ] [ next ]
Developers' Documents of Defoma
Yasuhiro take (take@debian.org)