Font-TTF
view release on metacpan or search on metacpan
lib/Font/TTF/EBDT.pm view on Meta::CPAN
# if ($fh->tell != $self->{' OFFSET'} + $offset + $o0) {
# $fh->seek($self->{' OFFSET'} + $offset + $o0, 0);
# }
$fh->read($dat, 8);
($b->{'height'},
$b->{'width'},
$b->{'horiBearingX'},
$b->{'horiBearingY'},
$b->{'horiAdvance'},
$b->{'vertBearingX'},
$b->{'vertBearingY'},
$b->{'vertAdvance'})
= unpack("cccccccc", $dat);
$fh->read($dat, $len);
$b->{'imageData'} = $dat;
$b->{'format'} = 7; # bitmap and bigMetrics
$bitmap->{$c} = $b;
$o0 = $o1;
}
$offset += $o0;
}
}
$self;
}
=head2 $t->update
Update EBLC information using EBDT data.
=cut
sub get_regions
{
my (@l) = @_;
my (@r) = ();
my ($e);
my ($first);
my ($last);
$first = $l[0];
$last = $first - 1;
foreach $e (@l) {
if ($last + 1 != $e) { # not contiguous
$r[++$#r] = [$first, $last];
$first = $e;
}
$last = $e;
}
$r[++$#r] = [$first, $last];
@r;
}
sub update
{
my ($self) = @_;
my ($eblc) = $self->{' PARENT'}->{'EBLC'};
my ($bst_array) = [];
my ($offset) = 4;
my ($i);
my ($bitmap_array) = $self->{'bitmap'};
my ($istao) = 8 + 48 * $eblc->{'Num'};
$eblc->{'bitmapSizeTable'} = $bst_array;
for ($i = 0; $i < $eblc->{'Num'}; $i++) {
my ($bst) = {};
my ($ist_array) = [];
my ($j);
my ($bitmap) = $bitmap_array->[$i];
my (@regions) = get_regions(sort {$a <=> $b} keys (%$bitmap));
my ($aotis) = 8 * (1+$#regions);
$bst->{'indexFormat'} = 1;
$bst->{'imageFormat'} = 7;
$bst->{'imageDataOffset'} = $offset;
$bst->{'numberOfIndexSubTables'} = 1+$#regions;
$bst->{'indexSubTableArrayOffset'} = $istao;
$bst->{'colorRef'} = 0;
$bst->{'startGlyphIndex'} = $regions[0][0];
$bst->{'endGlyphIndex'} = $regions[-1][1];
$bst->{'bitDepth'} = 1;
$bst->{'flags'} = 1; # Horizontal
$bst_array->[$i] = $bst;
$eblc->{'indexSubTableArray'}[$i] = $ist_array;
for ($j = 0; $j <= $#regions; $j++) {
my ($ista) = {};
my ($offsetArray) = [];
my ($p, $o0, $c);
$ist_array->[$j] = $ista;
$ista->{'firstGlyphIndex'} = $regions[$j][0];
$ista->{'lastGlyphIndex'} = $regions[$j][1];
$ista->{'additionalOffsetToIndexSubtable'} = $aotis;
$eblc->{'indexSubTable'}[$i][$j] = $offsetArray;
$p = 0;
$o0 = 0;
for ($c = $regions[$j][0]; $c <= $regions[$j][1]; $c++) {
my ($b) = $bitmap->{$c};
$offsetArray->[$p++] = $o0;
$o0 += 8 + length($b->{'imageData'});
}
$offsetArray->[$p++] = $o0;
$aotis += ($regions[$j][1] - $regions[$j][0] + 1 + 1)*4;
$offset += $o0;
# Do we need the element of 0x10007 and absolute offset here,
# at the end of offsetArray?
# if ($j + 1 <= $#regions) {
( run in 2.709 seconds using v1.01-cache-2.11-cpan-140bd7fdf52 )