Defoma-configuration script is a perl script which is provided by each of Defoma-aware application packages. This script does configuration about fonts for its application. It is called whenever a font is installed or removed, and its package is installed and removed, so that it can update the configuration about fonts dynamically.
BTW, applications using fonts are divided into two groups: base-level applications that access fonts directly and provide logical fonts, and higher-level applications that access fonts via logical fonts provided by base-level applications. The examples of former applications are: X and ghostscript. which provide XLFD and PostScript fonts. VFlib can also be said as base-level application. The major latter applications are X applications that output a PostScript file. Defoma-configuration scripts of base-level applications can register their logical fonts to Defoma from the scripts, so that the scripts of higher-level applications can update configuration about logical fonts immediately.
The big problem of automatic configuration is name-space conflict. If two different fonts /usr/lib/fonts/foo.pfa and /usr/share/fonts/foo.pfb have the same name Foo, only one of the two should be actually installed and the other shouldn't be installed unless the installed one is removed. This complicated problem can be solved by using Defoma::Id module.
Defoma-configuration script must be written as a perl library. That is, the script must end up with '1;' line.
The script must declare what categories of fonts the script accepts in the first line. Use global array variable @ACCEPT_CATEGORIES.
Any codes and declarations must be packaged with its script name. If the name of the script is bar.defoma, you have to put
package bar;
before any perl code except @ACCEPT_CATEGORIES. If the name of the script contains characters other than alphabets, numbers and underscore, replace them with underscore.
Functions for each acceptable category must exist. The name of the function must be the same as the name of the acceptable category, except that replacing non-alphabetic non-numeric non-underscore characters with underscore. These functions will be called from defoma and Defoma::Id module, so they are sort of interface between Defoma and the script.
Here is an example of a package named 'foo-bar' which has a Defoma-configuration script, which configures about fonts in type1 and x-postscript categories.
# Declare acceptable categories. @ACCEPT_CATEGORIES = ('type1', 'x-postscript'); # no code allowed here. package foo_bar; my $GlobalVariable1; my @GlobalVariable2; ... # function for type1 category. sub type1 { ... } # function for x-postscript category. sub x_postscript { ... } # end up with 1; this is the requirement of perl library. 1;
Functions whose names are the same as acceptable categories are called with some arguments. Its first argument always represents command. Following is a list of commands and their descriptions.
In these commands the script must do installation of the font with the id.
In these commands the script must do removal of the font with the id.
Here describes an example of a function type1.
sub type1 { my $com = shift; if ($com eq 'register') { return type1_register(@_); } elsif ($com eq 'unregister') { return type1_unregister(@_); } elsif ($com eq 'init') { return type1_init(); } elsif ($com eq 'term') { return type1_term(); } return 0; }