/usr/share/perl5/Font/TTF/Post.pm is in libfont-ttf-perl 1.05-1.
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 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | package Font::TTF::Post;
=head1 NAME
Font::TTF::Post - Holds the Postscript names for each glyph
=head1 DESCRIPTION
Holds the postscript names for glyphs. Note that they are not held as an
array, but as indexes into two lists. The first list is the standard Postscript
name list defined by the TrueType standard. The second comes from the font
directly.
Looking up a glyph from a Postscript name or a name from a glyph number is
achieved through methods rather than variable lookup.
This class handles PostScript table types of 1, 2, 2.5 & 3, but not version 4.
Support for version 2.5 is as per Apple spec rather than MS.
The way to look up Postscript names or glyphs is:
$pname = $f->{'post'}{'VAL'}[$gnum];
$gnum = $f->{'post'}{'STRINGS'}{$pname};
=head1 INSTANCE VARIABLES
Due to different systems having different limitations, there are various class
variables available to control what post table types can be written.
=over 4
=item $Font::TTF::Post::no25
If set tells Font::TTF::Post::out to use table type 2 instead of 2.5 in case apps
cannot handle version 2.5.
=item VAL
Contains an array indexed by glyph number of Postscript names. This is used when
writing out a font.
=item STRINGS
An associative array of Postscript names mapping to the highest glyph with that
name. These may not be in sync with VAL.
=back
In addition there are the standard introductory variables defined in the
standard:
FormatType
italicAngle
underlinePosition
underlineThickness
isFixedPitch
minMemType42
maxMemType42
minMemType1
maxMemType1
=head1 METHODS
=cut
use strict;
use vars qw(@ISA @base_set %base_set %fields $VERSION $no25 @field_info @base_set);
require Font::TTF::Table;
use Font::TTF::Utils;
$no25 = 1; # officially deprecated format 2.5 tables in MS spec 1.3
@ISA = qw(Font::TTF::Table);
@field_info = (
'FormatType' => 'f',
'italicAngle' => 'f',
'underlinePosition' => 's',
'underlineThickness' => 's',
'isFixedPitch' => 'L',
'minMemType42' => 'L',
'maxMemType42' => 'L',
'minMemType1' => 'L',
'maxMemType1' => 'L');
@base_set = qw(.notdef .null nonmarkingreturn space exclam quotedbl numbersign dollar percent ampersand quotesingle
parenleft parenright asterisk plus comma hyphen period slash zero one two three four five six
seven eight nine colon semicolon less equal greater question at A B C D E F G H I J K L M N O P Q
R S T U V W X Y Z bracketleft backslash bracketright asciicircum underscore grave a b c d e f g h
i j k l m n o p q r s t u v w x y z braceleft bar braceright asciitilde Adieresis Aring Ccedilla
Eacute Ntilde Odieresis Udieresis aacute agrave acircumflex adieresis atilde aring ccedilla eacute
egrave ecircumflex edieresis iacute igrave icircumflex idieresis ntilde oacute ograve ocircumflex
odieresis otilde uacute ugrave ucircumflex udieresis dagger degree cent sterling section bullet
paragraph germandbls registered copyright trademark acute dieresis notequal AE Oslash infinity
plusminus lessequal greaterequal yen mu partialdiff summation product pi integral ordfeminine
ordmasculine Omega ae oslash questiondown exclamdown logicalnot radical florin approxequal
Delta guillemotleft guillemotright ellipsis nonbreakingspace Agrave Atilde Otilde OE oe endash emdash
quotedblleft quotedblright quoteleft quoteright divide lozenge ydieresis Ydieresis fraction currency
guilsinglleft guilsinglright fi fl daggerdbl periodcentered quotesinglbase quotedblbase perthousand
Acircumflex Ecircumflex Aacute Edieresis Egrave Iacute Icircumflex Idieresis Igrave Oacute Ocircumflex
apple Ograve Uacute Ucircumflex Ugrave dotlessi circumflex tilde macron breve dotaccent
ring cedilla hungarumlaut ogonek caron Lslash lslash Scaron scaron Zcaron zcaron brokenbar Eth eth
Yacute yacute Thorn thorn minus multiply onesuperior twosuperior threesuperior onehalf onequarter
threequarters franc Gbreve gbreve Idotaccent Scedilla scedilla Cacute cacute Ccaron ccaron dcroat);
$VERSION = 0.01; # MJPH 5-AUG-1998 Re-organise data structures
sub init
{
my ($k, $v, $c, $i);
for ($i = 0; $i < $#field_info; $i += 2)
{
($k, $v, $c) = TTF_Init_Fields($field_info[$i], $c, $field_info[$i + 1]);
next unless defined $k && $k ne "";
$fields{$k} = $v;
}
$i = 0;
%base_set = map {$_ => $i++} @base_set;
}
=head2 $t->read
Reads the Postscript table into memory from disk
=cut
sub read
{
my ($self) = @_;
$self->SUPER::read or return $self;
my ($dat, $dat1, $i, $off, $c, $maxoff, $form, $angle, $numGlyphs);
my ($fh) = $self->{' INFILE'};
$numGlyphs = $self->{' PARENT'}{'maxp'}{'numGlyphs'};
init unless ($fields{'FormatType'});
$fh->read($dat, 32);
TTF_Read_Fields($self, $dat, \%fields);
if (int($self->{'FormatType'} + .5) == 1)
{
for ($i = 0; $i < 258; $i++)
{
$self->{'VAL'}[$i] = $base_set[$i];
$self->{'STRINGS'}{$base_set[$i]} = $i unless (defined $self->{'STRINGS'}{$base_set[$i]});
}
} elsif (int($self->{'FormatType'} * 2 + .1) == 5)
{
$fh->read($dat, 2);
$numGlyphs = unpack("n", $dat);
$fh->read($dat, $numGlyphs);
for ($i = 0; $i < $numGlyphs; $i++)
{
$off = unpack("c", substr($dat, $i, 1));
$self->{'VAL'}[$i] = $base_set[$i + $off];
$self->{'STRINGS'}{$base_set[$i + $off]} = $i unless (defined $self->{'STRINGS'}{$base_set[$i + $off]});
}
} elsif (int($self->{'FormatType'} + .5) == 2)
{
my (@strings);
$fh->read($dat, ($numGlyphs + 1) << 1);
for ($i = 0; $i < $numGlyphs; $i++)
{
$off = unpack("n", substr($dat, ($i + 1) << 1, 2));
$maxoff = $off if (!defined $maxoff || $off > $maxoff);
}
for ($i = 0; $i < $maxoff - 257; $i++)
{
$fh->read($dat1, 1);
$off = unpack("C", $dat1);
$fh->read($dat1, $off);
$strings[$i] = $dat1;
}
for ($i = 0; $i < $numGlyphs; $i++)
{
$off = unpack("n", substr($dat, ($i + 1) << 1, 2));
if ($off > 257)
{
$self->{'VAL'}[$i] = $strings[$off - 258];
$self->{'STRINGS'}{$strings[$off - 258]} = $i;
}
else
{
$self->{'VAL'}[$i] = $base_set[$off];
$self->{'STRINGS'}{$base_set[$off]} = $i unless (defined $self->{'STRINGS'}{$base_set[$off]});
}
}
}
$self;
}
=head2 $t->out($fh)
Writes out a new Postscript name table from memory or copies from disk
=cut
sub out
{
my ($self, $fh) = @_;
my ($i, $num);
return $self->SUPER::out($fh) unless $self->{' read'};
$num = $self->{' PARENT'}{'maxp'}{'numGlyphs'};
init unless ($fields{'FormatType'});
for ($i = $#{$self->{'VAL'}}; !defined $self->{'VAL'}[$i] && $i > 0; $i--)
{ pop(@{$self->{'VAL'}}); }
if ($#{$self->{'VAL'}} < 0)
{ $self->{'FormatType'} = 3; }
else
{
$self->{'FormatType'} = 1;
for ($i = 0; $i < $num; $i++)
{
if (!defined $base_set{$self->{'VAL'}[$i]})
{
$self->{'FormatType'} = 2;
last;
}
elsif ($base_set{$self->{'VAL'}[$i]} != $i)
{ $self->{'FormatType'} = ($no25 ? 2 : 2.5); }
}
}
$fh->print(TTF_Out_Fields($self, \%fields, 32));
return $self if (int($self->{'FormatType'} + .4) == 3);
if (int($self->{'FormatType'} + .5) == 2)
{
my (@ind);
my ($count) = 0;
$fh->print(pack("n", $num));
for ($i = 0; $i < $num; $i++)
{
if (defined $base_set{$self->{'VAL'}[$i]})
{ $fh->print(pack("n", $base_set{$self->{'VAL'}[$i]})); }
else
{
$fh->print(pack("n", $count + 258));
$ind[$count++] = $i;
}
}
for ($i = 0; $i < $count; $i++)
{
$fh->print(pack("C", length($self->{'VAL'}[$ind[$i]])));
$fh->print($self->{'VAL'}[$ind[$i]]);
}
} elsif (int($self->{'FormatType'} * 2 + .5) == 5)
{
$fh->print(pack("n", $num));
for ($i = 0; $i < $num; $i++)
{ $fh->print(pack("c", defined $base_set{$self->{'VAL'}[$i]} ?
$base_set{$self->{'VAL'}[$i]} - $i : -$i)); }
}
$self;
}
=head2 $t->XML_element($context, $depth, $key, $val)
Outputs the names as one block of XML
=cut
sub XML_element
{
my ($self) = shift;
my ($context, $depth, $key, $val) = @_;
my ($fh) = $context->{'fh'};
my ($i);
return $self->SUPER::XML_element(@_) unless ($key eq 'STRINGS' || $key eq 'VAL');
return unless ($key eq 'VAL');
$fh->print("$depth<names>\n");
for ($i = 0; $i <= $#{$self->{'VAL'}}; $i++)
{ $fh->print("$depth$context->{'indent'}<name post='$self->{'VAL'}[$i]' gid='$i'/>\n"); }
$fh->print("$depth</names>\n");
$self;
}
=head2 $t->minsize()
Returns the minimum size this table can be. If it is smaller than this, then the table
must be bad and should be deleted or whatever.
=cut
sub minsize
{
return 32;
}
1;
=head1 BUGS
=over 4
=item *
No support for type 4 tables
=back
=head1 AUTHOR
Martin Hosken L<http://scripts.sil.org/FontUtils>.
=head1 LICENSING
Copyright (c) 1998-2014, SIL International (http://www.sil.org)
This module is released under the terms of the Artistic License 2.0.
For details, see the full text of the license in the file LICENSE.
=cut
|