@ISA
=
qw(Font::TTF::Table)
;
sub
read
{
my
(
$self
) =
@_
;
$self
->{
' PARENT'
}{
'loca'
}->
read
;
$self
->{
' read'
} = 1;
$self
;
}
sub
out
{
my
(
$self
,
$fh
) =
@_
;
my
(
$i
,
$loca
,
$offset
,
$numGlyphs
);
return
$self
->SUPER::out(
$fh
)
unless
$self
->{
' read'
};
$loca
=
$self
->{
' PARENT'
}{
'loca'
}{
'glyphs'
};
$numGlyphs
=
$self
->{
' PARENT'
}{
'maxp'
}{
'numGlyphs'
};
$offset
= 0;
for
(
$i
= 0;
$i
<
$numGlyphs
;
$i
++)
{
next
unless
defined
$loca
->[
$i
];
$loca
->[
$i
]->update;
$loca
->[
$i
]{
' OUTLOC'
} =
$offset
;
$loca
->[
$i
]->out(
$fh
);
$offset
+=
$loca
->[
$i
]{
' OUTLEN'
};
}
$self
;
}
sub
out_xml
{
my
(
$self
,
$context
,
$depth
) =
@_
;
my
(
$fh
) =
$context
->{
'fh'
};
my
(
$loca
,
$i
,
$numGlyphs
);
$loca
=
$self
->{
' PARENT'
}{
'loca'
}{
'glyphs'
};
$numGlyphs
=
$self
->{
' PARENT'
}{
'maxp'
}{
'numGlyphs'
};
for
(
$i
= 0;
$i
<
$numGlyphs
;
$i
++)
{
$context
->{
'gid'
} =
$i
;
$loca
->[
$i
]->out_xml(
$context
,
$depth
)
if
(
defined
$loca
->[
$i
]);
}
$self
;
}
sub
XML_start
{
my
(
$self
) =
shift
;
my
(
$context
,
$tag
,
%attrs
) =
@_
;
if
(
$tag
eq
'glyph'
)
{
$context
->{
'tree'
}[-1] = Font::TTF::Glyph->new(
read
=> 2,
PARENT
=>
$self
->{
' PARENT'
});
$context
->{
'receiver'
} =
$context
->{
'tree'
}[-1];
}
}
sub
XML_end
{
my
(
$self
) =
shift
;
my
(
$context
,
$tag
,
%attrs
) =
@_
;
if
(
$tag
eq
'glyph'
)
{
unless
(
defined
$context
->{
'glyphs'
})
{
if
(
defined
$self
->{
' PARENT'
}{
'loca'
})
{
$context
->{
'glyphs'
} =
$self
->{
' PARENT'
}{
'loca'
}{
'glyphs'
}; }
else
{
$context
->{
'glyphs'
} = []; }
}
$context
->{
'glyphs'
}[
$attrs
{
'gid'
}] =
$context
->{
'tree'
}[-1];
return
$context
;
}
else
{
return
$self
->SUPER::XML_end(
@_
); }
}
1;