1Font::TTF::Glyph(3)   User Contributed Perl Documentation  Font::TTF::Glyph(3)
2
3
4

NAME

6       Font::TTF::Glyph - Holds a single glyph's information
7

DESCRIPTION

9       This is a single glyph description as held in a TT font. On creation
10       only its header is read. Thus you can get the bounding box of each
11       glyph without having to read all the other information.
12

INSTANCE VARIABLES

14       In addition to the named variables in a glyph header ("xMin" etc.),
15       there are also all capital instance variables for holding working
16       information, mostly from the location table.
17
18       The standard attributes each glyph has are:
19
20        numberOfContours
21        xMin
22        yMin
23        xMax
24        yMax
25
26       There are also other, derived, instance variables for each glyph which
27       are read when the whole glyph is read (via "read_dat"):
28
29       instLen
30           Number of bytes in the hinting instructions (Warning this variable
31           is deprecated, use "length($g-"{'hints'})> instead).
32
33       hints
34           The string containing the hinting code for the glyph
35
36       In addition there are other attribute like instance variables for
37       simple glyphs:
38
39           For each contour there is:
40
41           endPoints
42               An array of endpoints for each contour in the glyph. There are
43               "numberOfContours" contours in a glyph. The number of points in
44               a glyph is equal to the highest endpoint of a contour.
45
46           There are also a number of arrays indexed by point number
47
48           flags
49               The flags associated with reading this point. The flags for a
50               point are recalculated for a point when it is "update"d. Thus
51               the flags are not very useful. The only important bit is bit 0
52               which indicates whether the point is an 'on' curve point, or an
53               'off' curve point.
54
55           x   The absolute x co-ordinate of the point.
56
57           y   The absolute y co-ordinate of the point
58
59       For composite glyphs there are other variables
60
61       metric
62           This holds the component number (not its glyph number) of the
63           component from which the metrics for this glyph should be taken.
64
65       comps
66           This is an array of hashes for each component. Each hash has a
67           number of elements:
68
69           glyph
70               The glyph number of the glyph which comprises this component of
71               the composite.  NOTE: In some badly generated fonts, "glyph"
72               may contain a numerical value but that glyph might not actually
73               exist in the font file.  This could occur in any glyph, but is
74               particularly likely for glyphs that have no strokes, such as
75               SPACE, U+00A0 NO-BREAK SPACE, or U+200B ZERO WIDTH SPACE.
76
77           args
78               An array of two arguments which may be an x, y co-ordinate or
79               two attachment points (one on the base glyph the other on the
80               component). See flags for details.
81
82           flag
83               The flag for this component
84
85           scale
86               A 4 number array for component scaling. This allows stretching,
87               rotating, etc.  Note that scaling applies to placement co-
88               ordinates (rather than attachment points) before locating
89               rather than after.
90
91       numPoints
92           This is a generated value which contains the number of components
93           read in for this compound glyph.
94
95       The private instance variables are:
96
97       INFILE (P)
98           The input file form which to read any information
99
100       LOC (P)
101           Location relative to the start of the glyf table in the read file
102
103       BASE (P)
104           The location of the glyf table in the read file
105
106       LEN (P)
107           This is the number of bytes required by the glyph. It should be
108           kept up to date by calling the "update" method whenever any of the
109           glyph content changes.
110
111       OUTLOC (P)
112           Location relative to the start of the glyf table. This variable is
113           only active whilst the output process is going on. It is used to
114           inform the location table where the glyph's location is, since the
115           glyf table is output before the loca table due to alphabetical
116           ordering.
117
118       OUTLEN (P)
119           This indicates the length of the glyph data when it is output. This
120           more accurately reflects the internal memory form than the "LEN"
121           variable which only reflects the read file length. The "OUTLEN"
122           variable is only set after calling "out" or "out_dat".
123
124   Editing
125       If you want to edit a glyph in some way, then you should read_dat the
126       glyph, then make your changes and then update the glyph or set the
127       $g->{' isdirty'} variable.  It is the application's duty to ensure that
128       the following instance variables are correct, from which update will
129       calculate the rest, including the bounding box information.
130
131           numPoints
132           numberOfContours
133           endPoints
134           x, y, flags         (only flags bit 0)
135           instLen
136           hints
137
138       For components, the numPoints, x, y, endPoints & flags are not required
139       but the following information is required for each component.
140
141           flag                (bits 2, 10, 11, 12)
142           glyph
143           args
144           scale
145           metric              (glyph instance variable)
146

METHODS

Font::TTF::Glyph->new(%parms)

149       Creates a new glyph setting various instance variables
150
151   $g->read
152       Reads the header component of the glyph (bounding box, etc.) and also
153       the glyph content, but into a data field rather than breaking it down
154       into its constituent structures. Use read_dat for this.
155
156   $g->read_dat
157       Reads the contents of the glyph (components and curves, etc.) from the
158       memory store "DAT" into structures within the object. Then, to indicate
159       where the master form of the data is, it deletes the "DAT" instance
160       variable.
161
162   $g->out($fh)
163       Writes the glyph data to outfile
164
165   $g->out_xml($context, $depth)
166       Outputs an XML description of the glyph
167
168   $g->update
169       Generates a "$self-"{'DAT'}> from the internal structures, if the data
170       has been read into structures in the first place. If you are building a
171       glyph from scratch you will need to set the instance variable ' read'
172       to 2 (or something > 1) for the update to work.
173
174   $g->update_bbox
175       Updates the bounding box for this glyph according to the points in the
176       glyph
177
178   $g->maxInfo
179       Returns lots of information about a glyph so that the "maxp" table can
180       update itself. Returns array containing contributions of this glyph to
181       maxPoints, maxContours, maxCompositePoints, maxCompositeContours,
182       maxSizeOfInstructions, maxComponentElements, and maxComponentDepth.
183
184   $g->empty
185       Empties the glyph of all information to the level of not having been
186       read.  Useful for saving memory in apps with many glyphs being read
187
188   $g->get_points
189       This method creates point information for a compound glyph. The
190       information is stored in the same place as if the glyph was not a
191       compound, but since numberOfContours is negative, the glyph is still
192       marked as being a compound
193
194   $g->get_refs
195       Returns an array of all the glyph ids that are used to make up this
196       glyph. That is all the compounds and their references and so on. If
197       this glyph is not a compound, then returns an empty array.
198
199       Please note the warning about bad fonts that reference nonexistant
200       glyphs under INSTANCE VARIABLES above.  This function will not attempt
201       to filter out nonexistant glyph numbers.
202

BUGS

204       ·   The instance variables used here are somewhat clunky and
205           inconsistent with the other tables.
206
207       ·   "update" doesn't re-calculate the bounding box or
208           "numberOfContours".
209

AUTHOR

211       Martin Hosken Martin_Hosken@sil.org. See Font::TTF::Font for copyright
212       and licensing.
213
214
215
216perl v5.10.1                      2008-06-11               Font::TTF::Glyph(3)
Impressum