<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTypesetter/textTab(forGlyphLocation:writingDirection:maxLocation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTypesetter(im)textTabForGlyphLocation:writingDirection:maxLocation:"
  },
  "title" : "textTab(forGlyphLocation:writingDirection:maxLocation:)"
}
-->

# textTab(forGlyphLocation:writingDirection:maxLocation:)

Returns the text tab next closest to a given glyph location within the given parameters.

```
func textTab(forGlyphLocation glyphLocation: CGFloat, writingDirection direction: NSWritingDirection, maxLocation: CGFloat) -> NSTextTab?
```

## Parameters

`glyphLocation`

The location at which to start searching.

`direction`

The direction in which to search.

`maxLocation`

The maximum location for the search.

## Return Value

The text tab next closest to `glyphLocation`, indexing in `direction` but not beyond `maxLocation`.

## Discussion

The typesetter calls this method whenever it finds a tab character. To determine the width to advance the next glyph, the typesetter examines the [`NSParagraphStyle`](/documentation/AppKit/NSParagraphStyle) object’s tab array and the default tab interval.

---

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)