This file is indexed.

/usr/share/perl5/PostScript/File/Metrics/Loader.pm is in libpostscript-file-perl 2.20+dfsg-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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
#---------------------------------------------------------------------
package PostScript::File::Metrics::Loader;
#
# Copyright 2009 Christopher J. Madsen
#
# Author: Christopher J. Madsen <perl@cjmweb.net>
# Created: 29 Oct 2009
#
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See either the
# GNU General Public License or the Artistic License for more details.
#
# ABSTRACT: Load metrics for PostScript fonts using Font::AFM
#---------------------------------------------------------------------

use 5.008;
our $VERSION = '2.20';          ## no critic
# This file is part of PostScript-File 2.20 (February 11, 2012)

use strict;
use warnings;
use Carp 'confess';
# RECOMMEND PREREQ: Font::AFM
use Font::AFM;
use PostScript::File 2.00 ();

our %attribute = qw(
  FullName           full_name
  FamilyName         family
  Weight             weight
  IsFixedPitch       fixed_pitch
  ItalicAngle        italic_angle
  FontBBox           font_bbox
  UnderlinePosition  underline_position
  UnderlineThickness underline_thickness
  Version            version
  CapHeight          cap_height
  XHeight            x_height
  Ascender           ascender
  Descender          descender
);

our @numeric_attributes = qw(
  ascender
  cap_height
  descender
  italic_angle
  underline_position
  underline_thickness
  x_height
);

our @StandardEncoding = qw(
    .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    space exclam quotedbl numbersign
	dollar percent ampersand quoteright
    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
    quoteleft 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 .notdef
    .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    .notdef exclamdown cent sterling
	fraction yen florin section
    currency quotesingle quotedblleft guillemotleft
	guilsinglleft guilsinglright fi fl
    .notdef endash dagger daggerdbl
	periodcentered .notdef paragraph bullet
    quotesinglbase quotedblbase quotedblright guillemotright
	ellipsis perthousand .notdef questiondown
    .notdef grave acute circumflex tilde macron breve dotaccent
    dieresis .notdef ring cedilla .notdef hungarumlaut ogonek caron
    emdash .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
    .notdef AE .notdef ordfeminine .notdef .notdef .notdef .notdef
    Lslash Oslash OE ordmasculine .notdef .notdef .notdef .notdef
    .notdef ae .notdef .notdef .notdef dotlessi .notdef .notdef
    lslash oslash oe germandbls .notdef .notdef .notdef .notdef
);

our @SymbolEncoding = (
  ('.notdef') x 32,
# \040
  qw(space exclam universal numbersign
	existential percent ampersand suchthat
    parenleft parenright asteriskmath plus
	comma minus period slash
    zero one two three
	four five six seven
    eight nine colon semicolon
	less equal greater question),
# \100
  qw(congruent Alpha Beta Chi
	Delta Epsilon Phi Gamma
    Eta Iota theta1 Kappa
	Lambda Mu Nu Omicron
    Pi Theta Rho Sigma
	Tau Upsilon sigma1 Omega
    Xi Psi Zeta bracketleft
	therefore bracketright perpendicular underscore),
# \140
  qw(radicalex alpha beta chi
	delta epsilon phi gamma
    eta iota phi1 kappa
	lambda mu nu omicron
    pi theta rho sigma
	tau upsilon omega1 omega
    xi psi zeta braceleft
	bar braceright similar .notdef),
# \200
  ('.notdef') x 32,
# \240
  qw(Euro Upsilon1 minute lessequal
	fraction infinity florin club
    diamond heart spade arrowboth
	arrowleft arrowup arrowright arrowdown
    degree plusminus second greaterequal
	multiply proportional partialdiff bullet
    divide notequal equivalence approxequal
	ellipsis arrowvertex arrowhorizex carriagereturn),
# \300
  qw(aleph Ifraktur Rfraktur weierstrass
	circlemultiply circleplus emptyset intersection
    union propersuperset reflexsuperset notsubset
	propersubset reflexsubset element notelement
    angle gradient registerserif copyrightserif
	trademarkserif product radical dotmath
    logicalnot logicaland logicalor arrowdblboth
	arrowdblleft arrowdblup arrowdblright arrowdbldown),
# \340
  qw(lozenge angleleft registersans copyrightsans
	trademarksans summation parenlefttp parenleftex
    parenleftbt bracketlefttp bracketleftex bracketleftbt
	bracelefttp braceleftmid braceleftbt braceex
    .notdef angleright integral integraltp
	integralex integralbt parenrighttp parenrightex
    parenrightbt bracketrighttp bracketrightex bracketrightbt
	bracerighttp bracerightmid bracerightbt .notdef),
);
#=====================================================================


