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

Correctly capture and use stroke properties when rendering SVG paths #1647

Merged
merged 3 commits into from
Mar 14, 2021

Conversation

SecondFlight
Copy link
Collaborator

This patch updates the SVG widget to fetch and use properties about stroke style, such as line cap and dash array.

This has not been thoroughly tested since the new properties have a one-to-one mapping with StrokeStyle in piet. It has passed a smoke test in a project I'm working on, which has 12 unique SVG icons. Some of these icons also now render correctly where they didn't before.

I'm a little iffy about is the Vec clone. I don't think it's avoidable here, but I want to point it out since Druid goes to great lengths to avoid it elsewhere.

Copy link
Collaborator

@maan2003 maan2003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I don't think there is a way to avoid clone here. :)

(Edit: there is a way but not practical: Make p &mut usvg::Path, then mem::take the dasharray and reassigning it again after stroke_style())

@maan2003 maan2003 merged commit 17e03bd into linebender:master Mar 14, 2021
@SecondFlight SecondFlight deleted the svg-stroke-style branch March 14, 2021 16:15
@cmyr
Copy link
Member

cmyr commented Mar 16, 2021

I think the best answer here is to not have dash_array be a vec; StrokeStyle should be cheap to clone.

A simple answer is Rc<[]>; and maybe const generics will let us use arrays in more places like this?

derekdreery pushed a commit to derekdreery/druid that referenced this pull request Apr 6, 2021
…inebender#1647)

* Use correct LineJoin and LineCap behavior in svg widget

* Correctly set miter limit and dash array properties when rendering SVG paths with stroke

* Update changelog
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

Successfully merging this pull request may close these issues.

None yet

3 participants