Font::TTF::Glyph - Holds a information for a single glyph |
new(%parms)
out($fh)
dirty($val)
Font::TTF::Glyph - Holds a information for a single glyph
This is a single glyph description as held in a TT font. On creation only its header is read. Thus you can get the bounding box of each glyph without having to read all the other information.
In addition to the named variables in a glyph header (xMin
etc.), there are
also all capital instance variables for holding working information, mostly
from the location table.
The standard attributes each glyph has are:
There are also other, derived, instance variables for each glyph which are read
when the whole glyph is read (via read_dat
):
length($g-
{'hints'})> instead).
numberOfContours
contours in a glyph. The number of points in a glyph is
equal to the highest endpoint of a contour.
There are also a number of arrays indexed by point number:
update
d. Thus the flags are not very
useful. The only important bit is bit 0 which indicates whether the point is
an 'on' curve point, or an 'off' curve point.
glyph
may contain a numerical value
but that glyph might not actually exist in the font file. This could
occur in any glyph, but is particularly likely for glyphs that have
no strokes, such as SPACE, U+00A0 NO-BREAK SPACE, or
U+200B ZERO WIDTH SPACE.
update
method whenever any of the glyph content changes.
LEN
variable which
only reflects the read file length. The OUTLEN
variable is only set after
calling out
or out_dat
.
If you want to edit a glyph in some way, then you should read_dat the glyph, then make your changes and then update the glyph or set the $g->{' isDirty'} variable. The application must ensure that the following instance variables are correct, from which update will calculate the rest, including the bounding box information.
numPoints numberOfContours endPoints x, y, flags (only flags bit 0) instLen hints
For components, the numPoints, x, y, endPoints & flags are not required but the following information is required for each component.
flag (bits 2, 10, 11, 12) glyph args scale metric (glyph instance variable)
new(%parms)
Creates a new glyph setting various instance variables
Reads the header component of the glyph (numberOfContours and bounding box) and also the glyph content, but into a data field rather than breaking it down into its constituent structures. Use read_dat for this.
Reads the contents of the glyph (components and curves, etc.) from the memory
store DAT
into structures within the object.
out($fh)
Writes the glyph data to outfile
Outputs an XML description of the glyph
dirty($val)
This sets the dirty flag to the given value or 1 if no given value. It returns the value of the flag
Generates a $self-
{'DAT'}> from the internal structures, if the data has
been read into structures in the first place. If you are building a glyph
from scratch you will need to set the instance variable ' isDirty'
.
Updates the bounding box for this glyph according to the points in the glyph
Empties the glyph of all information to the level of not having been read. Useful for saving memory in apps with many glyphs being read
This method creates point information for a compound glyph. The information is stored in the same place as if the glyph was not a compound, but since numberOfContours is negative, the glyph is still marked as being a compound
Returns an array of all the glyph ids that are used to make up this glyph. That is all the compounds and their references and so on. If this glyph is not a compound, then returns an empty array.
Please note the warning about bad fonts that reference nonexistant glyphs under INSTANCE VARIABLES above. This function will not attempt to filter out nonexistant glyph numbers.
update
doesn't re-calculate the bounding box or numberOfContours
.
Martin Hosken http://scripts.sil.org/FontUtils.
Copyright (c) 1998-2014, SIL International (http://www.sil.org)
This module is released under the terms of the Artistic License 2.0. For details, see the full text of the license in the file LICENSE.
Font::TTF::Glyph - Holds a information for a single glyph |