1Font::TTF::XMLparse(3)User Contributed Perl DocumentationFont::TTF::XMLparse(3)
2
3
4
6 Font::TTF::XMLparse - provides support for XML parsing. Requires Expat
7 module XML::Parser::Expat
8
10 use Font::TTF::Font;
11 use Font::TTF::XMLparse;
12
13 $f = Font::TTF::Font->new;
14 read_xml($f, $ARGV[0]);
15 $f->out($ARGV[1]);
16
18 This module contains the support routines for parsing XML and
19 generating the Truetype font structures as a result. The module has
20 been separated from the rest of the package in order to reduce the
21 dependency that this would bring, of the whole package on XML::Parser.
22 This way, people without the XML::Parser can still use the rest of the
23 package.
24
25 The package interacts with another package through the use of a context
26 containing and element 'receiver' which is an object which can possibly
27 receive one of the following messages:
28
29 XML_start
30 This message is called when an open tag occurs. It is called with
31 the context, tag name and the attributes. The return value has no
32 meaning.
33
34 XML_end
35 This messages is called when a close tag occurs. It is called with
36 the context, tag name and attributes (held over from when the tag
37 was opened). There are 3 possible return values from such a
38 message:
39
40 undef This is the default return value indicating that default
41 processing should occur in which either the current element
42 on the tree, or the text of this element should be stored
43 in the parent object.
44
45 $context
46 This magic value marks that the element should be deleted
47 from the parent. Nothing is stored in the parent. (This
48 rather than '' is used to allow 0 returns.)
49
50 anything
51 Anything else is taken as the element content to be stored
52 in the parent.
53
54 In addition, the context hash passed to these messages contains the
55 following keys:
56
57 xml This is the expat xml object. The context is also available as
58 $context->{'xml'}{' mycontext'}. But that is a long winded way
59 of not saying much!
60
61 font
62 This is the base object that was passed in for XML parsing.
63
64 receiver
65 This holds the current receiver of parsing events. It may be
66 set in associated application to adjust which objects should
67 receive messages when. It is also stored in the parsing stack
68 to ensure that where an object changes it during XML_start,
69 that that same object that received XML_start will receive the
70 corresponding XML_end
71
72 stack
73 This is the parsing stack, used internally to hold the current
74 receiver and attributes for each element open, as a complete
75 hierarchy back to the root element.
76
77 tree
78 This element contains the storage tree corresponding to the
79 parent of each element in the stack. The default action is to
80 push undef onto this stack during XML_start and then to resolve
81 this, either in the associated application (by changing
82 $context->{'tree'}[-1]) or during XML_end of a child element,
83 by which time we know whether we are dealing with an array or a
84 hash or what.
85
86 text
87 Character processing is to insert all the characters into the
88 text element of the context for available use later.
89
92 Martin Hosken <http://scripts.sil.org/FontUtils>.
93
95 Copyright (c) 1998-2016, SIL International (http://www.sil.org)
96
97 This module is released under the terms of the Artistic License 2.0.
98 For details, see the full text of the license in the file LICENSE.
99
100
101
102perl v5.34.0 2021-07-22 Font::TTF::XMLparse(3)