| 1 | package PDF::API2::Resource::Font::BdFont; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use base 'PDF::API2::Resource::Font'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||
| 8 | 1 | our $VERSION = '2.044'; # VERSION | |||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use PDF::API2::Util; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use PDF::API2::Basic::PDF::Utils; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||
| 13 | 1 | our $BmpNum = 0; | |||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||
| 15 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||
| 17 | PDF::API2::Resource::Font::BdFont - Module for using bitmapped Fonts. | ||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||||||||||||
| 22 | use PDF::API2; | ||||||||||||||||||||||||||||||||||||||
| 23 | # | ||||||||||||||||||||||||||||||||||||||
| 24 | $pdf = PDF::API2->new; | ||||||||||||||||||||||||||||||||||||||
| 25 | $sft = $pdf->bdfont($file); | ||||||||||||||||||||||||||||||||||||||
| 26 | # | ||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||
| 28 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||
| 30 | =over 4 | ||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||
| 32 | =cut | ||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||
| 34 | =item $font = PDF::API2::Resource::Font::BdFont->new $pdf, $font, %options | ||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||
| 36 | Returns a BmpFont object. | ||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||
| 38 | =cut | ||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||
| 40 | =pod | ||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||
| 42 | Valid %options are: | ||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||
| 44 | I<-encode> | ||||||||||||||||||||||||||||||||||||||
| 45 | ... changes the encoding of the font from its default. | ||||||||||||||||||||||||||||||||||||||
| 46 | See I<perl's Encode> for the supported values. | ||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||
| 48 | I<-pdfname> ... changes the reference-name of the font from its default. | ||||||||||||||||||||||||||||||||||||||
| 49 | The reference-name is normally generated automatically and can be | ||||||||||||||||||||||||||||||||||||||
| 50 | retrieved via $pdfname=$font->name. | ||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||
| 52 | =cut | ||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||
| 54 | sub new { | ||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my ($class, $pdf, $file, %opts) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=23 SCAR=63.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | $class = ref($class) if ref($class); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $name = sprintf('%s+Bdf%02i', pdfkey(), ++$BmpNum) . '~' . time(); | |||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $self = $class->SUPER::new($pdf, $name); | |||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $pdf->new_obj($self) unless $self->is_obj($pdf); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||
| 62 | # Adobe Bitmap Distribution Font | ||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $self->{' data'} = $self->readBDF($file); | |||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my $first = 1; | |||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $last = 255; | |||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $self->{'Subtype'} = PDFName('Type3'); | |||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->{'FirstChar'} = PDFNum($first); | |||||||||||||||||||||||||||||||||||||
| 70 | 0 | $self->{'LastChar'} = PDFNum($last); | |||||||||||||||||||||||||||||||||||||
| 71 | 0 | $self->{'FontMatrix'} = PDFArray(map { PDFNum($_) } 0.001, 0, 0, 0.001, 0, 0); | |||||||||||||||||||||||||||||||||||||
| 72 | 0 | $self->{'FontBBox'} = PDFArray(map { PDFNum($_) } $self->fontbbox()); | |||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my $xo = PDFDict(); | |||||||||||||||||||||||||||||||||||||
| 75 | 0 | $self->{'Encoding'} = $xo; | |||||||||||||||||||||||||||||||||||||
| 76 | 0 | $xo->{'Type'} = PDFName('Encoding'); | |||||||||||||||||||||||||||||||||||||
| 77 | 0 | $xo->{'BaseEncoding'} = PDFName('WinAnsiEncoding'); | |||||||||||||||||||||||||||||||||||||
| 78 | $xo->{'Differences'} = PDFArray(PDFNum('0'), | ||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | map { PDFName($_ or '.notdef') } | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_ || '.notdef'
MC/DC0%0/1
$_ || '.notdef'
$_
Truth table0%0/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||
| 80 | 0 | @{$self->data->{'char'}}); | |||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my $procs = PDFDict(); | |||||||||||||||||||||||||||||||||||||
| 83 | 0 | $pdf->new_obj($procs); | |||||||||||||||||||||||||||||||||||||
| 84 | 0 | $self->{'CharProcs'} = $procs; | |||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $self->{'Resources'} = PDFDict(); | |||||||||||||||||||||||||||||||||||||
| 87 | 0 | $self->{'Resources'}->{'ProcSet'} = PDFArray(map { PDFName($_) } | |||||||||||||||||||||||||||||||||||||
| 88 | qw(PDF Text ImageB ImageC ImageI)); | ||||||||||||||||||||||||||||||||||||||
| 89 | 0 | foreach my $w ($first .. $last) { | |||||||||||||||||||||||||||||||||||||
| 90 | 0 | $self->data->{'uni'}->[$w] = uniByName($self->data->{'char'}->[$w]); | |||||||||||||||||||||||||||||||||||||
| 91 | 0 | $self->data->{'u2e'}->{$self->data->{'uni'}->[$w]} = $w; | |||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my @widths; | |||||||||||||||||||||||||||||||||||||
| 94 | 0 | foreach my $w (@{$self->data->{'char2'}}) { | |||||||||||||||||||||||||||||||||||||
| 95 | 0 | $widths[$w->{'ENCODING'}] = $self->data->{'wx'}->{$w->{'NAME'}}; | |||||||||||||||||||||||||||||||||||||
| 96 | 0 | my @bbx = @{$w->{'BBX'}}; | |||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $stream = pack('H*', $w->{'hex'}); | |||||||||||||||||||||||||||||||||||||
| 98 | 0 | my $y = $bbx[1]; | |||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $char = PDFDict(); | |||||||||||||||||||||||||||||||||||||
| 100 | 0 | $char->{'Filter'} = PDFArray(PDFName('FlateDecode')); | |||||||||||||||||||||||||||||||||||||
| 101 | # $char->{' stream'} = $widths[$w->{'ENCODING'}] . ' 0 ' . join(' ', map { int($_) } $self->fontbbox()) . " d1\n"; | ||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $char->{' stream'} = $widths[$w->{'ENCODING'}] . " 0 d0\n"; | |||||||||||||||||||||||||||||||||||||
| 103 | $char->{'Comment'} = PDFStr(join(' ', | ||||||||||||||||||||||||||||||||||||||
| 104 | "N='" . $w->{'NAME'} . "'", | ||||||||||||||||||||||||||||||||||||||
| 105 | 0 | "C=(" . $w->{'ENCODING'} . ")")); | |||||||||||||||||||||||||||||||||||||
| 106 | 0 | $procs->{$w->{'NAME'}} = $char; | |||||||||||||||||||||||||||||||||||||
| 107 | 0 | @bbx = map { $_ * 1000 / $self->data->{'upm'} } @bbx; | |||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if ($y == 0) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $char->{' stream'} .= "q Q\n"; | |||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||
| 111 | else { | ||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $x = 8 * length($stream) / $y; # q $x 0 0 $y 50 50 cm | |||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $dict = join('', | |||||||||||||||||||||||||||||||||||||
| 114 | "/Interpolate true", | ||||||||||||||||||||||||||||||||||||||
| 115 | "/Mask[0 0.1]", | ||||||||||||||||||||||||||||||||||||||
| 116 | "/Decode[1 0]", | ||||||||||||||||||||||||||||||||||||||
| 117 | "/H $y", | ||||||||||||||||||||||||||||||||||||||
| 118 | "/W $x", | ||||||||||||||||||||||||||||||||||||||
| 119 | "/BPC 1", | ||||||||||||||||||||||||||||||||||||||
| 120 | "/CS /G"); | ||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $img = qq|BI\n$dict\nID $stream\nEI\n|; | |||||||||||||||||||||||||||||||||||||
| 122 | 0 | $procs->{$self->data->{'char'}->[$w]} = $char; | |||||||||||||||||||||||||||||||||||||
| 123 | 0 | $char->{' stream'} .= "$bbx[0] 0 0 $bbx[1] $bbx[2] $bbx[3] cm\n"; | |||||||||||||||||||||||||||||||||||||
| 124 | 0 | $char->{' stream'} .= $img . "\n"; | |||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $pdf->new_obj($char); | |||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $procs->{'.notdef'} = $procs->{$self->data->{'char'}->[32]}; | |||||||||||||||||||||||||||||||||||||
| 129 | 0 | delete $procs->{''}; | |||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $self->{'Widths'} = PDFArray(map { PDFNum($widths[$_] or 0) } | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$widths[$_] || 0
MC/DC0%0/1
$widths[$_] || 0
$widths[$_]
Truth table0%0/2
A
A= $widths[$_]
| |||||||||||||||||||||||||||||||||||||||
| 131 | $first .. $last); | ||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $self->data->{'e2n'} = $self->data->{'char'}; | |||||||||||||||||||||||||||||||||||||
| 133 | 0 | $self->data->{'e2u'} = $self->data->{'uni'}; | |||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $self->data->{'u2c'} = {}; | |||||||||||||||||||||||||||||||||||||
| 136 | 0 | $self->data->{'u2e'} = {}; | |||||||||||||||||||||||||||||||||||||
| 137 | 0 | $self->data->{'u2n'} = {}; | |||||||||||||||||||||||||||||||||||||
| 138 | 0 | $self->data->{'n2c'} = {}; | |||||||||||||||||||||||||||||||||||||
| 139 | 0 | $self->data->{'n2e'} = {}; | |||||||||||||||||||||||||||||||||||||
| 140 | 0 | $self->data->{'n2u'} = {}; | |||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $data = $self->data(); | |||||||||||||||||||||||||||||||||||||
| 143 | 0 | foreach my $n (reverse 0 .. 255) { | |||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | $data->{'n2c'}->{$data->{'char'}->[$n] or '.notdef'} //= $n; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$data->{"n2c"}{$data->{"char"}[$n] or ".notdef"} //= $n
$data->{'char'}[$n] || '.notdef'
MC/DC0%0/2
$data->{"n2c"}{$data->{"char"}[$n] or ".notdef"} //= $n
$data->{"n2c"}{$data->{"char"}[$n] or ".notdef"}
$n
MC/DC0%0/1
$data->{'char'}[$n] || '.notdef'
$data->{'char'}[$n]
Truth table0%0/3
A //= B
A= $data->{"n2c"}{$data->{"char"}[$n] or ".notdef"}B= $n
Truth table0%0/2
A
A= $data->{'char'}[$n]
| |||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $data->{'n2e'}->{$data->{'e2n'}->[$n] or '.notdef'} //= $n; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$data->{"n2e"}{$data->{"e2n"}[$n] or ".notdef"} //= $n
$data->{'e2n'}[$n] || '.notdef'
MC/DC0%0/2
$data->{"n2e"}{$data->{"e2n"}[$n] or ".notdef"} //= $n
$data->{"n2e"}{$data->{"e2n"}[$n] or ".notdef"}
$n
MC/DC0%0/1
$data->{'e2n'}[$n] || '.notdef'
$data->{'e2n'}[$n]
Truth table0%0/3
A //= B
A= $data->{"n2e"}{$data->{"e2n"}[$n] or ".notdef"}B= $n
Truth table0%0/2
A
A= $data->{'e2n'}[$n]
| |||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | $data->{'n2u'}->{$data->{'e2n'}->[$n] or '.notdef'} //= $data->{'e2u'}->[$n]; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$data->{"n2u"}{$data->{"e2n"}[$n] or ".notdef"} //= $data->{"e2u"}[$n]
$data->{'e2n'}[$n] || '.notdef'
MC/DC0%0/2
$data->{"n2u"}{$data->{"e2n"}[$n] or ".notdef"} //= $data->{"e2u"}[$n]
$data->{"n2u"}{$data->{"e2n"}[$n] or ".notdef"}
$data->{"e2u"}[$n]
MC/DC0%0/1
$data->{'e2n'}[$n] || '.notdef'
$data->{'e2n'}[$n]
Truth table0%0/3
A //= B
A= $data->{"n2u"}{$data->{"e2n"}[$n] or ".notdef"}B= $data->{"e2u"}[$n]
Truth table0%0/2
A
A= $data->{'e2n'}[$n]
| |||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | $data->{'n2u'}->{$data->{'char'}->[$n] or '.notdef'} //= $data->{'uni'}->[$n]; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$data->{"n2u"}{$data->{"char"}[$n] or ".notdef"} //= $data->{"uni"}[$n]
$data->{'char'}[$n] || '.notdef'
MC/DC0%0/2
$data->{"n2u"}{$data->{"char"}[$n] or ".notdef"} //= $data->{"uni"}[$n]
$data->{"n2u"}{$data->{"char"}[$n] or ".notdef"}
$data->{"uni"}[$n]
MC/DC0%0/1
$data->{'char'}[$n] || '.notdef'
$data->{'char'}[$n]
Truth table0%0/3
A //= B
A= $data->{"n2u"}{$data->{"char"}[$n] or ".notdef"}B= $data->{"uni"}[$n]
Truth table0%0/2
A
A= $data->{'char'}[$n]
| |||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | $data->{'u2c'}->{$data->{'uni'}->[$n]} //= $n; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$data->{"u2c"}{$data->{"uni"}[$n]} //= $n
MC/DC0%0/2
$data->{"u2c"}{$data->{"uni"}[$n]} //= $n
$data->{"u2c"}{$data->{"uni"}[$n]}
$n
Truth table0%0/3
A //= B
A= $data->{"u2c"}{$data->{"uni"}[$n]}B= $n
| |||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | $data->{'u2e'}->{$data->{'e2u'}->[$n]} //= $n; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$data->{"u2e"}{$data->{"e2u"}[$n]} //= $n
MC/DC0%0/2
$data->{"u2e"}{$data->{"e2u"}[$n]} //= $n
$data->{"u2e"}{$data->{"e2u"}[$n]}
$n
Truth table0%0/3
A //= B
A= $data->{"u2e"}{$data->{"e2u"}[$n]}B= $n
| |||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | $data->{'u2n'}->{$data->{'e2u'}->[$n]} //= ($data->{'e2n'}->[$n] or '.notdef'); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$data->{"u2n"}{$data->{"e2u"}[$n]} //= $data->{"e2n"}[$n] || ".notdef"
$data->{'e2n'}[$n] || '.notdef'
MC/DC0%0/2
$data->{"u2n"}{$data->{"e2u"}[$n]} //= $data->{"e2n"}[$n] || ".notdef"
$data->{"u2n"}{$data->{"e2u"}[$n]}
$data->{'e2n'}[$n]
Truth table0%0/3
A //= B
A= $data->{"u2n"}{$data->{"e2u"}[$n]}B= $data->{'e2n'}[$n]
| |||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | $data->{'u2n'}->{$data->{'uni'}->[$n]} //= ($data->{char}->[$n] or '.notdef'); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$data->{"u2n"}{$data->{"uni"}[$n]} //= $data->{"char"}[$n] || ".notdef"
$data->{'char'}[$n] || '.notdef'
MC/DC0%0/2
$data->{"u2n"}{$data->{"uni"}[$n]} //= $data->{"char"}[$n] || ".notdef"
$data->{"u2n"}{$data->{"uni"}[$n]}
$data->{'char'}[$n]
Truth table0%0/3
A //= B
A= $data->{"u2n"}{$data->{"uni"}[$n]}B= $data->{'char'}[$n]
| |||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||
| 157 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||
| 160 | sub readBDF { | ||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | my ($self, $file) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
readBDF: not called CC=25 SCAR=64.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||
| 163 | 0 | $data->{'char'} = []; | |||||||||||||||||||||||||||||||||||||
| 164 | 0 | $data->{'char2'} = []; | |||||||||||||||||||||||||||||||||||||
| 165 | 0 | $data->{'wx'} = {}; | |||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | die "file='$file' doesn't exist" unless -e $file; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | open(my $afmf, '<', $file) or die "Can't find the BDF file for $file"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||
| 170 | 0 | local $/ = "\n"; # ensure correct $INPUT_RECORD_SEPARATOR | |||||||||||||||||||||||||||||||||||||
| 171 | 0 | local $_ = undef; | |||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | while ($_ = <$afmf>) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 173 | 0 | chomp($_); | |||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if (/^STARTCHAR/ .. /^ENDCHAR/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if (/^STARTCHAR\s+(\S+)/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $name = $1; | |||||||||||||||||||||||||||||||||||||
| 177 | 0 | $name =~ s/^(\d+.*)$/X_$1/; | |||||||||||||||||||||||||||||||||||||
| 178 | 0 | push @{$data->{'char2'}}, { 'NAME' => $name }; | |||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||
| 180 | elsif (/^BITMAP/ .. /^ENDCHAR/) { | ||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | next if /^BITMAP/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if (/^ENDCHAR/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | $data->{'char2'}->[-1]->{'NAME'} ||= 'E_' . $data->{'char2'}->[-1]->{'ENCODING'}; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$data->{"char2"}[-1]{"NAME"} ||= 'E_' . $data->{"char2"}[-1]{"ENCODING"}
MC/DC0%0/1
$data->{"char2"}[-1]{"NAME"} ||= 'E_' . $data->{"char2"}[-1]{"ENCODING"}
$data->{"char2"}[-1]{"NAME"}
Truth table0%0/2
A
A= $data->{"char2"}[-1]{"NAME"}
| |||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $data->{'char'}->[$data->{'char2'}->[-1]->{'ENCODING'}] = $data->{'char2'}->[-1]->{'NAME'}; | |||||||||||||||||||||||||||||||||||||
| 185 | 0 | ($data->{'wx'}->{$data->{'char2'}->[-1]->{'NAME'}}) = split(/\s+/, $data->{'char2'}->[-1]->{'SWIDTH'}); | |||||||||||||||||||||||||||||||||||||
| 186 | 0 | $data->{'char2'}->[-1]->{'BBX'} = [split(/\s+/, $data->{'char2'}->[-1]->{'BBX'})]; | |||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||
| 188 | else { | ||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $data->{'char2'}->[-1]->{'hex'} .= $_; | |||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||
| 192 | else { | ||||||||||||||||||||||||||||||||||||||
| 193 | 0 | m/^(\S+)\s+(.+)$/; | |||||||||||||||||||||||||||||||||||||
| 194 | 0 | $data->{'char2'}->[-1]->{uc($1)} .= $2; | |||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||
| 196 | # } elsif (/^STARTPROPERTIES/ .. /^ENDPROPERTIES/) { | ||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||
| 198 | else { | ||||||||||||||||||||||||||||||||||||||
| 199 | 0 | m/^(\S+)\s+(.+)$/; | |||||||||||||||||||||||||||||||||||||
| 200 | 0 | $data->{uc($1)} .= $2; | |||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||
| 203 | 0 | close($afmf); | |||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | unless (exists $data->{'wx'}->{'.notdef'}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $data->{'wx'}->{'.notdef'} = 0; | |||||||||||||||||||||||||||||||||||||
| 206 | 0 | $data->{'bbox'}{'.notdef'} = [0, 0, 0, 0]; | |||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $data->{'fontname'} = pdfkey() . pdfkey() . '~' . time(); | |||||||||||||||||||||||||||||||||||||
| 210 | 0 | $data->{'apiname'} = $data->{'fontname'}; | |||||||||||||||||||||||||||||||||||||
| 211 | 0 | $data->{'flags'} = 34; | |||||||||||||||||||||||||||||||||||||
| 212 | 0 | $data->{'fontbbox'} = [ split(/\s+/, $data->{'FONTBOUNDINGBOX'}) ]; | |||||||||||||||||||||||||||||||||||||
| 213 | $data->{'upm'} = ($data->{'PIXEL_SIZE'} | ||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | or ($data->{'fontbbox'}->[1] - $data->{'fontbbox'}->[3])); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$data->{'PIXEL_SIZE'} || $data->{'fontbbox'}[1] - $data->{'fontbbox'}[3]
MC/DC0%0/2
$data->{'PIXEL_SIZE'} || $data->{'fontbbox'}[1] - $data->{'fontbbox'}[3]
$data->{'PIXEL_SIZE'}
$data->{'fontbbox'}[1] - $data->{'fontbbox'}[3]
Truth table0%0/3
A || B
A= $data->{'PIXEL_SIZE'}B= $data->{'fontbbox'}[1] - $data->{'fontbbox'}[3]
| |||||||||||||||||||||||||||||||||||||||
| 215 | 0 | @{$data->{'fontbbox'}} = (map { int($_ * 1000 / $data->{'upm'}) } | |||||||||||||||||||||||||||||||||||||
| 216 | 0 | @{$data->{'fontbbox'}}); | |||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||
| 218 | 0 | foreach my $n (0 .. 255) { | |||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | $data->{'char'}->[$n] ||= '.notdef'; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$data->{"char"}[$n] ||= ".notdef"
MC/DC0%0/1
$data->{"char"}[$n] ||= ".notdef"
$data->{"char"}[$n]
Truth table0%0/2
A
A= $data->{"char"}[$n]
| |||||||||||||||||||||||||||||||||||||||
| 220 | # $data->{'wx'}->{$data->{'char'}->[$n]} | ||||||||||||||||||||||||||||||||||||||
| 221 | # = int($data->{'wx'}->{$data->{'char'}->[$n]} * 1000 / $data->{'upm'}); | ||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | $data->{'uni'} ||= []; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$data->{"uni"} ||= []
MC/DC0%0/1
$data->{"uni"} ||= []
$data->{"uni"}
Truth table0%0/2
A
A= $data->{"uni"}
| |||||||||||||||||||||||||||||||||||||||
| 225 | 0 | foreach my $n (0 .. 255) { | |||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | $data->{'uni'}->[$n] = uniByName($data->{'char'}->[$n] or '.notdef') || 0; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
uniByName($data->{'char'}[$n] || '.notdef') || 0
$data->{'char'}[$n] || '.notdef'
MC/DC0%0/1
uniByName($data->{'char'}[$n] || '.notdef') || 0
uniByName($data->{'char'}[$n] || '.notdef')
MC/DC0%0/1
$data->{'char'}[$n] || '.notdef'
$data->{'char'}[$n]
Truth table0%0/2
A
A= uniByName($data->{'char'}[$n] || '.notdef')
Truth table0%0/2
A
A= $data->{'char'}[$n]
| |||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||
| 228 | $data->{'ascender'} = $data->{'RAW_ASCENT'} | ||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | || int($data->{'FONT_ASCENT'} * 1000 / $data->{'upm'}); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$data->{'RAW_ASCENT'} || int $data->{'FONT_ASCENT'} * 1000 / $data->{'upm'}
MC/DC0%0/2
$data->{'RAW_ASCENT'} || int $data->{'FONT_ASCENT'} * 1000 / $data->{'upm'}
$data->{'RAW_ASCENT'}
int $data->{'FONT_ASCENT'} * 1000 / $data->{'upm'}
Truth table0%0/3
A || B
A= $data->{'RAW_ASCENT'}B= int $data->{'FONT_ASCENT'} * 1000 / $data->{'upm'}
| |||||||||||||||||||||||||||||||||||||||
| 230 | $data->{'descender'} = $data->{'RAW_DESCENT'} | ||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | || int($data->{'FONT_DESCENT'} * 1000 / $data->{'upm'}); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$data->{'RAW_DESCENT'} || int $data->{'FONT_DESCENT'} * 1000 / $data->{'upm'}
MC/DC0%0/2
$data->{'RAW_DESCENT'} || int $data->{'FONT_DESCENT'} * 1000 / $data->{'upm'}
$data->{'RAW_DESCENT'}
int $data->{'FONT_DESCENT'} * 1000 / $data->{'upm'}
Truth table0%0/3
A || B
A= $data->{'RAW_DESCENT'}B= int $data->{'FONT_DESCENT'} * 1000 / $data->{'upm'}
| |||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $data->{'type'} = 'Type3'; | |||||||||||||||||||||||||||||||||||||
| 234 | 0 | $data->{'capheight'} = 1000; | |||||||||||||||||||||||||||||||||||||
| 235 | 0 | $data->{'iscore'} = 0; | |||||||||||||||||||||||||||||||||||||
| 236 | 0 | $data->{'issymbol'} = 0; | |||||||||||||||||||||||||||||||||||||
| 237 | 0 | $data->{'isfixedpitch'} = 0; | |||||||||||||||||||||||||||||||||||||
| 238 | 0 | $data->{'italicangle'} = 0; | |||||||||||||||||||||||||||||||||||||
| 239 | $data->{'missingwidth'} = $data->{'AVERAGE_WIDTH'} | ||||||||||||||||||||||||||||||||||||||
| 240 | || int($data->{'FONT_AVERAGE_WIDTH'} * 1000 / $data->{'upm'}) | ||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | || $data->{'RAW_AVERAGE_WIDTH'} | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$data->{'AVERAGE_WIDTH'} || int $data->{'FONT_AVERAGE_WIDTH'} * 1000 / $data->{'upm'} || $data->{'RAW_AVERAGE_WIDTH'} || 500
$data->{"AVERAGE_WIDTH"} or int $data->{"FONT_AVERAGE_WIDTH"} * 1000 / $data->{"upm"} or $data->{"RAW_AVERAGE_WIDTH"}
$data->{"AVERAGE_WIDTH"} or int $data->{"FONT_AVERAGE_WIDTH"} * 1000 / $data->{"upm"}
MC/DC0%0/3
$data->{'AVERAGE_WIDTH'} || int $data->{'FONT_AVERAGE_WIDTH'} * 1000 / $data->{'upm'} || $data->{'RAW_AVERAGE_WIDTH'} || 500
$data->{"AVERAGE_WIDTH"}
int $data->{"FONT_AVERAGE_WIDTH"} * 1000 / $data->{"upm"}
$data->{"RAW_AVERAGE_WIDTH"}
Truth table0%0/4
A or B or C
A= $data->{"AVERAGE_WIDTH"}B= int $data->{"FONT_AVERAGE_WIDTH"} * 1000 / $data->{"upm"}C= $data->{"RAW_AVERAGE_WIDTH"}
| |||||||||||||||||||||||||||||||||||||||
| 242 | || 500; | ||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $data->{'underlineposition'} = -200; | |||||||||||||||||||||||||||||||||||||
| 244 | 0 | $data->{'underlinethickness'} = 10; | |||||||||||||||||||||||||||||||||||||
| 245 | $data->{'xheight'} = $data->{'RAW_XHEIGHT'} | ||||||||||||||||||||||||||||||||||||||
| 246 | || int($data->{'FONT_XHEIGHT'} * 1000 / $data->{'upm'}) | ||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | || int($data->{'ascender'} / 2); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$data->{'RAW_XHEIGHT'} || int $data->{'FONT_XHEIGHT'} * 1000 / $data->{'upm'} || int $data->{'ascender'} / 2
$data->{"RAW_XHEIGHT"} or int $data->{"FONT_XHEIGHT"} * 1000 / $data->{"upm"}
MC/DC0%0/3
$data->{'RAW_XHEIGHT'} || int $data->{'FONT_XHEIGHT'} * 1000 / $data->{'upm'} || int $data->{'ascender'} / 2
$data->{"RAW_XHEIGHT"}
int $data->{"FONT_XHEIGHT"} * 1000 / $data->{"upm"}
int $data->{'ascender'} / 2
Truth table0%0/4
A or B || C
A= $data->{"RAW_XHEIGHT"}B= int $data->{"FONT_XHEIGHT"} * 1000 / $data->{"upm"}C= int $data->{'ascender'} / 2
| |||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $data->{'firstchar'} = 1; | |||||||||||||||||||||||||||||||||||||
| 249 | 0 | $data->{'lastchar'} = 255; | |||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||
| 251 | 0 | delete $data->{'wx'}->{''}; | |||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||
| 253 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||
| 256 | =back | ||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||
| 258 | =cut | ||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||
| 260 | 1 | 1; | |||||||||||||||||||||||||||||||||||||