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.
init .. this command is passed only once before any other command is passed to
the function. In this command the script should open id-caches and
subst-caches if necessary, and read config files if exist.
register .. this command is passed whenever a font in the category is newly
registered to Defoma. Following arguments consist of the font and its hints.
If registration of the font is failed, the function must return non-zero.
Otherwise the function must return zero.
unregister .. this command is passed whenever a font in the category is
unregistered from Defoma. Following arguments consist of the font and its
hints.
term .. this command is passed after all registration and unregistration is
done, and before quitting. In this command the script should close id-caches
and subst-caches if necessary, and might update the configuration of fonts.
do-install-real, do-install-alias, do-install-subst .. these commands are
passed from Defoma::Id module, so if the script doesn't use Defoma::Id module,
the script never comes across these commands. Following arguments consists of
the font, the id and some hints.
In these commands the script must do installation of the font with the id.
do-remove-real, do-remove-alias, do-remove-subst .. these commands are passed
from Defoma::Id module, so if the script doesn't use Defoma::Idd module, the
script never comes across these commands. Following arguments consists of the
font, the id and some hints.
In these commands the script must do removal of the font with the id.