File: font-type1.t

package info (click to toggle)
libpdf-builder-perl 3.027-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,992 kB
  • sloc: perl: 107,532; makefile: 10
file content (81 lines) | stat: -rw-r--r-- 2,789 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
#!/usr/bin/perl
use warnings;
use strict;

use Test::More tests => 2;
my $test_count = 2;

use PDF::Builder;

my (@pfb_list, @pfm_list);
my ($pfb_file, $pfm_file);

my $OSname = $^O;

# expecting a matching pfb and pfm set. if you have .pfa and/or .afm|.xfm,
# something will have to be done about that
if ($OSname eq 'MSWin32') {
    # Windows systems (MikTex installation assumed, as Windows doesn't come
    # with any Type1 fonts preinstalled). new and older MiKTeX paths.
    push @pfb_list, 'C:/Program Files/MikTex 2.9/fonts/type1/urw/bookman/ubkd8a.pfb';
    push @pfm_list, 'C:/Program Files/MikTex 2.9/fonts/type1/urw/bookman/ubkd8a.pfm';
    push @pfb_list, 'C:/Program Files (x86)/MikTex 2.9/fonts/type1/urw/bookman/ubkd8a.pfb';
    push @pfm_list, 'C:/Program Files (x86)/MikTex 2.9/fonts/type1/urw/bookman/ubkd8a.pfm';
    push @pfb_list, 'C:/Users/Phil/fonts/T1fonts/URWGothic-Book.t1';
    push @pfm_list, 'C:/Users/Phil/fonts/T1fonts/URWGothic-Book.afm';

} else {
    # Unix/Linux systems assumed. is this a standard location everyone has?
    push @pfb_list, '/usr/share/fonts/type1/gsfonts/a010013l.pfb';
    push @pfm_list, '/usr/share/fonts/type1/gsfonts/a010013l.pfm';
    push @pfb_list, '/usr/share/X11/fonts/urw-fonts/a010013l.pfb';
    push @pfm_list, '/usr/share/X11/fonts/urw-fonts/a010013l.pfm';
    push @pfb_list, '/usr/share/fonts/urw-base35/URWGothic-Book.t1';
    push @pfm_list, '/usr/share/fonts/urw-base35/URWGothic-Book.afm';
}

# This may or may not work on Macs ("darwin" string) and other platforms
# ("os2", "dos", "cygwin"). Might need some updates once the appropriate
# file paths are known. Suggestions are welcome for Windows and non-Windows
# font paths that could be tried.

# find a working file set (hopefully matched set of font and metrics!)
foreach (@pfb_list) {
    if (-f $_ && -r $_) {
        $pfb_file = $_; 
	last;
    }
}
foreach (@pfm_list) {
    if (-f $_ && -r $_) {
        $pfm_file = $_; 
	last;
    }
}

SKIP: {
    skip "Skipping Type1 tests... URW Gothic L Book font not found", $test_count
        unless (defined $pfb_file and defined $pfm_file);

    my $pdf = PDF::Builder->new();
    my $font;
    # handle both afm and pfm metric files
    if ($pfm_file =~ m/\.pfm$/i) {
#       $font = $pdf->font($pfb_file, 'pfmfile' => $pfm_file);
        $font = $pdf->psfont($pfb_file, 'pfmfile' => $pfm_file);
    } else {
#       $font = $pdf->font($pfb_file, 'afmfile' => $pfm_file);
        $font = $pdf->psfont($pfb_file, 'afmfile' => $pfm_file);
    }

    # Do something with the font to see if it appears to have opened
    # properly.
    ok($font->glyphNum() > 0,
       q{Able to read a count of glyphs (>0) from a Type1 font});

    like($font->{'Name'}->val(), qr/^Ur/,
	 q{Font has the expected name});

}

1;