Contents

CTFontGetOpticalBoundsForGlyphs(_:_:_:_:_:)

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

Declaration

func CTFontGetOpticalBoundsForGlyphs(_ font: CTFont, _ glyphs: UnsafePointer<CGGlyph>, _ boundingRects: UnsafeMutablePointer<CGRect>?, _ count: CFIndex, _ options: CFOptionFlags) -> CGRect

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