Inset/outset step size change with page units

Bug #1542093 reported by Windell Oskay
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Medium
Alvin Penner
0.92.x
Triaged
Medium
Alvin Penner

Bug Description

The Inset/Outset feature step size appears to depend upon the page unit system, rather than upon the value set in the preferences.

Tested on Inkscape 0.91 r13725. Present on both Mac and Windows

Steps to reproduce:

1. Open a new document with A4 size. (File> Templates > A4)

2. Open global preferences, set Inset/Outset step size to 1 px. Close preferences.

3. On the page, create a closed path, for example with the freehand (pencil) or circle tool.

4. Make that object a well-defined initial size. For example, 100 mm x 100 mm, with solid fill and no stroke.
Copy this object to the clipboard, for later use as well.

Select the object.

5. Use Path>Outset to increase the size of the object.

Expected behavior: Object is larger in both dimensions by approximately 2 px.

Actual behavior: object is larger, roughly 102 x 102 mm. (It appears to have been outset by 1 mm, not 1 px.)

6. Open a new document with Letter size (File > Templates > Letter)

7. Optional: Check preferences, note that Inset/Outset step size is still 1 px. Close preferences.

8. Paste object from clipboard, and select it.

9. Use Path>Outset to increase the size of the object.

Expected behavior: Object is larger in both dimensions by approximately 2 px.

Actual behavior: object is larger, roughly 150 x 150 mm. (It appears to have been outset by 1 inch.)

10. Create a new default document (File > New)

11 Optional: Check preferences, note that Inset/Outset step size is still 1 px. Close preferences.

12. Paste object from clipboard, and select it.

13. Use Path>Outset to increase the size of the object.

Expected behavior: Object is larger in both dimensions by approximately 2 px.

Actual behavior is as expected: object is larger, roughly 100.5 x 100.5 mm. (It appears to have been outset by 1 pixel.)

Similar behavior can be seen with the Inset feature.

Revision history for this message
LucaDC (lucadc) wrote :

IMHO this is not a bug.
Actually, the 'px' unit should be referred to as 'user unit' which is the document's default unit. Under this assumption the described behavior is correct.

Revision history for this message
Windell Oskay (windell) wrote :

@LucaDC,
That may well be a valid description. But if so, it is (in my view) still inconsistent with the behavior that a user should expect from the preferences dialog.

For example, the same "steps" pane of the Global Preferences offers different step sizes for scaling an object.

If we set the "Scale" step size to be 1 px, then scaling up a 100 mm x 100 mm object (with ">") does scale that object up by 1 px in size (1 inch/90). (Scaling twice gives an object of 100.5 x 100.5 mm, just as though it had been outset by 1 px.)

And, if we set the "Scale" step size to be 1 cm, then scaling up a 100 mm x 100 mm object (with ">") does scale that object up by 1 cm in size. Scaling twice gives an object of 120 x 120 mm, just as though it had been outset by 1 cm.)

This behavior seems quite reasonable, and is consistent across different page templates (A4, letter).

If the behavior that you describe for the meaning of 'px' -- that it simply means the document's default unit -- were followed, then this would not be the case. (Or, there is a bug in the implementation of the scale step feature.)

Let us also pick an example of inset/outset with specific step size units that should be independent of the specific definition of 'px.'

Start with an A4 template, and an initial object that is 100 mm x 100 mm.
Set the Inset/Outset step size (in preferences) to 1 cm.
Use Path>Outset to increase the size of the object.

Expected behavior: should be that the resulting object (outset by 1 cm) is 120 mm x 120 mm.
Actual behavior: Object is larger, roughly 170.8 mm x 170.8 mm.

(This is outset not by 1 cm, but by 35.4 mm, the number of pixels per cm.)

Start with a letter template, and an initial object that is 100 mm x 100 mm.
Set the Inset/Outset step size (in preferences) to 1 cm.
Use Path>Outset to increase the size of the object.

Expected behavior: should be that the resulting object (outset by 1 cm) is 120 mm x 120 mm.
Actual behavior: Object is larger, roughly 280 mm x 280 mm.
(This is outset not by 1 cm, but by 90 mm, the number of pixels per inch.)

It is my opinion that this is incorrect behavior because an outset of 1 cm size should produce an outset of 1 cm, regardless of the page template used.

Revision history for this message
LucaDC (lucadc) wrote :

