<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSLayoutManager/characterRange(forGlyphRange:actualGlyphRange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLayoutManager(im)characterRangeForGlyphRange:actualGlyphRange:"
  },
  "title" : "characterRange(forGlyphRange:actualGlyphRange:)"
}
-->

# characterRange(forGlyphRange:actualGlyphRange:)

Returns the range of characters that correspond to the glyphs in the specified glyph range.

```
func characterRange(forGlyphRange glyphRange: NSRange, actualGlyphRange: NSRangePointer?) -> NSRange
```

## Parameters

`glyphRange`

The glyph range for which to return the character range.

`actualGlyphRange`

If not `NULL`, on output, points to the full range of glyphs generated by the character range returned. This range may be identical or slightly larger than the requested glyph range. For example, if the text storage contains the character “`Ö`” and the glyph cache contains the two atomic glyphs “`O`” and “`¨`”, and if `glyphRange` encloses only the first or second glyph, then `actualGlyphRange` is set to enclose both glyphs.

## Return Value

The range of characters that generated the glyphs in `glyphRange`.

## Discussion

If the length of `glyphRange` is `0`, the resulting character range is a zero-length range just after the character(s) corresponding to the preceding glyph, and `actualGlyphRange` is also zero-length. If `glyphRange` extends beyond the text length, the method truncates the result to the number of characters in the text.

If noncontiguous layout is not enabled, this method forces the generation of glyphs for all characters up to and including the end of the returned range.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)