Skip to content

Commit

Permalink
Checks against punctuation character set
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbs committed May 4, 2022
1 parent 1478adb commit 386905e
Showing 1 changed file with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ final class LineTypesetter {
private var startOffset = 0
private var nextYPosition: CGFloat = 0
private var lineFragmentIndex = 0
/// List of characters that we prefer wrapping a line after. These are less preferred than whitespace.
/// If it's not possible to wrap a line after a whitespace or any of these characters, then we'll wrap after any character.
private let preferredLineBreakCharacters = [",", ";"]

init(lineID: String) {
self.lineID = lineID
Expand Down Expand Up @@ -221,11 +218,7 @@ private extension LineTypesetter {
let range = NSRange(location: location, length: 1)
let attributedSubstring = attributedString.attributedSubstring(from: range)
let string = attributedSubstring.string.trimmingCharacters(in: .whitespaces)
if string.isEmpty {
return true
} else {
return preferredLineBreakCharacters.contains(string)
}
return string.isEmpty ||CharacterSet(charactersIn: string).isSubset(of: .punctuationCharacters)
}

private func makeLineFragment(for range: CFRange, in typesetter: CTTypesetter, lineFragmentIndex: Int, yPosition: CGFloat) -> LineFragment {
Expand Down

0 comments on commit 386905e

Please sign in to comment.