Skip to content

Commit 9f64965

Browse files
Make sure to use CGRect
1 parent 4af0e52 commit 9f64965

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies: [
2828
func characterIndexes(within rect: CGRect) -> IndexSet
2929
func enumerateLineFragments(for rect: CGRect, strictIntersection: Bool, block: (CGRect, NSRange, inout Bool) -> Void)
3030
func enumerateLineFragments(in range: NSRange, block: (CGRect, NSRange, inout Bool) -> Void)
31-
func boundingRect(for range: NSRange) -> NSRect?
31+
func boundingRect(for range: NSRange) -> CGRect?
3232
```
3333

3434
### `NSTextLayoutManager` Additions
@@ -49,7 +49,7 @@ func enumerateLineFragments(with provider: NSTextElementProvider, block: (NSText
4949
```swift
5050
func characterIndexes(within rect: CGRect) -> IndexSet
5151
var visibleCharacterIndexes: IndexSet
52-
func boundingRect(for range: NSRange) -> NSRect?
52+
func boundingRect(for range: NSRange) -> CGRect?
5353
```
5454

5555
### `NSRange` and `NSTextRange` Additions

Sources/Glyph/NSTextContainer+Additions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ extension NSTextContainer {
8989
}
9090

9191
extension NSTextContainer {
92-
public func boundingRect(for range: NSRange) -> NSRect? {
92+
public func boundingRect(for range: NSRange) -> CGRect? {
9393
if #available(macOS 12.0, iOS 15.0, *), let textLayoutManager {
9494
return textLayoutManager.boundingRect(for: range)
9595
}
9696

9797
return tk1BoundingRect(for: range)
9898
}
9999

100-
private func tk1BoundingRect(for range: NSRange) -> NSRect? {
100+
private func tk1BoundingRect(for range: NSRange) -> CGRect? {
101101
guard let layoutManager else { return nil }
102102

103103
let glyphRange = layoutManager.glyphRange(forCharacterRange: range, actualCharacterRange: nil)

Sources/Glyph/NSTextLayoutManager+Additions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ extension NSTextLayoutManager {
118118
}
119119
}
120120

121-
func boundingRect(for range: NSRange) -> NSRect? {
122-
var rect: NSRect? = nil
121+
func boundingRect(for range: NSRange) -> CGRect? {
122+
var rect: CGRect? = nil
123123

124124
enumerateTextLineFragments(in: range, options: [.ensuresLayout]) { lineFragment, lineRect, lineRange, stop in
125125
rect = rect?.union(lineRect) ?? lineRect

Sources/Glyph/NSTextView+Additions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extension TextView {
3535
}
3636

3737
/// Returns the bounding rectangle for the given text range.
38-
public func boundingRect(for range: NSRange) -> NSRect? {
38+
public func boundingRect(for range: NSRange) -> CGRect? {
3939
#if os(macOS) && !targetEnvironment(macCatalyst)
4040
guard let rect = textContainer?.boundingRect(for: range) else {
4141
return nil

0 commit comments

Comments
 (0)