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 of
59 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 set in
66 associated application to adjust which objects should receive
67 messages when. It is also stored in the parsing stack to ensure
68 that where an object changes it during XML_start, that that same
69 object that received XML_start will receive the corresponding
70 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 parent
79 of each element in the stack. The default action is to push undef
80 onto this stack during XML_start and then to resolve this, either
81 in the associated application (by changing $context->{'tree'}[-1])
82 or during XML_end of a child element, by which time we know whether
83 we are dealing with an array or a hash or what.
84
85 text
86 Character processing is to insert all the characters into the text
87 element of the context for available use later.
88
91 Hey! The above document had some coding errors, which are explained
92 below:
93
94 Around line 58:
95 =back doesn't take any parameters, but you said =back 4
96
97 Around line 60:
98 =back doesn't take any parameters, but you said =back 4
99
100 Around line 101:
101 =back doesn't take any parameters, but you said =back 4
102
103
104
105perl v5.10.1 2008-06-11 Font::TTF::XMLparse(3)