<!--
{
  "availability" : [
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextInputClient/fractionOfDistanceThroughGlyph(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTextInputClient(im)fractionOfDistanceThroughGlyphForPoint:"
  },
  "title" : "fractionOfDistanceThroughGlyph(for:)"
}
-->

# fractionOfDistanceThroughGlyph(for:)

Returns the fraction of the distance from the left side of the character to the right side that a given point lies.

```
optional func fractionOfDistanceThroughGlyph(for point: NSPoint) -> CGFloat
```

## Parameters

`point`

The point to test.

## Return Value

The fraction of the distance `aPoint` is through the glyph in which it lies. May be 0 or 1 if `aPoint` is not within the bounding rectangle of a glyph (0 if the point is to the left or above the glyph; 1 if it’s to the right or below).

## Discussion

Implementation of this method is optional. This allows caller to perform precise selection handling.

For purposes such as dragging out a selection or placing the insertion point, a partial percentage less than or equal to 0.5 indicates that `aPoint` should be considered as falling before the glyph; a partial percentage greater than 0.5 indicates that it should be considered as falling after the glyph. If the nearest glyph doesn’t lie under `aPoint` at all (for example, if `aPoint` is beyond the beginning or end of a line), this ratio is 0 or 1.

For example, if the glyph stream contains the glyphs “A” and “b”, with the width of “A” being 13 points, and `aPoint` is 8 points from the left side of “A”, then the fraction of the distance is 8/13, or 0.615. In this case, the `aPoint` should be considered as falling between “A” and “b” for purposes such as dragging out a selection or placing the insertion point.

---

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)