Nantes icon indicating copy to clipboard operation
Nantes copied to clipboard

Index out of range when using background fill or stroke

Open clo-dan opened this issue 2 years ago • 1 comments

When I attempt to set a background fill or stroke, like so:

string.addAttribute(.nantesLabelBackgroundFillColor, value: UIColor.lightGray, range: range)

App crashes with:

Swift/ContiguousArrayBuffer.swift:600: Fatal error: Index out of range

The termination point is Drawing.swift:198, when accessing origins[lineIndex].x: runBounds.origin.x = origins[lineIndex].x + rect.origin.x + xOffset - fillPadding.left - rect.origin.x

I have verified that the NSRange I provide in the addAttribute call is valid, as I can use the nantesLabelStrikeOut attribute and it works fine.

clo-dan avatar Sep 22 '22 19:09 clo-dan

lineIndex should increase in the loop of for line in lines, other than the loop of for glyphRun in glyphRuns.

image

homekuanyi avatar Aug 08 '23 05:08 homekuanyi