XAML export omits fractional stroke widths

Bug #1350817 reported by Johannes Rössel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Medium
Johannes Rössel

Bug Description

The XAML export rounds stroke widths to the nearest integer. This causes elements with StrokeThickness="0" to be emitted if the stroke width was below 0.5 before.

I don't know *why* the rounding was done, but it definitely destroys certain SVGs. I attached a patch that removes the rounding.

Tags: exporting xaml
Revision history for this message
Johannes Rössel (joey-muhkuhsaft) wrote :
Revision history for this message
jazzynico (jazzynico) wrote :

Looks sensible. I don't know why it is currently rounded. An old specification maybe?
Thanks for your patch. I'll try to test it later next week.

Changed in inkscape:
assignee: nobody → jazzynico (jazzynico)
importance: Undecided → Medium
milestone: none → 0.91
status: New → Triaged
Revision history for this message
jazzynico (jazzynico) wrote :

Patch tested successfully with revision 13505.

I still have a doubt because of the following article (which was the reason why I used rounded values 4 years ago): http://msdn.microsoft.com/en-us/library/system.windows.shapes.shape.strokethickness%28v=vs.95%29.aspx
In the remarks section: "Generally you should use integral numeric values for this property. Nonintegral values can cause subpixel rendering, and may alter the apparent color of the stroke."

Note that it's just a suggestion and that it only applies to Silverlight (not the .NET). Now (r13505) that I have activated a new Silverlight compatible mode we could use rounded values for Silverlight only and keep the fractional component for .NET. Or use your patch and ignore Microsoft's suggestion...

Johannes, any comment or preference?

Changed in inkscape:
status: Triaged → In Progress
Revision history for this message
Johannes Rössel (joey-muhkuhsaft) wrote :

The remark in the docs essentially just say that when antialiasing is used the color of the stroke's pixels is not necessarily the one you wanted. Which ... is kinda obvious. Most importantly, this is also a problem with SVG. And if you scale an image down.

In this case we're exporting an SVG image to XAML. It may have a specific size at which it is rendered or may be freely zoomable (the outer ViewBox element will scale anything inside anyway if it has to). But regardless, the stroke width constraints for the designer should be the same in SVG and XAML. If they want to ensure that strokes fit the pixel grid at a particular output size, then they should have done exactly that in SVG already (or use shape-rendering='crisp-edges' (which could very well be translated into SnapsToDevicePixels in XAML).

So I believe that the guideline in the documentation is more for designers to keep in mind that they don't do print. Also a stroke with thickness could appear in lots of places, be it a border around content, or part of a control template. I guess the SVG → XAML route only needs to concern itself with vector images and I'm not sure the suggestion in the docs holds much merit there.

Revision history for this message
jazzynico (jazzynico) wrote :

Thanks for your comment, Johannes!

Fixed in the trunk revision 13507 with the patch from comment #1.

Changed in inkscape:
assignee: jazzynico (jazzynico) → Johannes Rössel (joey-muhkuhsaft)
status: In Progress → Fix Committed
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.