1 package Font::TTF::Bsln;
5 Font::TTF::Bsln - Baseline table in a font
9 =head1 INSTANCE VARIABLES
34 use Font::TTF::AATutils;
36 require Font::TTF::Table;
38 @ISA = qw(Font::TTF::Table);
42 Reads the table into memory
51 $self->SUPER::read or return $self;
53 $fh = $self->{' INFILE'};
55 my ($version, $format, $defaultBaseline) = TTF_Unpack("vSS", $dat);
57 if ($format == 0 or $format == 1) {
59 $self->{'deltas'} = [TTF_Unpack("s*", $dat)];
61 elsif ($format == 2 or $format == 3) {
63 $self->{'stdGlyph'} = unpack("n", $dat);
65 $self->{'ctlPoints'} = unpack("n*", $dat);
68 die "unknown table format";
71 if ($format == 1 or $format == 3) {
72 my $len = $self->{' LENGTH'} - ($fh->tell() - $self->{' OFFSET'});
73 my ($lookupFormat, $lookup) = AAT_read_lookup($fh, 2, $len, $defaultBaseline);
74 $self->{'lookupFormat'} = $lookupFormat;
75 $self->{'lookup'} = $lookup;
78 $self->{'version'} = $version;
79 $self->{'format'} = $format;
80 $self->{'defaultBaseline'} = $defaultBaseline;
87 Writes the table to a file either from memory or by copying
95 return $self->SUPER::out($fh) unless $self->{' read'};
97 my $format = $self->{'format'};
98 my $defaultBaseline = $self->{'defaultBaseline'};
99 $fh->print(TTF_Pack("vSS", $self->{'version'}, $format, $defaultBaseline));
101 AAT_write_lookup($fh, $self->{'lookupFormat'}, $self->{'lookup'}, 2, $defaultBaseline) if ($format == 1 or $format == 3);
104 =head2 $t->print($fh)
106 Prints a human-readable representation of the table
112 my ($self, $fh) = @_;
116 $fh = 'STDOUT' unless defined $fh;
118 my $format = $self->{'format'};
119 $fh->printf("version %f\nformat %d\ndefaultBaseline %d\n", $self->{'version'}, $format, $self->{'defaultBaseline'});
120 if ($format == 0 or $format == 1) {
121 $fh->printf("\tdeltas:\n");
122 my $deltas = $self->{'deltas'};
124 $fh->printf("\t\t%d: %d%s\n", $_, $deltas->[$_], defined baselineName_($_) ? "\t# " . baselineName_($_) : "");
127 if ($format == 2 or $format == 3) {
128 $fh->printf("\tstdGlyph = %d\n", $self->{'stdGlyph'});
129 my $ctlPoints = $self->{'ctlPoints'};
131 $fh->printf("\t\t%d: %d%s\n", $_, $ctlPoints->[$_], defined baselineName_($_) ? "\t# " . baselineName_($_) : "");
134 if ($format == 1 or $format == 3) {
135 $fh->printf("lookupFormat %d\n", $self->{'lookupFormat'});
136 my $lookup = $self->{'lookup'};
137 foreach (sort { $a <=> $b } keys %$lookup) {
138 $fh->printf("\tglyph %d: %d%s\n", $_, $lookup->{$_}, defined baselineName_($_) ? "\t# " . baselineName_($_) : "");
146 my @baselines = ( 'Roman', 'Ideographic centered', 'Ideographic low', 'Hanging', 'Math' );
159 Jonathan Kew L<Jonathan_Kew@sil.org>. See L<Font::TTF::Font> for copyright and