| 1 | package Font::TTF::Kern::OrderedList; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Font::TTF::Kern::OrderedList - Ordered List Kern subtable for AAT | ||
| 6 | |||
| 7 | =head1 METHODS | ||
| 8 | |||
| 9 | =cut | ||
| 10 | |||
| 11 | use strict; | ||
| 12 | use vars qw(@ISA); | ||
| 13 | use Font::TTF::Utils; | ||
| 14 | use Font::TTF::AATutils; | ||
| 15 | |||
| 16 | @ISA = qw(Font::TTF::Kern::Subtable); | ||
| 17 | |||
| 18 | sub new | ||
| 19 | { | ||
| 20 | my ($class, @options) = @_; | ||
| 21 | my ($self) = {}; | ||
| 22 | |||
| 23 | $class = ref($class) || $class; | ||
| 24 | bless $self, $class; | ||
| 25 | } | ||
| 26 | |||
| 27 | =head2 $t->read | ||
| 28 | |||
| 29 | Reads the table into memory | ||
| 30 | |||
| 31 | =cut | ||
| 32 | |||
| 33 | sub read | ||
| 34 | { | ||
| 35 | my ($self, $fh) = @_; | ||
| 36 | |||
| 37 | my $dat; | ||
| 38 | $fh->read($dat, 8); | ||
| 39 | my ($nPairs, $searchRange, $entrySelector, $rangeShift) = unpack("nnnn", $dat); | ||
| 40 | |||
| 41 | my $pairs = []; | ||
| 42 | foreach (1 .. $nPairs) { | ||
| 43 | $fh->read($dat, 6); | ||
| 44 | my ($left, $right, $kern) = TTF_Unpack("SSs", $dat); | ||
| 45 | push @$pairs, { 'left' => $left, 'right' => $right, 'kern' => $kern } if $kern != 0; | ||
| 46 | } | ||
| 47 | |||
| 48 | $self->{'kernPairs'} = $pairs; | ||
| 49 | |||
| 50 | $self; | ||
| 51 | } | ||
| 52 | |||
| 53 | =head2 $t->out_sub($fh) | ||
| 54 | |||
| 55 | Writes the table to a file | ||
| 56 | |||
| 57 | =cut | ||
| 58 | |||
| 59 | sub out_sub | ||
| 60 | { | ||
| 61 | my ($self, $fh) = @_; | ||
| 62 | |||
| 63 | my $pairs = $self->{'kernPairs'}; | ||
| 64 | $fh->print(pack("nnnn", TTF_bininfo(scalar @$pairs, 6))); | ||
| 65 | |||
| 66 | foreach (sort { $a->{'left'} <=> $b->{'left'} or $a->{'right'} <=> $b->{'right'} } @$pairs) { | ||
| 67 | $fh->print(TTF_Pack("SSs", $_->{'left'}, $_->{'right'}, $_->{'kern'})); | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 71 | =head2 $t->print($fh) | ||
| 72 | |||
| 73 | Prints a human-readable representation of the table | ||
| 74 | |||
| 75 | =cut | ||
| 76 | |||
| 77 | sub out_xml | ||
| 78 | { | ||
| 79 | my ($self, $context, $depth, $k, $val) = @_; | ||
| 80 | my ($fh) = $context->{'fh'}; | ||
| 81 | |||
| 82 | my $postVal = $self->post()->{'VAL'}; | ||
| 83 | |||
| 84 | $fh = 'STDOUT' unless defined $fh; | ||
| 85 | foreach (@{$self->{'kernPairs'}}) { | ||
| 86 | $fh->printf("$depth$context->{'indent'}<pair l=\"%s\" r=\"%s\" v=\"%s\"/>\n", $postVal->[$_->{'left'}], $postVal->[$_->{'right'}], $_->{'kern'}); | ||
| 87 | } | ||
| 88 | } | ||
| 89 | |||
| 90 | |||
| 91 | sub type | ||
| 92 | { | ||
| 93 | return 'kernOrderedList'; | ||
| 94 | } | ||
| 95 | |||
| 96 | |||
| 97 | 1; | ||
| 98 | |||
| 99 | =head1 BUGS | ||
| 100 | |||
| 101 | None known | ||
| 102 | |||
| 103 | =head1 AUTHOR | ||
| 104 | |||
| 105 | Jonathan Kew L<http://scripts.sil.org/FontUtils>. | ||
| 106 | |||
| 107 | |||
| 108 | =head1 LICENSING | ||
| 109 | |||
| 110 | Copyright (c) 1998-2016, SIL International (http://www.sil.org) | ||
| 111 | |||
| 112 | This module is released under the terms of the Artistic License 2.0. | ||
| 113 | For details, see the full text of the license in the file LICENSE. | ||
| 114 | |||
| 115 | |||
| 116 | |||
| 117 | =cut | ||
| 118 |