sub load
{
  my ($font, $encodings) = @_;

  my $afm = Font::AFM->new($font);


  # Process the encoding-independent font attributes:
  unless ($PostScript::File::Metrics::Info{$font}) {
    my %info;
    while (my ($method, $key) = each %attribute) {
      # Font::AFM croaks instead of returning undef:
      $info{$key} = do { local $@; eval { $afm->$method } };
    }

    # Ensure Data::Dumper will dump numbers as such:
    for (@numeric_attributes) {
      $info{$_} += 0 if defined $info{$_};
    }

    # Convert attributes to be more "Perlish":
    $info{fixed_pitch} = ($info{fixed_pitch} eq 'true' ? 1 : 0);
    $info{font_bbox} = [ map { $_ + 0 } split ' ', $info{font_bbox} ];

    $PostScript::File::Metrics::Info{$font} = \%info;
  } # end unless info has been loaded

  # Create a width table for each requested encoding:
  my $wxHash = $afm->Wx;

  foreach my $encoding (@$encodings) {
    next if $PostScript::File::Metrics::Metrics{$font}{$encoding};

    my $vector = get_encoding_vector($encoding);

    my @wx;
    for (0..255) {
      my $name = $vector->[$_];
      if (exists $wxHash->{$name}) {
        push @wx, $wxHash->{$name} + 0;
      } else {
        push @wx, $wxHash->{'.notdef'} + 0;
      }
    } # end for 0..255

    $PostScript::File::Metrics::Metrics{$font}{$encoding} = \@wx;
  } # end foreach $encoding
} # end load
#---------------------------------------------------------------------


sub get_encoding_vector
{
  my ($encoding) = @_;

  return \@StandardEncoding if $encoding eq 'std';
  return \@SymbolEncoding   if $encoding eq 'sym';

  my $name = $PostScript::File::encoding_name{$encoding}
      or confess "Unknown encoding $encoding";


  $PostScript::File::encoding_def{$name}
      =~ /\bSTARTDIFFENC\b(.+)\bENDDIFFENC\b/s
          or confess "Can't find definition for $encoding";

  my $def = $1;
  $def =~ s/%.*//g;             # Strip comments

  my @vec = @StandardEncoding;

  my $i = 0;
  while ($def =~ /(\S+)/g) {
    my $term = $1;
    if ($term =~ m!^/(.+)!) {
      $vec[$i++] = $1;
    } elsif ($term =~ /^\d+$/) {
      $i = $term;
    } else {
      confess "Invalid term $term in $name";
    }
  }

  return \@vec;
} # end get_encoding_vector

#=====================================================================
# Package Return Value:

1;

__END__

=head1 NAME

PostScript::File::Metrics::Loader - Load metrics for PostScript fonts using Font::AFM

=head1 VERSION

This document describes version 2.20 of
PostScript::File::Metrics::Loader, released February 11, 2012
as part of PostScript-File version 2.20.

=head1 DESCRIPTION

PostScript::File::Metrics::Loader is used by
L<PostScript::File::Metrics> when no pre-compiled metrics are
available for the requested font or encoding.  It uses Font::AFM to
read the AFM file and extract metrics from it.

You should not normally need to use this module, since pre-compiled
metrics for the standard PostScript fonts are included with this
distribution.  If you request metrics for a non-standard font,
PostScript::File::Metrics will load this module automatically.

If you need metrics for additional fonts, you may want to modify and
run F<examples/generate_metrics.pl> to create pre-compiled modules for
them.

=head1 SUBROUTINES

