Moving location of object changes the stroke-width when it shouldn't

Bug #1093742 reported by rickmastfan67
18
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Confirmed
Low
Unassigned

Bug Description

Inkscape 0.48.4 r9939
Windows 7 x64

Steps to reproduce:
1. Open attached file in a text editor.
2. Go to line 55 and notice the text "stroke-width:1.05".
3. Now, open the file in Inkscape.
4. Select the object.
5. Hit any of the arrow keys to shift the objects location by 2 (doesn't matter which direction as the result is always the same).
6. Re-save the file.

What happens:
When you re-open the file in the text editor and go back down to line 55, the "stroke-width" has been changed to: 1.04999995

What should happen:
The "stroke-width" shouldn't be changed (staying @ 1.05) since you didn't transform the object's shape, and just moved it's location.

For some odd reason, Inkscape is shrinking the stroke-width by 0.00000005. By doing that, it adds 6 bytes to the file that shouldn't be there in the first place since you didn't change the item's size, just the location of the object.

===
Variations: bug #1417073, bug #1417071

Revision history for this message
rickmastfan67 (rickmastfan67) wrote :
su_v (suv-lp)
tags: added: precision
Revision history for this message
su_v (suv-lp) wrote :

Reproduced with Inkscape 0.48.4 and current trunk (r11986) on OS X 10.7.4.

Changed in inkscape:
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
rickmastfan67 (rickmastfan67) wrote :

Still happening.

Inkscape 0.91 r13725 x64
Windows 7 SP1 x64

su_v (suv-lp)
description: updated
Revision history for this message
Alvin Penner (apenner) wrote :

- reproduced on Windows 7, Inkscape 0.91 r13725 (Jan 30 2015)
- reproduced on Windows XP, Inkscape 0.91+devel r13867 (Jan 23 2015)

Revision history for this message
Alvin Penner (apenner) wrote :

there is a temporary workaround available:

- go to Edit->Preferences
- click on Input/Output->SVG Output
- change Numeric Precision from 8 to 7

Revision history for this message
Alvin Penner (apenner) wrote :

the problem is not limited to just stroke-width. It shows up also in the properties fill-opacity and stroke-miterlimit. It can be triggered in the XML editor without actually moving the object. Attached is a demo file. The original style variables are:

fill-opacity : 0.732
stroke-width : 1.05
stroke-miterlimit: 4.27

To trigger the bug, click on Edit->XML Editor. Select the line and click on the style property in the XML Editor. Note that the style still has the original values. Now click on the Set button. The style properties update to the the new values below.

fill-opacity : 0.73200001
stroke-width : 1.04999995
stroke-miterlimit: 4.26999998

This was done with a numericalprecision value of 8 in the SVG Output preferences, which is the default.
The error appears to be coming from the routine 'write_num' in the file svg\css-ostringstream.cpp. In order to fix this, it would probably be necessary to use some formatting code that is more similar to the code for writing the 'd' parameter for the path data, which appears to be in the routine svg\path-string.cpp.

Revision history for this message
Alvin Penner (apenner) wrote :

sorry, I misspoke myself, the source of the problem is not in the file 'svg\css-ostringstream.cpp', or the routine 'write_num'. The source of the problem is that the data coming in to this routine, which is variables like fill-opacity, stroke-width, and stroke-miterlimit, are all originally declared to be single-precision variables, even though they are being passed into a routine that accepts double-precision variables. Therefore it is unavoidable that there will be some round-off error in them if they are inspected at the 8th significant digit, which is the default behavior in Inkscape.
    It is not really feasible to convert these variables from single-precision to double-precision at this stage of the game, and there is very little practical purpose in doing so. Therefore I would recommend using the above workaround, in comment 5. I believe this should solve the problem in all cases.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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