<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Font::TTF::Prop;

=head1 NAME

Font::TTF::Prop - Glyph Properties table in a font

=head1 DESCRIPTION

=head1 INSTANCE VARIABLES

=item version

=item default

=item lookup

Hash of property values keyed by glyph number

=item lookupFormat

=head1 METHODS

=cut

use strict;
use vars qw(@ISA);
use Font::TTF::Utils;
use Font::TTF::AATutils;
use Font::TTF::Segarr;

@ISA = qw(Font::TTF::Table);

=head2 $t-&gt;read

Reads the table into memory

=cut

sub read
{
    my ($self) = @_;
    my ($dat, $fh);
    my ($version, $lookupPresent, $default);
    
    $self-&gt;SUPER::read or return $self;

    $fh = $self-&gt;{' INFILE'};
    $fh-&gt;read($dat, 8);
    ($version, $lookupPresent, $default) = TTF_Unpack("vSS", $dat);

    if ($lookupPresent) {
        my ($format, $lookup) = AAT_read_lookup($fh, 2, $self-&gt;{' LENGTH'} - 8, $default);
        $self-&gt;{'lookup'} = $lookup;
        $self-&gt;{'format'} = $format;
    }

    $self-&gt;{'version'} = $version;
    $self-&gt;{'default'} = $default;

    $self;
}


=head2 $t-&gt;out($fh)

Writes the table to a file either from memory or by copying

=cut

sub out
{
    my ($self, $fh) = @_;
    my ($default, $lookup);
    
    return $self-&gt;SUPER::out($fh) unless $self-&gt;{' read'};

    $default = $self-&gt;{'default'};
    $lookup = $self-&gt;{'lookup'};
    $fh-&gt;print(TTF_Pack("vSS", $self-&gt;{'version'}, (defined $lookup ? 1 : 0), $default));

    AAT_write_lookup($fh, $self-&gt;{'format'}, $lookup, 2, $default) if (defined $lookup);
}

=head2 $t-&gt;print($fh)

Prints a human-readable representation of the table

=cut

sub print
{
    my ($self, $fh) = @_;
    my ($lookup);
    
    $self-&gt;read;
    
    $fh = 'STDOUT' unless defined $fh;

    $fh-&gt;printf("version %f\ndefault %04x # %s\n", $self-&gt;{'version'}, $self-&gt;{'default'}, meaning_($self-&gt;{'default'}));
    $lookup = $self-&gt;{'lookup'};
    if (defined $lookup) {
        $fh-&gt;printf("format %d\n", $self-&gt;{'format'});
        foreach (sort { $a &lt;=&gt; $b } keys %$lookup) {
            $fh-&gt;printf("\t%d -&gt; %04x # %s\n", $_, $lookup-&gt;{$_}, meaning_($lookup-&gt;{$_}));
        }
    }
}

sub meaning_
{
    my ($val) = @_;
    my ($res);
    
    my @types = (
        "Strong left-to-right",
        "Strong right-to-left",
        "Arabic letter",
        "European number",
        "European number separator",
        "European number terminator",
        "Arabic number",
        "Common number separator",
        "Block separator",
        "Segment separator",
        "Whitespace",
        "Other neutral");
    $res = $types[$val &amp; 0x001f] or ("Undefined [" . ($val &amp; 0x001f) . "]");
    
    $res .= ", floater" if $val &amp; 0x8000;
    $res .= ", hang left" if $val &amp; 0x4000;
    $res .= ", hang right" if $val &amp; 0x2000;
    $res .= ", attaches on right" if $val &amp; 0x0080;
    $res .= ", pair" if $val &amp; 0x1000;
    my $pairOffset = ($val &amp; 0x0f00) &gt;&gt; 8;
    $pairOffset = $pairOffset - 16 if $pairOffset &gt; 7;
    $res .= $pairOffset &gt; 0 ? " +" . $pairOffset : $pairOffset &lt; 0 ? " " . $pairOffset : "";
    
    $res;
}

1;


=head1 BUGS

None known

=head1 AUTHOR

Jonathan Kew L&lt;Jonathan_Kew@sil.org&gt;. See L&lt;Font::TTF::Font&gt; for copyright and
licensing.

=cut

</pre></body></html>