=head2 get_encoding_vector

  PostScript::File::Metrics::Loader::get_encoding_vector($encoding)

This returns the encoding vector for C<$encoding>, an arrayref of 256
glyph names.


=head2 load

  PostScript::File::Metrics::Loader::load($font, \@encodings)

This uses Font::AFM to read the metrics for C<$font>, and creates
width tables for each of the C<@encodings>.  The metrics are stored
into the hashes used internally by PostScript::File::Metrics.

=head1 DIAGNOSTICS

=over

=item C<< Can't find definition for %s >>

If this happens, it indicates you found a bug in
PostScript::File::Metrics::Loader.  Please report it as described
under L</AUTHOR>.


=item C<< Can't find the AFM file for %s >>

Font::AFM could not find F<%s.afm> in any of the directories it
searched.  See L</"CONFIGURATION AND ENVIRONMENT">.


=item C<< Invalid term %s in %s >>

This also indicates a bug in PostScript::File.  Please report it.


=item C<< Unknown encoding %s >>

You asked for an encoding that PostScript::File::Metrics doesn't know about.


=back

=head1 CONFIGURATION AND ENVIRONMENT

PostScript::File::Metrics::Loader requires no configuration files or
environment variables.

However, it uses L<Font::AFM>, and unfortunately that's difficult to
configure properly (which is why I created PostScript::File::Metrics
in the first place).  Font::AFM expects to find a file named
F<FontName.afm> in one of the directories it searches.

I wound up creating symlinks in F</usr/local/lib/afm/> (which is one
of the default paths that Font::AFM searches if you don't have a
C<METRICS> environment variable):

 Courier.afm
   -> /usr/share/texmf-dist/fonts/afm/adobe/courier/pcrr8a.afm
 Courier-Bold.afm
   -> /usr/share/texmf-dist/fonts/afm/adobe/courier/pcrb8a.afm
 Courier-BoldOblique.afm
   -> /usr/share/texmf-dist/fonts/afm/adobe/courier/pcrbo8a.afm
 Courier-Oblique.afm
   -> /usr/share/texmf-dist/fonts/afm/adobe/courier/pcrro8a.afm
 Helvetica.afm
   -> /usr/share/texmf-dist/fonts/afm/adobe/helvetic/phvr8a.afm
 Helvetica-Bold.afm
   -> /usr/share/texmf-dist/fonts/afm/adobe/helvetic/phvb8a.afm
 Helvetica-BoldOblique.afm
   -> /usr/share/texmf-dist/fonts/afm/adobe/helvetic/phvbo8a.afm
 Helvetica-Oblique.afm
   -> /usr/share/texmf-dist/fonts/afm/adobe/helvetic/phvro8a.afm
 Symbol.afm
   -> /usr/share/texmf-dist/fonts/afm/adobe/symbol/psyr.afm
 Times-Bold.afm
   -> /usr/share/texmf-dist/fonts/afm/adobe/times/ptmb8a.afm
 Times-BoldItalic.afm
   -> /usr/share/texmf-dist/fonts/afm/adobe/times/ptmbi8a.afm
 Times-Italic.afm
   -> /usr/share/texmf-dist/fonts/afm/adobe/times/ptmri8a.afm
 Times-Roman.afm
   -> /usr/share/texmf-dist/fonts/afm/adobe/times/ptmr8a.afm

Paths on your system may vary.  I suggest searching for C<.afm> files,
and then grepping them for "FontName X", where X is the font you need
metrics for.

=head1 INCOMPATIBILITIES

None reported.

=head1 BUGS AND LIMITATIONS

No bugs have been reported.

=head1 AUTHOR

Christopher J. Madsen  S<C<< <perl AT cjmweb.net> >>>

Please report any bugs or feature requests
to S<C<< <bug-PostScript-File AT rt.cpan.org> >>>
or through the web interface at
L<< http://rt.cpan.org/Public/Bug/Report.html?Queue=PostScript-File >>.

You can follow or contribute to PostScript-File's development at
L<< http://github.com/madsen/postscript-file >>.

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Christopher J. Madsen.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=head1 DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

=cut