From 7350333f39380e5e4856df56737f234b3fb46ecb Mon Sep 17 00:00:00 2001 From: Ivan Bruel Date: Thu, 22 Oct 2020 23:38:59 -0700 Subject: [PATCH] Update Drawing.swift Account for fill paddings and fix array index out of bounds when background doesn't fill the whole line in which it starts. --- Source/Classes/Drawing/Drawing.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/Classes/Drawing/Drawing.swift b/Source/Classes/Drawing/Drawing.swift index cf224e0..0457f5c 100644 --- a/Source/Classes/Drawing/Drawing.swift +++ b/Source/Classes/Drawing/Drawing.swift @@ -174,7 +174,6 @@ extension NantesLabel { let lineWidth: CGFloat = attributes[.nantesLabelBackgroundLineWidth] as? CGFloat ?? 0.0 guard strokeColor != nil || fillColor != nil else { - lineIndex += 1 continue } @@ -199,7 +198,7 @@ extension NantesLabel { runBounds.origin.y = origins[lineIndex].y + rect.origin.y - fillPadding.bottom - rect.origin.y - runDescent // We don't want to draw too far to the right - runBounds.size.width = runBounds.width > width ? width : runBounds.width + runBounds.size.width = runBounds.width > width + fillPadding.left + fillPadding.right ? width + fillPadding.left + fillPadding.right : runBounds.width let roundedRect = runBounds.inset(by: linkBackgroundEdgeInset).insetBy(dx: lineWidth, dy: lineWidth) let path: CGPath = UIBezierPath(roundedRect: roundedRect, cornerRadius: cornerRadius).cgPath