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

# textContainer(forGlyphAt:effectiveRange:)

Returns the text container that manages the layout for the specified glyph, causing layout to happen as necessary.

```
func textContainer(forGlyphAt glyphIndex: Int, effectiveRange effectiveGlyphRange: NSRangePointer?) -> NSTextContainer?
```

## Parameters

`glyphIndex`

Index of a glyph in the returned container.

`effectiveGlyphRange`

If not `NULL`, on output, points to the whole range of glyphs that are in the returned container.

## Return Value

The text container in which the glyph at `glyphIndex` is laid out.

## Discussion

This method causes glyph generation and layout for the line fragment containing the specified glyph, or if noncontiguous layout is not enabled, up to and including that line fragment. If noncontiguous layout is not enabled and `effectiveGlyphRange` is not `NULL`, this method additionally causes glyph generation and layout for the entire text container containing the specified glyph.

Overriding this method is not recommended. Any changes to the returned glyph range should be done at the typesetter level.

---

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)