/usr/share/doc/defoma-doc/defoma-script.html/ch6.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 | <!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 - Using Defoma::Subst module.</title>
<link href="index.html" rel="start">
<link href="ch5.html" rel="prev">
<link href="ch7.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="ch6"></a></p>
<hr>
<p>
[ <a href="ch5.html">previous</a> ]
[ <a href="index.html#contents">Contents</a> ]
[ <a href="ch1.html">1</a> ]
[ <a href="ch2.html">2</a> ]
[ <a href="ch3.html">3</a> ]
[ <a href="ch4.html">4</a> ]
[ <a href="ch5.html">5</a> ]
[ 6 ]
[ <a href="ch7.html">7</a> ]
[ <a href="ch7.html">next</a> ]
</p>
<hr>
<h1>
A Tutorial on Writing Defoma Configuration Script
<br>Chapter 6 - Using Defoma::Subst module.
</h1>
<hr>
<p>
This document describes How to write Defoma-configuration script using font
substitution mechanism. Font substitution mechanism makes fonts substitute for
a certain id described in a subst-rule. The subst-rule file describes required
ids and their appearance information as hints, called rules, so that more
similar fonts substitute for the described required id. Substitutive fonts are
registered in a subst-cache. When a new id is added to a subst-rule, fonts
registered in the subst-cache similar to the id will substitute for the id.
</p>
<p>
Usually a subst-rule may be edited by users, but there is one that cannot be
edited. It is called private subst-rule. Private subst-rule is supposed to
add/remove rules from a Defoma-configuration script. This chapter describes a
modifiable subst-rule.
</p>
<p>
The script needs to call <samp>defoma_subst_open()</samp> in init command.
This function opens the subst-rule and subst-cache specified by the rulename
argument. You need to specify the id-cache to which the substituted ids are
registered.
</p>
<pre>
...
$Id = defoma_id_open_cache();
$Sb = defoma_subst_open(rulename => 'gsfonts',
idobject => $Id);
...
</pre>
<p>
The script needs to call <samp>defoma_subst_register()</samp> and
<samp>defoma_subst_unregister()</samp> functions in register and unregister
commands respectively. You need to pass the substitutive font and its realname
to the arguments. It is required to pass the hints of the font to the
arguments of <samp>defoma_id_register()</samp> on registering the real name.
</p>
<pre>
sub register {
...
defoma_id_register($Id, type => 'real', font => $font,
id => $realname, priority => $priority,
hints => join(' ', @hints));
defoma_subst_register($Sb, $font, $realname);
...
}
sub unregister {
...
defoma_subst_unregister($Sb, $font);
defoma_id_unregister($Id, type => 'real', font => $font);
...
}
</pre>
<p>
The script needs to call <samp>defoma_subst_close()</samp> in term command.
</p>
<pre>
...
defoma_subst_close($Sb);
defoma_id_close_cache($Id);
...
</pre>
<p>
The substituted ids are directly registered to the id-cache. Then Defoma::Id
module calls back the script with <samp>do-install-subst</samp> and
<samp>do-remove-subst</samp> commands, so the script must handle these
commands.
</p>
<pre>
type1 {
my $com = shift;
if (
...
} elsif ($com =~ /^do-install-(alias|subst)$/) {
return do_install_alias(@_);
} elsif ($com =~ /^do-remove-(alias|subst)$/) {
return do_remove_alias(@_);
}
...
}
</pre>
<p>
This example unite the operation for -subst into -alias. It it appropriate
because substituted ids are considered as alias.
</p>
<hr>
<p>
[ <a href="ch5.html">previous</a> ]
[ <a href="index.html#contents">Contents</a> ]
[ <a href="ch1.html">1</a> ]
[ <a href="ch2.html">2</a> ]
[ <a href="ch3.html">3</a> ]
[ <a href="ch4.html">4</a> ]
[ <a href="ch5.html">5</a> ]
[ 6 ]
[ <a href="ch7.html">7</a> ]
[ <a href="ch7.html">next</a> ]
</p>
<hr>
<p>
A Tutorial on Writing Defoma Configuration Script
</p>
<address>
Yasuhiro Take<br>
<br>
</address>
<hr>
</body>
</html>
|