Skip to content

Commit

Permalink
typographicBounds
Browse files Browse the repository at this point in the history
  • Loading branch information
krzyzanowskim committed May 18, 2024
1 parent a57a208 commit 561858f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/STTextKitPlus/NSTextContentManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public extension NSTextContentManager {
precondition(range.isEmpty == false)
}

if range != nil, range?.isEmpty == true {
if let range, range.isEmpty {
return nil
}

Expand Down
7 changes: 7 additions & 0 deletions Sources/STTextKitPlus/NSTextLayoutManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ extension NSTextLayoutManager {
}

extension NSTextLayoutManager {

/// Typographic bounds of the range.
/// - Parameter textRange: The range.
/// - Returns: Typographic bounds of the range.
public func typographicBounds(in textRange: NSTextRange) -> CGRect? {
textSegmentFrame(in: textRange, type: .standard, options: [.upstreamAffinity, .rangeNotRequired])
}

/// A text segment is both logically and visually contiguous portion of the text content inside a line fragment.
public func textSegmentFrame(at location: NSTextLocation, type: NSTextLayoutManager.SegmentType, options: SegmentOptions = [.upstreamAffinity]) -> CGRect? {
Expand Down

0 comments on commit 561858f

Please sign in to comment.