| 1 | package Font::TTF::Hhea; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | Font::TTF::Hhea - Horizontal Header table | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | This is a simplte table with just standards specified instance variables | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 INSTANCE VARIABLES | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | version | ||||||||||||||||||||||||||||
| 14 | Ascender | ||||||||||||||||||||||||||||
| 15 | Descender | ||||||||||||||||||||||||||||
| 16 | LineGap | ||||||||||||||||||||||||||||
| 17 | advanceWidthMax | ||||||||||||||||||||||||||||
| 18 | minLeftSideBearing | ||||||||||||||||||||||||||||
| 19 | minRightSideBearing | ||||||||||||||||||||||||||||
| 20 | xMaxExtent | ||||||||||||||||||||||||||||
| 21 | caretSlopeRise | ||||||||||||||||||||||||||||
| 22 | caretSlopeRun | ||||||||||||||||||||||||||||
| 23 | metricDataFormat | ||||||||||||||||||||||||||||
| 24 | numberOfHMetrics | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =head1 METHODS | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | use vars qw(@ISA %fields @field_info); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 1 | require Font::TTF::Table; | |||||||||||||||||||||||||||
| 35 | 1 | ▶ | use Font::TTF::Utils; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 1 | @ISA = qw(Font::TTF::Table); | |||||||||||||||||||||||||||
| 38 | 1 | @field_info = ( | |||||||||||||||||||||||||||
| 39 | 'version' => 'v', | ||||||||||||||||||||||||||||
| 40 | 'Ascender' => 's', | ||||||||||||||||||||||||||||
| 41 | 'Descender' => 's', | ||||||||||||||||||||||||||||
| 42 | 'LineGap' => 's', | ||||||||||||||||||||||||||||
| 43 | 'advanceWidthMax' => 'S', | ||||||||||||||||||||||||||||
| 44 | 'minLeftSideBearing' => 's', | ||||||||||||||||||||||||||||
| 45 | 'minRightSideBearing' => 's', | ||||||||||||||||||||||||||||
| 46 | 'xMaxExtent' => 's', | ||||||||||||||||||||||||||||
| 47 | 'caretSlopeRise' => 's', | ||||||||||||||||||||||||||||
| 48 | 'caretSlopeRun' => 's', | ||||||||||||||||||||||||||||
| 49 | 'metricDataFormat' => '+10s', | ||||||||||||||||||||||||||||
| 50 | 'numberOfHMetrics' => 'S'); | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | sub init | ||||||||||||||||||||||||||||
| 53 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | 1 | my ($k, $v, $c, $i); | |||||||||||||||||||||||||||
| 55 | 1 | ▶ | for ($i = 0; $i < $#field_info; $i += 2) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||
| 57 | 12 | ($k, $v, $c) = TTF_Init_Fields($field_info[$i], $c, $field_info[$i + 1]); | |||||||||||||||||||||||||||
| 58 | 12 | ▶ | next unless defined $k && $k ne ""; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $k and $k ne ""
MC/DC0%0/2
defined $k and $k ne ""
defined $k
$k ne ""
Truth table33%1/3
A and B
A= defined $kB= $k ne ""
| |||||||||||||||||||||||||||||
| 59 | 12 | $fields{$k} = $v; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =head2 $t->read | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | Reads the table into memory as instance variables | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =cut | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | sub read | ||||||||||||||||||||||||||||
| 71 | 6 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
read: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||
| 73 | 6 | my ($dat); | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 6 | ▶ | $self->SUPER::read or return $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 2 | ▶ | init unless defined $fields{'Ascender'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 2 | $self->{' INFILE'}->read($dat, 36); | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 2 | TTF_Read_Fields($self, $dat, \%fields); | |||||||||||||||||||||||||||
| 80 | 2 | $self; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =head2 $t->out($fh) | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | Writes the table to a file either from memory or by copying. | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =cut | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | sub out | ||||||||||||||||||||||||||||
| 91 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
out: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||
| 92 | 2 | my ($self, $fh) = @_; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 2 | ▶ | return $self->SUPER::out($fh) unless $self->{' read'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 2 | ▶ | $self->{'numberOfHMetrics'} = $self->{' PARENT'}{'hmtx'}->numMetrics || $self->{'numberOfHMetrics'}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->{' PARENT'}{'hmtx'}->numMetrics || $self->{'numberOfHMetrics'}
MC/DC0%0/2
$self->{' PARENT'}{'hmtx'}->numMetrics || $self->{'numberOfHMetrics'}
$self->{' PARENT'}{'hmtx'}->numMetrics
$self->{'numberOfHMetrics'}
Truth table33%1/3
A || B
A= $self->{' PARENT'}{'hmtx'}->numMetricsB= $self->{'numberOfHMetrics'}
| |||||||||||||||||||||||||||||
| 97 | 2 | $fh->print(TTF_Out_Fields($self, \%fields, 36)); | |||||||||||||||||||||||||||
| 98 | 2 | $self; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =head2 $t->minsize() | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | Returns the minimum size this table can be. If it is smaller than this, then the table | ||||||||||||||||||||||||||||
| 105 | must be bad and should be deleted or whatever. | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | =cut | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | sub minsize | ||||||||||||||||||||||||||||
| 110 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
minsize: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 111 | 0 | return 36; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | =head2 $t->update | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | Updates various parameters in the hhea table from the hmtx table. | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | sub update | ||||||||||||||||||||||||||||
| 122 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
update: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||
| 123 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 124 | 0 | my ($hmtx) = $self->{' PARENT'}{'hmtx'}; | |||||||||||||||||||||||||||
| 125 | 0 | my ($glyphs); | |||||||||||||||||||||||||||
| 126 | 0 | my ($num, $res); | |||||||||||||||||||||||||||
| 127 | 0 | my ($i, $maw, $mlsb, $mrsb, $mext, $aw, $lsb, $ext); | |||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | ▶ | return undef unless ($self->SUPER::update); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 0 | ▶ | return undef unless (defined $hmtx && defined $self->{' PARENT'}{'loca'}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $hmtx and defined $self->{" PARENT"}{"loca"}
MC/DC0%0/2
defined $hmtx and defined $self->{" PARENT"}{"loca"}
defined $hmtx
defined $self->{" PARENT"}{"loca"}
Truth table0%0/3
A and B
A= defined $hmtxB= defined $self->{" PARENT"}{"loca"}
| |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 0 | $hmtx->read->update; | |||||||||||||||||||||||||||
| 133 | 0 | $self->{' PARENT'}{'loca'}->read->update; | |||||||||||||||||||||||||||
| 134 | 0 | $glyphs = $self->{' PARENT'}{'loca'}{'glyphs'}; | |||||||||||||||||||||||||||
| 135 | 0 | $num = $self->{' PARENT'}{'maxp'}{'numGlyphs'}; | |||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 0 | ▶ | for ($i = 0; $i < $num; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | { | ||||||||||||||||||||||||||||
| 139 | 0 | $aw = $hmtx->{'advance'}[$i]; | |||||||||||||||||||||||||||
| 140 | 0 | $lsb = $hmtx->{'lsb'}[$i]; | |||||||||||||||||||||||||||
| 141 | 0 | ▶ | if (defined $glyphs->[$i]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 0 | { $ext = $lsb + $glyphs->[$i]->read->{'xMax'} - $glyphs->[$i]{'xMin'}; } | |||||||||||||||||||||||||||
| 143 | else | ||||||||||||||||||||||||||||
| 144 | 0 | { $ext = $aw; } | |||||||||||||||||||||||||||
| 145 | 0 | ▶ | $maw = $aw if ($aw > $maw); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 0 | ▶ | $mlsb = $lsb if ($lsb < $mlsb or $i == 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$lsb < $mlsb or $i == 0
MC/DC0%0/2
$lsb < $mlsb or $i == 0
$lsb < $mlsb
$i == 0
Truth table0%0/3
A or B
A= $lsb < $mlsbB= $i == 0
| |||||||||||||||||||||||||||||
| 147 | 0 | ▶ | $mrsb = $aw - $ext if ($aw - $ext < $mrsb or $i == 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$aw - $ext < $mrsb or $i == 0
MC/DC0%0/2
$aw - $ext < $mrsb or $i == 0
$aw - $ext < $mrsb
$i == 0
Truth table0%0/3
A or B
A= $aw - $ext < $mrsbB= $i == 0
| |||||||||||||||||||||||||||||
| 148 | 0 | ▶ | $mext = $ext if ($ext > $mext); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | 0 | $self->{'advanceWidthMax'} = $maw; | |||||||||||||||||||||||||||
| 151 | 0 | $self->{'minLeftSideBearing'} = $mlsb; | |||||||||||||||||||||||||||
| 152 | 0 | $self->{'minRightSideBearing'} = $mrsb; | |||||||||||||||||||||||||||
| 153 | 0 | $self->{'xMaxExtent'} = $mext; | |||||||||||||||||||||||||||
| 154 | 0 | $self->{'numberOfHMetrics'} = $hmtx->numMetrics; | |||||||||||||||||||||||||||
| 155 | 0 | $self; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 1 | 1; | |||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =head1 BUGS | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | None known | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | Martin Hosken L<http://scripts.sil.org/FontUtils>. | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | =head1 LICENSING | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | Copyright (c) 1998-2016, SIL International (http://www.sil.org) | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | This module is released under the terms of the Artistic License 2.0. | ||||||||||||||||||||||||||||
| 176 | For details, see the full text of the license in the file LICENSE. | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | =cut | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||