/usr/share/doc/defoma-doc/defoma-script.html/ch5.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 | <!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::Id (2)</title>
<link href="index.html" rel="start">
<link href="ch4.html" rel="prev">
<link href="ch6.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="ch5"></a></p>
<hr>
<p>
[ <a href="ch4.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> ]
[ 5 ]
[ <a href="ch6.html">6</a> ]
[ <a href="ch7.html">7</a> ]
[ <a href="ch6.html">next</a> ]
</p>
<hr>
<h1>
A Tutorial on Writing Defoma Configuration Script
<br>Chapter 5 - Using Defoma::Id (2)
</h1>
<hr>
<p>
This chapter describes another way of creating <samp>fonts.dir</samp> and
<samp>fonts.alias</samp> files mentioned in the previous example. Only the
different point is described, so please also refer the previous chapter.
</p>
<p>
The general strategy is, get a list of installed fonts and ids from the
id-cache in term command and create the files using the list. Reading these
files in init command, adding/removing a font and its id to/from @dir in
do_install_real/do_remove_real, and codes for do_install_alias/do_remove_alias
commands are not necessary now.
</p>
<pre>
sub init {
unless ($Id) {
$Id = defoma_id_open_cache();
}
return 0;
}
sub do_install_real {
my $font = shift;
my $id = shift;
my $depfont = shift;
my $depid = shift;
my @hints = @_;
$font =~ /^(.*)\/(.+)$/;
my $fontfile = $2;
symlink($font, $DIR.$fontfile) || return 1;
return 0;
}
sub do_remove_real {
my $font = shift;
my $id = shift;
my $depfont = shift;
my $depid = shift;
my @hints = @_;
$font =~ /^(.*)\/(.+)$/;
my $fontfile = $2;
unlink($DIR.$fontfile);
return 0;
}
sub truetype {
my $com = shift;
if ($com eq 'init') {
return init();
} elsif ($com eq 'term') {
return term();
} elsif ($com eq 'register') {
return register(@_);
} elsif ($com eq 'unregister') {
return unregister(@_);
} elsif ($com eq 'do-install-real') {
return do_install_real(@_);
} elsif ($com eq 'do-remove-real') {
return do_remove_real(@_);
}
return 0;
}
</pre>
<p>
In term command, the script needs to obtain a list of installed fonts and ids.
First the script creates <samp>fonts.dir</samp> file.
</p>
<pre>
my $i;
my $font;
my $fontfile;
my $id;
my $depid;
my @list = defoma_id_get_font($Id, 'installed', type => 'SrI');
open(F, '>'.$DIR.'fonts.dir');
foreach $i (@list) {
$font = $Id->{e_font}->[$i];
$font =~ /^(.*)\/(.+)$/;
$fontfile = $2;
$id = $Id->{e_id}->[$i];
print F "/$id ($fontfile) ;\n";
}
close F;
</pre>
<p>
The <samp>defoma_id_get_font</samp> function searches ids that match the
specified rules from the specified id-cache, and returns the indexes of
id-cache which point to the matched fonts. In this example, the function
returns the indexes of installed real names. Following is codes to create
<samp>fonts.alias</samp>.
</p>
<pre>
my @list = defoma_id_get_font($Id, 'installed', type => 'SaI');
open(F, '>'.$DIR.'fonts.alias');
foreach $i (@list) {
$id = $Id->{e_id}->[$i];
$depid = $Id->{e_depid}->[$i];
print F "/$id /$depid ;\n";
}
close F;
</pre>
<hr>
<p>
[ <a href="ch4.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> ]
[ 5 ]
[ <a href="ch6.html">6</a> ]
[ <a href="ch7.html">7</a> ]
[ <a href="ch6.html">next</a> ]
</p>
<hr>
<p>
A Tutorial on Writing Defoma Configuration Script
</p>
<address>
Yasuhiro Take<br>
<br>
</address>
<hr>
</body>
</html>
|