Font-TTF
view release on metacpan or search on metacpan
lib/Font/TTF/Table.pm view on Meta::CPAN
=cut
sub XML_end
{
my ($self, $context, $tag, %attrs) = @_;
my ($dat, $addr);
return undef unless ($tag eq 'data');
$dat = $context->{'text'};
$dat =~ s/([0-9a-f]{2})\s*/hex($1)/oig;
if (defined $attrs{'addr'})
{ $addr = hex($attrs{'addr'}); }
else
{ $addr = length($self->{' dat'}); }
substr($self->{' dat'}, $addr, length($dat)) = $dat;
return $context;
}
=head2 $t->minsize()
Returns the minimum size this table can be. If it is smaller than this, then the table
must be bad and should be deleted or whatever.
=cut
sub minsize
{
return 0;
}
=head2 $t->dirty($val)
This sets the dirty flag to the given value or 1 if no given value. It returns the
value of the flag
=cut
sub dirty
{
my ($self, $val) = @_;
my ($res) = $self->{' isDirty'};
$self->{' isDirty'} = defined $val ? $val : 1;
$res;
}
=head2 $t->update
Each table knows how to update itself. This consists of doing whatever work
is required to ensure that the memory version of the table is consistent
and that other parameters in other tables have been updated accordingly.
I.e. by the end of sending C<update> to all the tables, the memory version
of the font should be entirely consistent.
Some tables which do no work indicate to themselves the need to update
themselves by setting isDirty above 1. This method resets that accordingly.
=cut
sub update
{
my ($self) = @_;
if ($self->{' isDirty'})
{
$self->read;
$self->{' isDirty'} = 0;
return $self;
}
else
{ return undef; }
}
=head2 $t->empty
Clears a table of all data to the level of not having been read
=cut
sub empty
{
my ($self) = @_;
my (%keep);
foreach (qw(INFILE LENGTH OFFSET CSUM PARENT))
{ $keep{" $_"} = 1; }
map {delete $self->{$_} unless $keep{$_}} keys %$self;
$self;
}
=head2 $t->release
Releases ALL of the memory used by this table, and all of its component/child
objects. This method is called automatically by
'Font::TTF::Font-E<gt>release' (so you don't have to call it yourself).
B<NOTE>, that it is important that this method get called at some point prior
to the actual destruction of the object. Internally, we track things in a
structure that can result in circular references, and without calling
'C<release()>' these will not properly get cleaned up by Perl. Once this
method has been called, though, don't expect to be able to do anything with the
C<Font::TTF::Table> object; it'll have B<no> internal state whatsoever.
B<Developer note:> As part of the brute-force cleanup done here, this method
will throw a warning message whenever unexpected key values are found within
the C<Font::TTF::Table> object. This is done to help ensure that any
unexpected and unfreed values are brought to your attention so that you can bug
us to keep the module updated properly; otherwise the potential for memory
leaks due to dangling circular references will exist.
=cut
sub release
{
my ($self) = @_;
# delete stuff that we know we can, here
( run in 0.876 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )