/usr/share/doc/defoma-doc/defoma-script.html/ch1.html is in defoma-doc 0.11.12ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>A Tutorial on Writing Defoma Configuration Script - Introduction</title>
<link href="index.html" rel="start">
<link href="index.html" rel="prev">
<link href="ch2.html" rel="next">
<link href="index.html#contents" rel="contents">
<link href="index.html#copyright" rel="copyright">
<link href="ch1.html" rel="chapter" title="1 Introduction">
<link href="ch2.html" rel="chapter" title="2 Simple Defoma-configuration script.">
<link href="ch3.html" rel="chapter" title="3 Using hints.">
<link href="ch4.html" rel="chapter" title="4 Using Defoma::Id module.">
<link href="ch5.html" rel="chapter" title="5 Using Defoma::Id (2)">
<link href="ch6.html" rel="chapter" title="6 Using Defoma::Subst module.">
<link href="ch7.html" rel="chapter" title="7 Using x-postscript Category.">
</head>
<body>
<p><a name="ch1"></a></p>
<hr>
<p>
[ <a href="index.html">previous</a> ]
[ <a href="index.html#contents">Contents</a> ]
[ 1 ]
[ <a href="ch2.html">2</a> ]
[ <a href="ch3.html">3</a> ]
[ <a href="ch4.html">4</a> ]
[ <a href="ch5.html">5</a> ]
[ <a href="ch6.html">6</a> ]
[ <a href="ch7.html">7</a> ]
[ <a href="ch2.html">next</a> ]
</p>
<hr>
<h1>
A Tutorial on Writing Defoma Configuration Script
<br>Chapter 1 - Introduction
</h1>
<hr>
<h2><a name="s1.1"></a>1.1 What is Defoma-configuration script?</h2>
<p>
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.
</p>
<p>
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.
</p>
<p>
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.
</p>
<hr>
<h2><a name="s1.2"></a>1.2 Format.</h2>
<p>
Defoma-configuration script must be written as a perl library. That is, the
script must end up with '1;' line.
</p>
<p>
The script must declare what categories of fonts the script accepts in the
first line. Use global array variable <samp>@ACCEPT_CATEGORIES</samp>.
</p>
<p>
Any codes and declarations must be packaged with its script name. If the name
of the script is <samp>bar.defoma</samp>, you have to put
</p>
<pre>
package bar;
</pre>
<p>
before any perl code except <samp>@ACCEPT_CATEGORIES</samp>. If the name of
the script contains characters other than alphabets, numbers and underscore,
replace them with underscore.
</p>
<p>
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.
</p>
<p>
Here is an example of a package named '<samp>foo-bar</samp>' which has a
Defoma-configuration script, which configures about fonts in type1 and
x-postscript categories.
</p>
<pre>
# 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;
</pre>
<hr>
<h2><a name="s1.3"></a>1.3 Arguments of function.</h2>
<p>
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.
</p>
<ul>
<li>
<p>
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.
</p>
</li>
</ul>
<ul>
<li>
<p>
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.
</p>
</li>
</ul>
<ul>
<li>
<p>
unregister .. this command is passed whenever a font in the category is
unregistered from Defoma. Following arguments consist of the font and its
hints.
</p>
</li>
</ul>
<ul>
<li>
<p>
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.
</p>
</li>
</ul>
<ul>
<li>
<p>
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.
</p>
<p>
In these commands the script must do installation of the font with the id.
</p>
</li>
</ul>
<ul>
<li>
<p>
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.
</p>
<p>
In these commands the script must do removal of the font with the id.
</p>
</li>
</ul>
<p>
Here describes an example of a function <samp>type1</samp>.
</p>
<pre>
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;
}
</pre>
<hr>
<p>
[ <a href="index.html">previous</a> ]
[ <a href="index.html#contents">Contents</a> ]
[ 1 ]
[ <a href="ch2.html">2</a> ]
[ <a href="ch3.html">3</a> ]
[ <a href="ch4.html">4</a> ]
[ <a href="ch5.html">5</a> ]
[ <a href="ch6.html">6</a> ]
[ <a href="ch7.html">7</a> ]
[ <a href="ch2.html">next</a> ]
</p>
<hr>
<p>
A Tutorial on Writing Defoma Configuration Script
</p>
<address>
Yasuhiro Take<br>
<br>
</address>
<hr>
</body>
</html>
|