Debian Codegraph @

make_metrics

raw ◀ ▶
1 Debian patch touch this file
•1 #!/usr/bin/perl -w
2
3 # $Id: make_metrics,v 1.3 1998/03/25 12:59:53 aas Exp $
4 #
5 # This program creates metrics modules for some fonts and place them
6 # under the "Metrics" directory.
7 #
8 # Author: Gisle Aas
9
10 @FONTS = qw(Courier
11 Courier-Bold
12 Courier-Oblique
13 Courier-BoldOblique
14
15 Helvetica
16 Helvetica-Bold
17 Helvetica-Oblique
18 Helvetica-BoldOblique
19
20 Times-Roman
21 Times-Bold
22 Times-Italic
23 Times-BoldItalic
24 );
25 @FONTS = @ARGV if @ARGV;
26
27 require Font::AFM;
28
29 $0 =~ s,.*/,,;
30
31 use File::Path qw(mkpath);
32 mkpath("lib/Font/Metrics", 1, 0755);
33
34 for $font (@FONTS) {
35 eval {
36 $afm = new Font::AFM $font;
37 };
38 if ($@) {
39 print $@;
40 next;
41 }
42 @wx = $afm->latin1_wx_table;
43
44 ($fontmod = $font) =~ s/-//g;
45
46 open(FONTDEF, ">lib/Font/Metrics/$fontmod.pm") or die "Can't open $fontmod.pm: $!";
47 select FONTDEF;
48 print "# Font metrics for $font\n#\n";
49 print "# DO NOT EDIT!!!\n";
50 print "#\n";
51 print "# This file was auto-generated by $0 based on the AFM file for the font.\n";
52 print "#\n# ", $afm->Notice, "\n";
53 print "\n";
54 print "package Font::Metrics::$fontmod;\n";
55
56 print "\n# Character width table (iso-8859-1)\n";
57 print "\@wx = (\n";
58 $i = 0;
59 for (@wx) {
60 printf " %-6s", sprintf "%.3g,", $_ / 1000;
61 unless (++$i % 8) {
62 print "\n";
63 }
64 }
65 print ");\n";
66
67 $upos = $afm->UnderlinePosition;
68 $uthick = $afm->UnderlineThickness;
69 if ($upos && $uthick) {
70 print "\n";
71 printf "\$UnderlinePosition = %.3g;\n", $upos/1000;
72 printf "\$UnderlineThickness = %.3g;\n", $uthick/1000;
73 }
74
75 print "\n1;\n";
76 }
77