File: 021_synfonts

package info (click to toggle)
libpdf-api2-perl 2.019-1%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 20,264 kB
  • sloc: perl: 42,313; sh: 23; makefile: 9
file content (122 lines) | stat: -rw-r--r-- 3,064 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl

use lib '../lib';
use PDF::API2;
use PDF::API2::Util;

my $sx=33;
my $sy=45;
my $fx=20;

foreach $fn (qw(
    Times-Roman
    Times-Italic
    Times-Bold
    Times-BoldItalic
    Courier
    Courier-Oblique
    Courier-Bold
    Courier-BoldOblique
    Helvetica
    Helvetica-Oblique
    Helvetica-Bold
    Helvetica-BoldOblique
    Symbol
    ZapfDingbats
    bankgothic
    georgia
    georgiaitalic
    georgiabold
    georgiabolditalic
    trebuchet
    trebuchetbold
    trebuchetbolditalic
    trebuchetitalic
    verdana
    verdanaitalic
    verdanabold
    verdanabolditalic
    wingdings
    webdings
)) {

    $pdf=PDF::API2->new;
    initNameTable();

    $f1=$pdf->corefont('Helvetica');

    print STDERR "\n$fn\n";


    my $fn1=$pdf->corefont($fn,-encode => 'latin1');

    my @fonts=($fn1,$fn1->automap());

    foreach my $fnt (@fonts) {

        foreach my $k ({-slant=>0.750},{-oblique=>12},{-bold=>4},{-caps=>1}) {

            my $font=$pdf->synfont($fnt, %{$k});

            my $page = $pdf->page;
            $page->mediabox(595,842);

            my $gfx=$page->gfx;

            my $txt=$page->text;
                $txt->font($font,$fx);

            my $txt2=$page->text;

                $txt2->translate(50,800);
                $txt2->font($f1,20);
                $txt2->text("font='".$font->fontname." / ".$font->name."'");

                $txt2->font($f1,5);
                $txt2->hspace(80);

            my $u=$font->underlineposition*$fx/1000;

            foreach $x (0..15) {
                print STDERR ".";
                foreach $y (0..15) {
                    $txt->translate(50+($sx*$x),50+($sy*$y));
                    $txt->text(chr($y*16+$x));

                    my $wx=$font->width(chr($y*16+$x))*$fx;

                    $gfx->strokecolor('lightblue');
                    $gfx->move(50+($sx*$x),50+($sy*$y)+$fx);
                    $gfx->line(50+($sx*$x),50+($sy*$y)+$u);
                    $gfx->line(50+($sx*$x)+$wx,50+($sy*$y)+$u);
                    $gfx->line(50+($sx*$x)+$wx,50+($sy*$y)+$fx);
                    $gfx->close;
                    $gfx->stroke;

                    $gfx->strokecolor('gray');
                    $gfx->move(50+($sx*$x),50+($sy*$y));
                    $gfx->line(50+($sx*$x)+$wx,50+($sy*$y));
                    $gfx->stroke;

                    $txt2->translate(50+($sx*$x)-2,50+($sy*$y)-6);
                    $txt2->text_right($y*16+$x);
                    $txt2->translate(50+($sx*$x)-2,50+($sy*$y)-11);
                    $txt2->text_right(sprintf('U=0x%04X',$font->uniByEnc($y*16+$x)));
                    $txt2->translate(50+($sx*$x)-2,50+($sy*$y)-16);
                    $txt2->text_right($font->glyphByEnc($y*16+$x));
                    $txt2->translate(50+($sx*$x)-2,50+($sy*$y)-21);
                    $txt2->text_right(sprintf('wx=%i',$font->wxByEnc($y*16+$x)));
                }
            }

            print STDERR "\n";
        }
    }
    
    $pdf->saveas("$0.$fn.pdf");
    $pdf->end();
    last;
}
exit;

__END__