1 package Font::TTF::Sill;
5 Font::TTF::Sill - Graphite language mapping table
9 =head1 INSTANCE VARIABLES
19 Contains a hash where the key is the language id and the value is an array of
24 =head2 Language Records
26 Each language record is itself an array of two values [fid, val]. fid is the
27 feature id and is held as a long.
32 require Font::TTF::Table;
34 @ISA = qw(Font::TTF::Table);
41 return $self if ($self->{' read'});
42 $self->SUPER::read_dat or return $self;
44 ($self->{'version'}, $num) = TTF_Unpack("vS", $self->{' dat'});
46 foreach $i (1 .. $num) # ignore bogus entry at end
48 my ($lid, $numf, $offset) = unpack("A4nn", substr($self->{' dat'}, $i * 8 + 4)); # 12 - 8 = 4 since i starts at 1. A4 strips nulls
51 foreach $j (1 .. $numf)
53 my ($fid, $val) = TTF_Unpack("Ls", substr($self->{' dat'}, $offset + $j * 8 - 8));
54 push (@settings, [$fid, $val]);
56 $self->{'langs'}{$lid} = [@settings];
58 delete $self->{' dat'};
66 my ($num, $range, $select, $shift) = TTF_bininfo(scalar keys %{$self->{'langs'}}, 1);
67 my ($offset) = $num * 8 + 20; #header = 12, dummy = 8
70 return $self->SUPER::out($fh) unless ($self->{' read'});
71 $fh->print(TTF_Pack("vSSSS", $self->{'version'}, $num, $range, $select, $shift));
72 foreach $k (sort (keys %{$self->{'langs'}}), '+1')
74 my ($numf) = scalar @{$self->{'langs'}{$k}} unless ($k eq '+1');
75 $fh->print(pack("a4nn", $k, $numf, $offset));
79 foreach $k (sort keys %{$self->{'langs'}})
81 foreach $s (@{$self->{'langs'}{$k}})
82 { $fh->print(TTF_Pack("LsS", @{$s}, 0)); }
90 my ($context, $depth, $key, $dat) = @_;
91 my ($fh) = $context->{'fh'};
94 return $self->SUPER::XML_element(@_) unless ($key eq 'langs');
95 foreach $k (sort keys %{$self->{'langs'}})
97 $fh->printf("%s<lang id='%s'>\n", $depth, $k);
98 foreach $s (@{$self->{'langs'}{$k}})
101 if ($fid > 0x00FFFFFF)
102 { $fid = unpack("A4", pack ("N", $fid)); }
104 { $fid = sprintf("%d", $fid); }
105 $fh->printf("%s%s<feature id='%s' value='%d'/>\n",
106 $depth, $context->{'indent'}, $fid, $s->[1]);
108 $fh->printf("%s</lang>\n", $depth);