Function

CTFontGetOpticalBoundsForGlyphs

Calculates the optical bounds for an array of glyphs and returns the overall optical bounds for the run.

Declaration

CGRect CTFontGetOpticalBoundsForGlyphs(CTFontRef font, const CGGlyph *glyphs, CGRect *boundingRects, CFIndex count, CFOptionFlags options);

Parameters

font

The font reference.

glyphs

An array of glyphs.

boundingRects

An array of CGRects to receive the computed glyph bounds. This parameter can be NULL, in which case the function only calculates the overall bounding rectangle.

count

The capacity of the glyphs and boundingRects buffers.

options

Reserved, set to zero.

Return Value

This function returns the overall bounding rectangle for an array of glyphs. The boundingRects parameter returns the bounding rectangles of the individual glyphs. These rectangles are the design metrics from the font transformed in font space.

Discussion

Fonts may specify the optical edges of glyphs that can be used to make the edges of lines of text line up in a more visually pleasing way. This function returns bounding rectangles that correspond to these specifications if the font provides them; otherwise, it returns typographic bounding rectangles, composed of the font’s ascender and descender and a glyph’s advance width.

See Also

Getting Glyph Data

CTFontCreatePathForGlyph

Creates a path for the specified glyph.

CTFontGetGlyphWithName

Returns the CGGlyph value for the specified glyph name in the given font.

CTFontGetBoundingRectsForGlyphs

Calculates the bounding rects for an array of glyphs and returns the overall bounding rectangle for the glyph run.

CTFontGetAdvancesForGlyphs

Calculates the advances for an array of glyphs and returns the summed advance.

CTFontGetVerticalTranslationsForGlyphs

Calculates the offset from the default (horizontal) origin to the vertical origin for an array of glyphs.