1 package Font::TTF::EBLC;
5 Font::TTF::EBLC - Embeeded Bitmap Location Table
9 Contains the sizes and glyph ranges of bitmaps, and the offsets to
10 glyph bitmap data in indexSubTables for EBDT.
12 Possibly contains glyph metrics information.
14 =head1 INSTANCE VARIABLES
15 The information specified 'B<(R)>ead only' is read only, those
16 are calculated from EBDT, when it is 'update'-ed.
21 An array of tables of following information
24 =item indexSubTableArrayOffset (R)
25 =item indexTablesSize (R)
26 =item numberOfIndexSubTables (R)
30 =item startGlyphIndex (R)
31 =item endGlyphIndex (R)
38 =item indexSubTableArray (R)
39 An array which contains range information.
41 =item indexSubTable (R)
42 An array which contains offsets of EBDT table.
52 require Font::TTF::Table;
54 @ISA = qw(Font::TTF::Table);
59 Reads the location information of embedded bitmap from the TTF file into memory
66 my ($fh) = $self->{' INFILE'};
68 my ($indexSubTableArrayOffset,
70 $numberOfIndexSubTables,
77 my ($bst, $ista, $ist);
80 $self->SUPER::read or return $self;
84 $self->{'version'} = unpack("N",$dat);
87 $self->{'Num'} = unpack("N",$dat);
90 for ($i = 0; $i < $self->{'Num'}; $i++) {
92 ($indexSubTableArrayOffset, $indexTablesSize,
93 $numberOfIndexSubTables, $colorRef) = unpack("NNNN", $dat);
94 $fh->read($dat, 12); @hori = unpack("cccccccccccc", $dat);
95 $fh->read($dat, 12); @vert = unpack("cccccccccccc", $dat);
98 ($startGlyphIndex, $endGlyphIndex,
99 $ppemX, $ppemY, $bitDepth, $flags) = unpack("nnCCCC", $dat);
101 $self->{'bitmapSizeTable'}[$i] = {
102 'indexSubTableArrayOffset' => $indexSubTableArrayOffset,
103 'indexTablesSize' => $indexTablesSize,
104 'numberOfIndexSubTables' => $numberOfIndexSubTables,
105 'colorRef' => $colorRef,
108 'startGlyphIndex' => $startGlyphIndex,
109 'endGlyphIndex' => $endGlyphIndex,
112 'bitDepth' => $bitDepth,
117 for ($i = 0; $i < $self->{'Num'}; $i++) {
120 $bst = $self->{'bitmapSizeTable'}[$i];
122 for ($j = 0; $j < $bst->{'numberOfIndexSubTables'}; $j++) {
126 $self->{'indexSubTableArray'}[$i][$j] = $ista;
128 ($ista->{'firstGlyphIndex'},
129 $ista->{'lastGlyphIndex'},
130 $ista->{'additionalOffsetToIndexSubtable'})
131 = unpack("nnN", $dat);
137 ($bst->{'indexFormat'},
138 $bst->{'imageFormat'},
139 $bst->{'imageDataOffset'}) = unpack("nnN", $dat);
141 die "Only indexFormat == 1 is supported" unless ($bst->{'indexFormat'} == 1);
143 for ($j = 0; $j < $bst->{'numberOfIndexSubTables'}; $j++) {
144 $ista = $self->{'indexSubTableArray'}[$i][$j];
145 $count = $ista->{'lastGlyphIndex'} - $ista->{'firstGlyphIndex'} + 1 + 1;
146 $fh->seek($self->{' OFFSET'} + $bst->{'indexSubTableArrayOffset'}
147 + $ista->{'additionalOffsetToIndexSubtable'} + 8, 0);
149 # $count += 2 if $j < $bst->{'numberOfIndexSubTables'} - 1;
151 $fh->read($dat, 4*$count);
153 $self->{'indexSubTable'}[$i][$j] = [unpack("N*", $dat)];
162 Outputs the location information of embedded bitmap for this font.
168 my ($self, $fh) = @_;
170 my ($bst_array) = $self->{'bitmapSizeTable'};
172 $fh->print(pack("N", 0x00020000));
173 $fh->print(pack("N", $self->{'Num'}));
175 for ($i = 0; $i < $self->{'Num'}; $i++) {
176 my ($bst) = $bst_array->[$i];
178 $fh->print(pack("NNNN",
179 $bst->{'indexSubTableArrayOffset'},
180 $bst->{'indexTablesSize'},
181 $bst->{'numberOfIndexSubTables'},
182 $bst->{'colorRef'}));
183 $fh->print(pack("cccccccccccc", @{$bst->{'hori'}}));
184 $fh->print(pack("cccccccccccc", @{$bst->{'vert'}}));
185 $fh->print(pack("nnCCCC", $bst->{'startGlyphIndex'},
186 $bst->{'endGlyphIndex'}, $bst->{'ppemX'},
187 $bst->{'ppemY'}, $bst->{'bitDepth'}, $bst->{'flags'}));
190 for ($i = 0; $i < $self->{'Num'}; $i++) {
191 my ($bst) = $bst_array->[$i];
194 for ($j = 0; $j < $bst->{'numberOfIndexSubTables'}; $j++) {
195 my ($ista) = $self->{'indexSubTableArray'}[$i][$j];
198 $ista->{'firstGlyphIndex'},
199 $ista->{'lastGlyphIndex'},
200 $ista->{'additionalOffsetToIndexSubtable'});
203 $fh->print(pack("nnN", $bst->{'indexFormat'}, $bst->{'imageFormat'},
204 $bst->{'imageDataOffset'}));
206 die "Only indexFormat == 1 is supported" unless ($bst->{'indexFormat'} == 1);
208 for ($j = 0; $j < $bst->{'numberOfIndexSubTables'}; $j++) {
209 $fh->print(pack("N*", $self->{'indexSubTable'}[$i][$j]));
218 Only indexFormat ==1 is implemented. XML output is not supported (yet).
222 NIIBE Yutaka L<gniibe@fsij.org>. See L<Font::TTF::Font> for copyright and
225 This was written at the CodeFest Akihabara 2006 hosted by FSIJ.