OutlineMetrics
OutlineMetrics Determine glyph measurements for a line of text
#include <Fonts.h> Font Manager
OSErr OutlineMetrics(byteCount, textPtr, numer, denom, ymax, yMin,
awArray, lsbArray, boundsArray );
Short byteCount; The number of bytes
void *textPtr; The pointer to the block of text
Point numer ; Numerator of scaling ratio
Point denom ; Denominator of scaling ratio
short *yMax; The maximum y-value for the text. Pass NULL in
this parameter if you don't want this value returned.
short *yMin; The minimum y-value for the text. Pass NULL in
this parameter if you don't want this value returned.
FixedPtr awArray; A pointer to the array of advanced width
measurements for the glyphs being considered
FixedPtr lsbArray; A pointer to an array of the left-side bearing
measurements for the glyphs being considered
RectPtr boundsArray; Pointer to array of bounding boxes for the glyphs
being considered
returns 0 = noErr
You can use the OutlineMetrics function to determine the measurements,
such as heights or advance widths, of the glyphs in any line of text you choose.
On the basis of these measurements, you can decide whether to use
SetPreserveGlyph to keep the original sizes of the glyphs. The
GetPreserveGlyph function tells you whether the glyphs in the current
grafPort record are scaled.
The OutlineMetrics function takes a block of text you provide and returns
the maximum y- value, minimum y- value, advance widths, left-side bearings,
and bounding boxes for this text only in the current font, point size, and font
style. (For definitions of these terms, see Font Measurements.) You can use
these measurements when laying out text. You may need to adjust line spacing
to accommodate exceptionally large glyphs. OutlineMetrics works on
TrueType fonts only.
Parameter descriptions
byteCount The number of bytes on which you want the OutlineMetrics
function to work.
textPtr The pointer to the block of text you are providing to
OutlineMetrics.
numer The numerators of the vertical and horizontal scaling factors. The
numer parameter is of type Point, and contains two integers-the
first is the numerator of the ratio for vertical scaling; the second
is the numerator of the ratio for horizontal scaling. The
Font Manager applies the font scaling factors to the font used in
the current grafPort in order to calculate the measurements for
the glyphs in the block of text.
denom The denominators of the vertical and horizontal scaling factors.
The denom parameter is of type Point, and contains two
integers-the first is the denominator of the ratio for vertical
scaling; the second is the denominator of the ratio for horizontal
scaling. The Font Manager applies the font scaling factors to the
font used in the current grafPort in order to calculate the
measurements for the glyphs in the block of text.
yMax The maximum y-value for the text. Pass NULL in this parameter
if you don't want this value returned.
yMin The minimum y-value for the text. Pass NULL in this parameter if
you don't want this value returned.
awArray A pointer to an array of the advance width measurements for the
glyphs being considered. These measurements are in pixels, based
on the point size and font scaling factors of the font used by the
current grafPort record. The number of entries in the array is
given by the byteCount parameter.
The awArray parameter is of type FixedPtr. The FixedPtr data
type is a pointer to an array, and each entry in the array is of type
Fixed, which is 4 bytes in length. Multiply byteCount by 4 to
calculate the memory you need in bytes. Allocate the memory needed
for the array and pass a pointer to the array in the awArray
parameter.
If the FractEnable global variable has been set to TRUE using the
SetFractEnable procedure, the values in awArray have
fractional character widths. If FractEnable has been set to FALSE,
the Font Manager returns integers for the advance widths, with
0 in the decimal part of the values.
Pass a NIL in this parameter if you don't want the advance width
values returned.
lsbArray A pointer to an array of the left-side bearing measurements for
the glyphs being considered. The measurements are in pixels, based
on the point size of the font used by the current grafPort record.
The number of entries in the array is given by the byteCount
parameter.
The lsbArray parameter is of type FixedPtr. The FixedPtr data
type is a pointer to an array, and each entry in the array is of type
Fixed, which is 4 bytes in length. Multiply byteCount by 4 to
calculate the memory you need in bytes. Allocate the memory needed
for the array and pass a pointer to the array in the lsbArray
parameter. The left-side bearing values are never rounded.
Pass a NIL in this parameter if you don't want the left-side
bearing values returned.
boundsArray A pointer to the array of bounding boxes for the glyphs being
considered. Bounding boxes are the smallest rectangles that fit
around the pixels of the glyph. The bounding box measurements
returned by OutlineMetrics may be slightly larger than the those
for the actual glyph. The number of entries in the array is given by
the byteCount parameter.
The boundsArray parameter is of type RectPtr. The RectPtr data
type is a pointer to QuickDraw 's Rect data type, which is 8 bytes
in length. Multiply byteCount by 8 to calculate the memory you
need in bytes. Allocate the memory needed for the array and pass a
pointer to the array in the boundsArray parameter.
Pass a NIL in this parameter if you don't want the bounding box
values returned.
Result codes
noErr (0) No error