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 sim‐
37       ple 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 com‐
63           ponent 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 num‐
67           ber of elements:
68
69           glyph
70               The glyph number of the glyph which comprises this component of
71               the composite.
72
73           args
74               An array of two arguments which may be an x, y co-ordinate or
75               two attachment points (one on the base glyph the other on the
76               component). See flags for details.
77
78           flag
79               The flag for this component
80
81           scale
82               A 4 number array for component scaling. This allows stretching,
83               rotating, etc.  Note that scaling applies to placement co-ordi‐
84               nates (rather than attachment points) before locating rather
85               than after.
86
87       numPoints
88           This is a generated value which contains the number of components
89           read in for this compound glyph.
90
91       The private instance variables are:
92
93       INFILE (P)
94           The input file form which to read any information
95
96       LOC (P)
97           Location relative to the start of the glyf table in the read file
98
99       BASE (P)
100           The location of the glyf table in the read file
101
102       LEN (P)
103           This is the number of bytes required by the glyph. It should be
104           kept up to date by calling the "update" method whenever any of the
105           glyph content changes.
106
107       OUTLOC (P)
108           Location relative to the start of the glyf table. This variable is
109           only active whilst the output process is going on. It is used to
110           inform the location table where the glyph's location is, since the
111           glyf table is output before the loca table due to alphabetical
112           ordering.
113
114       OUTLEN (P)
115           This indicates the length of the glyph data when it is output. This
116           more accurately reflects the internal memory form than the "LEN"
117           variable which only reflects the read file length. The "OUTLEN"
118           variable is only set after calling "out" or "out_dat".
119
120       Editing
121
122       If you want to edit a glyph in some way, then you should read_dat the
123       glyph, then make your changes and then update the glyph or set the
124       $g->{' isdirty'} variable.  It is the application's duty to ensure that
125       the following instance variables are correct, from which update will
126       calculate the rest, including the bounding box information.
127
128           numPoints
129           numberOfContours
130           endPoints
131           x, y, flags         (only flags bit 0)
132           instLen
133           hints
134
135       For components, the numPoints, x, y, endPoints & flags are not required
136       but the following information is required for each component.
137
138           flag                (bits 2, 10, 11, 12)
139           glyph
140           args
141           scale
142           metric              (glyph instance variable)
143

METHODS

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

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

BUGS

205       ·   The instance variables used here are somewhat clunky and inconsis‐
206           tent with the other tables.
207
208       ·   "update" doesn't re-calculate the bounding box or "numberOfCon‐
209           tours".
210

AUTHOR

212       Martin Hosken Martin_Hosken@sil.org. See Font::TTF::Font for copyright
213       and licensing.
214
215
216
217perl v5.8.8                       2005-06-14               Font::TTF::Glyph(3)
Impressum