Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index out of range when using background fill or stroke #83

Open
clo-dan opened this issue Sep 22, 2022 · 1 comment
Open

Index out of range when using background fill or stroke #83

clo-dan opened this issue Sep 22, 2022 · 1 comment

Comments

@clo-dan
Copy link

clo-dan commented Sep 22, 2022

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.

@homekuanyi
Copy link

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

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants