Introduce src dir.
[librarian.git] / src / librarian / font-optimizer / ext / Font-TTF / lib / Font / TTF / Prep.pm
1 package Font::TTF::Prep;
2
3 =head1 NAME
4
5 Font::TTF::Prep - Preparation hinting program. Called when ppem changes
6
7 =head1 DESCRIPTION
8
9 This is a minimal class adding nothing beyond a table, but is a repository
10 for prep type information for those processes brave enough to address hinting.
11
12 =cut
13
14 use strict;
15 use vars qw(@ISA $VERSION);
16 use Font::TTF::Utils;
17
18 @ISA = qw(Font::TTF::Table);
19
20 $VERSION = 0.0001;
21
22
23 =head2 $t->read
24
25 Reads the data using C<read_dat>.
26
27 =cut
28
29 sub read
30 {
31     $_[0]->read_dat;
32     $_[0]->{' read'} = 1;
33 }
34
35
36 =head2 $t->out_xml($context, $depth)
37
38 Outputs Prep program as XML
39
40 =cut
41
42 sub out_xml
43 {
44     my ($self, $context, $depth) = @_;
45     my ($fh) = $context->{'fh'};
46     my ($dat);
47
48     $self->read;
49     $dat = Font::TTF::Utils::XML_binhint($self->{' dat'});
50     $dat =~ s/\n(?!$)/\n$depth$context->{'indent'}/omg;
51     $fh->print("$depth<code>\n");
52     $fh->print("$depth$context->{'indent'}$dat");
53     $fh->print("$depth</code>\n");
54     $self;
55 }
56     
57
58 =head2 $t->XML_end($context, $tag, %attrs)
59
60 Parse all that hinting code
61
62 =cut
63
64 sub XML_end
65 {
66     my ($self) = shift;
67     my ($context, $tag, %attrs) = @_;
68
69     if ($tag eq 'code')
70     {
71         $self->{' dat'} = Font::TTF::Utils::XML_hintbin($context->{'text'});
72         return $context;
73     } else
74     { return $self->SUPER::XML_end(@_); }
75 }
76
77 1;
78
79 =head1 BUGS
80
81 None known
82
83 =head1 AUTHOR
84
85 Martin Hosken Martin_Hosken@sil.org. See L<Font::TTF::Font> for copyright and
86 licensing.
87
88 =cut
89