Skip to content

Commit d880f7a

Browse files
Merge pull request #1275 from wordpress-mobile/issue/fix_underline_bug
Fix underline bug
2 parents 4516bc8 + b55bb6f commit d880f7a

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

Aztec/Classes/TextKit/LayoutManager.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,15 @@ private extension LayoutManager {
363363
extension LayoutManager {
364364

365365
override func underlineGlyphRange(_ glyphRange: NSRange, underlineType underlineVal: NSUnderlineStyle, lineFragmentRect lineRect: CGRect, lineFragmentGlyphRange lineGlyphRange: NSRange, containerOrigin: CGPoint) {
366-
366+
guard let textStorage = textStorage else {
367+
return
368+
}
369+
let underlinedString = textStorage.attributedSubstring(from: glyphRange).string
367370
var updatedGlyphRange = glyphRange
368-
if glyphRange.endLocation == lineGlyphRange.endLocation {
371+
if glyphRange.endLocation == lineGlyphRange.endLocation,
372+
underlinedString.contains(String.init(.nonBreakingSpace)),
373+
underlinedString.hasSuffix(String.init(.paragraphSeparator))
374+
{
369375
updatedGlyphRange = NSRange(location: glyphRange.location, length: glyphRange.length - 1)
370376
}
371377
drawUnderline(forGlyphRange: updatedGlyphRange, underlineType: underlineVal, baselineOffset: 0, lineFragmentRect: lineRect, lineFragmentGlyphRange: lineGlyphRange, containerOrigin: containerOrigin)

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.17.1
2+
-----
3+
* Fix drawing of underlines when they include the last character of content.
4+
15
1.17.0
26
-----
37
* Fix drawing of underlines when they have a nbsp and span to the end of a line

Example/Example/SampleContent/underline.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
<p><span style="text-decoration: underline;">Alternative&nbsp;underline&nbsp;text</span></p>
33
<p>Before link <a href="www.wordpress.com">Link&nbsp;to&nbsp;WordPress</a></p>
44
<p>Before link <a href="www.jetpack.com">Link&nbsp;to&nbsp;Jetpack</a> After link</p>
5+
Link at end of text<a href="www.jetpack.com">Link&nbsp;to&nbsp;Jetpack</a>

WordPress-Aztec-iOS.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'WordPress-Aztec-iOS'
11-
s.version = '1.17.0'
11+
s.version = '1.17.1'
1212
s.summary = 'The native HTML Editor.'
1313

1414
# This description is used to generate tags and improve search results.

WordPress-Editor-iOS.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'WordPress-Editor-iOS'
11-
s.version = '1.17.0'
11+
s.version = '1.17.1'
1212
s.summary = 'The WordPress HTML Editor.'
1313

1414
# This description is used to generate tags and improve search results.

0 commit comments

Comments
 (0)