From 9f6496581d85c0fc77b6ddb7d190bf9a1f420e23 Mon Sep 17 00:00:00 2001 From: Matt <85322+mattmassicotte@users.noreply.github.com> Date: Tue, 27 Aug 2024 06:29:55 -0400 Subject: [PATCH] Make sure to use CGRect --- README.md | 4 ++-- Sources/Glyph/NSTextContainer+Additions.swift | 4 ++-- Sources/Glyph/NSTextLayoutManager+Additions.swift | 4 ++-- Sources/Glyph/NSTextView+Additions.swift | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e9fcd58..5ad7fb4 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ dependencies: [ func characterIndexes(within rect: CGRect) -> IndexSet func enumerateLineFragments(for rect: CGRect, strictIntersection: Bool, block: (CGRect, NSRange, inout Bool) -> Void) func enumerateLineFragments(in range: NSRange, block: (CGRect, NSRange, inout Bool) -> Void) -func boundingRect(for range: NSRange) -> NSRect? +func boundingRect(for range: NSRange) -> CGRect? ``` ### `NSTextLayoutManager` Additions @@ -49,7 +49,7 @@ func enumerateLineFragments(with provider: NSTextElementProvider, block: (NSText ```swift func characterIndexes(within rect: CGRect) -> IndexSet var visibleCharacterIndexes: IndexSet -func boundingRect(for range: NSRange) -> NSRect? +func boundingRect(for range: NSRange) -> CGRect? ``` ### `NSRange` and `NSTextRange` Additions diff --git a/Sources/Glyph/NSTextContainer+Additions.swift b/Sources/Glyph/NSTextContainer+Additions.swift index 229b2b1..c44db4d 100644 --- a/Sources/Glyph/NSTextContainer+Additions.swift +++ b/Sources/Glyph/NSTextContainer+Additions.swift @@ -89,7 +89,7 @@ extension NSTextContainer { } extension NSTextContainer { - public func boundingRect(for range: NSRange) -> NSRect? { + public func boundingRect(for range: NSRange) -> CGRect? { if #available(macOS 12.0, iOS 15.0, *), let textLayoutManager { return textLayoutManager.boundingRect(for: range) } @@ -97,7 +97,7 @@ extension NSTextContainer { return tk1BoundingRect(for: range) } - private func tk1BoundingRect(for range: NSRange) -> NSRect? { + private func tk1BoundingRect(for range: NSRange) -> CGRect? { guard let layoutManager else { return nil } let glyphRange = layoutManager.glyphRange(forCharacterRange: range, actualCharacterRange: nil) diff --git a/Sources/Glyph/NSTextLayoutManager+Additions.swift b/Sources/Glyph/NSTextLayoutManager+Additions.swift index ac9f89c..04f0c68 100644 --- a/Sources/Glyph/NSTextLayoutManager+Additions.swift +++ b/Sources/Glyph/NSTextLayoutManager+Additions.swift @@ -118,8 +118,8 @@ extension NSTextLayoutManager { } } - func boundingRect(for range: NSRange) -> NSRect? { - var rect: NSRect? = nil + func boundingRect(for range: NSRange) -> CGRect? { + var rect: CGRect? = nil enumerateTextLineFragments(in: range, options: [.ensuresLayout]) { lineFragment, lineRect, lineRange, stop in rect = rect?.union(lineRect) ?? lineRect diff --git a/Sources/Glyph/NSTextView+Additions.swift b/Sources/Glyph/NSTextView+Additions.swift index ca3afff..672f698 100644 --- a/Sources/Glyph/NSTextView+Additions.swift +++ b/Sources/Glyph/NSTextView+Additions.swift @@ -35,7 +35,7 @@ extension TextView { } /// Returns the bounding rectangle for the given text range. - public func boundingRect(for range: NSRange) -> NSRect? { + public func boundingRect(for range: NSRange) -> CGRect? { #if os(macOS) && !targetEnvironment(macCatalyst) guard let rect = textContainer?.boundingRect(for: range) else { return nil