It seems you're right: actually 'px' is the only unit working correctly. All other units seem broken because they apply the (incorrect) transformation between the default 96 DPI 'px' and the selected unit, then apply it in the current document unit.

Tested with rev14630 on Windows XP:
 - mm as default unit;
 - A4 page 297x210 mm;
 - scale 1,0 in both x and y (viewbox 0 0 210 297);
 - drawn a rectangle of 100 x 100 mm using guides (no transformations) (*1), miter join, butt cap (*2);
 - set outset 1 cm: got a 175,59 x 175,59 mm rectangle (+10/25.4*96 mm on each side);
 - set outset 1 px: got a 102 x 102 mm rectangle (+1 mm on each side).

(*1) If a 1 x 1 mm rectangle is drawn, then stretched to 100 x 100 mm with preserved transformations (100x transformation), then a 1 cm outset makes it become a 2100 x 2100 mm rectangle. In this case the unit seems to have been correctly considered but the transformation matrix is not compensated for: +10*100 mm on each side.

(*2) The outset takes into consideration the border path join and cap types. If round join and round cap are used, the result is a rounded rectangle 175,872 x 175,888 mm (like if 25,3 mm/inch was used). This setting is remembered even if the border is removed.

Revision history for this message
su_v (suv-lp) wrote :

On 2016-02-05 09:32 (+0100), LucaDC wrote:
> the 'px' unit should be referred to as 'user unit' which is the
> document's default unit.

To clarify (the comment is not correct): 'px' can refer (depending on the context) to 'SVG user units' or to the length of a CSS pixel.

Neither of those can be viewed or changed directly in the GUI of Inkscape 0.91.

The 'document units' in Inkscape's Document properties dialog refer to the units used in the GUI. This setting only affects the _display_ (how lengths and coordinates are represented in the GUI), and does not affect the document scale (neither in 0.91 r13725 nor in trunk).

On 2016-02-05 12:19 (+0100), LucaDC wrote:
> the default 96 DPI 'px'

Just keep in mind that 96dpi are trunk only (the reporter filed the report based on current stable 0.91 which still uses 90dpi).

Revision history for this message
su_v (suv-lp) wrote :

Reproduced with Inkscape 0.91 r13725 and 0.91+devel r14630 on OS X 10.7.5.

Of the three 'Steps' preferences, only the inset/outset option exposes incorrect unit handling.

AFAIU 'px' in the unit selector of the 'Steps' preferences should always refer to the real length of a CSS pixel (based on the drawing scale defined by SVGRoot's width, height and viewBox attributes).

Ideally, all 3 Steps options (move, scale, inset/outset) would have an additional unit 'SVG user units' (or maybe instead 'Display units') - this would better support the new templates in Inkscape >= 0.91 which vary the drawing scale (the "real" size of an SVG user unit (aka 'px' in SVG source)) depending on default units used in the template. Otherwise, the user needs to change the global preference setting depending on the currently edited document to have meaningful step sizes.

Changed in inkscape:
importance: Undecided → Medium
milestone: none → 0.92
status: New → Confirmed
tags: added: preferences units
Revision history for this message
LucaDC (lucadc) wrote :

IMHO the three 'Steps' preferences should be moved to document's properties. In any case they are going to mismatch with some document if more than one unit is used in it, so the user will always have to adjust them.
This would also solve dealing with templates.

~suv, actually I didn't get the difference you pointed out between 'SVG user units' and 'CSS pixel'. My understanding is that in SVG context they are just the same i.e. '1' in the current viewbox, so my comment should be correct. Please, tell me if I'm wrong.
Also, I did not intend to refer to 'document's unit' as in the context of display unit, but in the sense of the unit on which the document is based on or, in other words, the unit used to store numbers in the SVG file. Maybe I should have written 'document's internal unit'. Thanks for pointing this out.

Revision history for this message
LucaDC (lucadc) wrote :

I see that CSS has finally defined 1 px to be 1/96 inch in contrast with their previous definitions "because too much existing content relies on the assumption of 96dpi, and breaking that assumption breaks the content." (https://www.w3.org/TR/css3-values/#absolute-lengths).

Now that 'CSS px' has become an absolute unit, I agree that a new (or a way to refer to the current) unit is needed.

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

fix committed to rev 15610

jazzynico (jazzynico)
Changed in inkscape:
assignee: nobody → Alvin Penner (apenner)
milestone: 0.92 → 0.93
status: Confirmed → Fix Committed
tags: added: backport-proposed
Max Gaukler (mgmax)
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.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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