non-scaling stroke width (not affected by zoom level) - SVG Tiny 1.2 feature

Bug #448286 reported by Marián Kadaňka
44
This bug affects 8 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Wishlist
Unassigned
Nominated for 0.91.x by Lenge

Bug Description

I would like to see hairline stroke width implemented, that is, stroke is always very thin regardless of zoom level.

Tags: svg
tags: added: svg
Revision history for this message
Pablo Trabajos (pajarico) wrote :

If I remember correctly this was recently mentioned on bug or mailing lists. It's part of SVG Tiny 1.2 as a vector-effect [1].

[1]: http://www.w3.org/TR/SVGTiny12/painting.html#VectorEffectProperty

Changed in inkscape:
importance: Undecided → Wishlist
status: New → Confirmed
summary: - hairline stroke width
+ non-scaling stroke width (not affected by zoom level)
Revision history for this message
su_v (suv-lp) wrote : Re: non-scaling stroke width (not affected by zoom level)

The recent inkscape-devel discussion about guide lines mentions «to have 0-thickness lines with a border (different than lines with no border), so they are always drawn with 1 pixel width depending on the device resolution (1 point if printed, 1 pixel on screen regardless the zoom level, etc...)»
<http://thread.gmane.org/gmane.comp.graphics.inkscape.devel/31622/focus=31651>

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

…oops - meant this message: «This is not allowed in SVG 1.1. There is a vector effect called "non-scaling-stroke" in SVG 1.2 Tiny which effectively lets you specify the width in output user units (which is more powerful than simple hairline strokes :) )»
<http://thread.gmane.org/gmane.comp.graphics.inkscape.devel/31622/focus=31687>

Revision history for this message
Lenge (spampot) wrote :

Just to clarify - "hairline" stroke width and "non-scaling" stroke width are two different things:

1.) A "hairline" is a line that is visible, but has a thickness of EXACTLY zero in all calculations (despite its visibility). In effect, objects with a "hairline" border do have a clearly visible border, but the border has NO influence on the objects' width or height (both are exactly the same as if the object had no border at all). Hairlines are typically drawn with the smallest possible width (such as 1 device pixel) at whatever zoom.

Example: When I align an object to either the top or the bottom of a horizontal hairline, the object must end up in the exact same position in either case. The same holds for aligning to the left/right edges of vertical hairlines.

2.) A "non-scaling" line has a thickness that remains constant regardless of the zoom level or if any scaling operations are performed on the object. However, the line thickness may have any value - it does NOT need to be exactly zero as for hairlines.

I would like to see both features available in Inkscape (just as they are in CorelDraw). However, "hairlines" are more important to me because there is currently (as of 0.47) NO possibility in Inkscape to set a line width of exactly zero, but still end up with a visible line.

Revision history for this message
LucaDC (lucadc) wrote :

Actually, a "non-scaling" line thickness is not supposed to remain constant when changing zoom level. It has a fixed thickness only with regard to scaling operations while zoom level is involved in the visualization of the document.

So, a "hairline" will have a, let's say, 1 pixel width for visualization and is indeed a "non-scaling" for visualization (i.e. zoom level) but should be a 0 width for calculations (hence there's no point in specifying if it's "non-scaling" or not for calculations).

It's important not to make confusion between the document's unit and the visualization device's unit: 1 pixel is always 1 pixel on screen but it's not in an Inkscape's document: if you change the zoom level you can have 1 (Inkscape's) pixel that's 4x4 or 0,27x0,27 (LCD's) pixels on screen.

The attributes "hairline" and "non-scaling" refer to different and disjointed scaling scenarios (and needs).

Revision history for this message
Lenge (spampot) wrote :

LucaDC is right - my previous comment is wrong in one point:
"Non-scaling" lines are supposed to retain their thickness when scaling operations are performed, but the thickness DOES zoom along with the rest of the object.

Revision history for this message
Dusan Maliarik (dusan-maliarik) wrote :

Is vector-effect: non-scaling-stroke implemented or it's not? I'm trying to achieve something very similar. Except that I _zoom_ my SVG using viewBox. But apparently my stroke-width isn't scaled along with the rest of the document.

See the attached image, the only thing that is different between those 2 images, is SVG width, height and viewBox. IMHO, the white text stroke on the right, should be thicker. Also that stroke is not applied directly on the black text, but on a cloned text below it (to prevent _inner stroke_).

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

Dusan Maliarik wrote
> Is vector-effect: non-scaling-stroke implemented or it's not?

No, it is not part of the current SVG 1.1 specification (which Inkscape aims to support), and not implemented as custom feature in current inkscape (stable and development). Vector effects are

With regard to your example - could you attach the SVG source too? Was the screenshot done in Inkscape? Possibly it uses '%' as stroke width (which relates to the parent viewport [1]), but is not supported by Inkscape (bug #166725).

[1] «If a <percentage> is used, the value represents a percentage of the current viewport.»
    <http://www.w3.org/TR/SVG11/painting.html#StrokeWidthProperty>

Revision history for this message
Lenge (spampot) wrote :

> No, it is not part of the current SVG 1.1 specification (which Inkscape aims to support),
> and not implemented as custom feature in current inkscape

But still, hairlines are such an important feature that Inkscape should definitely have them.

By the way: Are hairlines part of ANY existing SVG specification?

If so, the implementation should conform to this spec.
If not, it should be provided as a custom feature.
But they should definitely be implemented.

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

Related (but not the same, according to the reporter):
Bug #1016763 “RFE: 'hairline' stroke-width”
<https://bugs.launchpad.net/inkscape/+bug/1016763>

Revision history for this message
Krzysztof Kosinski (tweenk) wrote :

SVG Tiny 1.2 provides this feature by setting the attribute vector-effect="non-scaling-stroke":
http://www.w3.org/TR/SVGTiny12/painting.html#NonScalingStroke

summary: - non-scaling stroke width (not affected by zoom level)
+ non-scaling stroke width (not affected by zoom level) - SVG Tiny 1.2
+ feature
Revision history for this message
Lenge (spampot) wrote :

In reply to comment #11:
It seems that the SVG Tiny 1.2 "non-scaling-stroke" feature does NOT account for hairlines (and thereby only covers one part of this bug). Note that it is NOT enough to make hairlines 1px and non-scaling - they also need to have a width of exactly zero in all position and size calculations.

Revision history for this message
ruffrecords (ianbell) wrote :

I use a program called FrontPanelDesigner that is used to create drawings of metal front panels and engraved text for use by CNC manufacturing equipment. The program will export front panels in .svg format so they can be used in documents as illustrations. However, the engraved text is not rendered correclty in Inkscape (but is rendered corrrectly by Chrome and Firefox). After discussion with the manufaturer's software engineers it appears that this is because the engraved text uses the "vector-effect=non-scaling-stroke" property. This appears not to be supported by Inkscape.

Cheers

ian

Revision history for this message
J Matthew Gaskill (jmgaskill) wrote :

...modifying the stroke-width in the example shown for the attribute vector-effect="non-scaling-stroke": http://www.w3.org/TR/SVGTiny12/painting.html#NonScalingStroke to

<line vector-effect="non-scaling-stroke" stroke="black" stroke-width="0" x1="32" y1="50" x2="32" y2="350"/>

perhaps adding a new item "hairline" to the units combobox (which would set the width to zero and deactivate the width box) would be a proper implementation. Visually Inkscape would always display "hairlines" as 1 px regardless of zoom factor.

I have been working on an Inkscape extension to generate output for the Universal brand of laser cutters -- right now I look for a width setting of exactly 1 pt to determine if a stroke should be a vector. This works well as long as an equivalent dimension in a another unit not used. A stroke width setting of 0 would be a slam dunk (as long as it is visible on screen).

This single change might generate even more wide spread adoption by laser cutting / engraving machine manufacturers since they would not have to purchase software from other vector drawing package vendors.

Revision history for this message
Rick-firefang (rick-firefang) wrote :

It's not quite the hairline feature you're asking for, but I created a patch for a new display mode that makes "hairlines" (anything smaller than half a pixel on screen) more visible: https://gitlab.com/inkscape/inkscape/merge_requests/365

Revision history for this message
Hachmann (marenhachmann) wrote :

It's actually implemented in Inkscape 0.92.3 - but can only be set via xml editor.

Try by appending ';vector-effect:non-scaling-stroke' to the style.

Revision history for this message
Hachmann (marenhachmann) wrote :

Maybe that could be added via extension? Or another button in the F&S dialog? (it really needs an 'advanced' panel, this doesn't need to be visible for everyone)

Revision history for this message
Hachmann (marenhachmann) wrote :

Usage in current Inkscape: https://framadrive.org/s/86dsDmnGLHNKec3 (mp4)

Revision history for this message
Lenge (spampot) wrote :

Two quick comments:

1.) IMO the usage video shows a buggy behavior:
As already said above, "non-scaling" lines are supposed to retain their thickness when scaling operations are performed on the object (such as resizing etc.), but the thickness DOES zoom along with the rest of the object. The video shows constant thickness when ZOOMING, which is NOT what "non-scaling" lines are about.

2.) The non-scaling feature is no substitute for "hairlines", which this bug originally was about.

Revision history for this message
Hachmann (marenhachmann) wrote :

1.) No. Did you watch the whole thing, or just the beginning?

2.) Maybe, don't know, but it was mentioned in one of the first comments there as a possible solution.

Revision history for this message
Hachmann (marenhachmann) wrote :

1. Sorry. That was incorrect. Yes, it's just for zooming. The other feature is a global switch in Inkscape, you can find that button on the selector tool's tool controls. It's not available per-object.

Revision history for this message
Hachmann (marenhachmann) wrote :

And, btw. the original report is about zooming:

"I would like to see hairline stroke width implemented, that is, stroke is always very thin regardless of zoom level."

Revision history for this message
Rick-firefang (rick-firefang) wrote :

Since SVG doesn't actually have hairline support, the best way I can think of to implement it in Inkscape is to set width=1px, vector-effect="non-scaling-stroke", and a new inkscape:vector-effect="hairline" property.

On screen, width=1px and vector-effect="non-scaling-stroke" imitates hairlines.

It doesn't necessarily work that way in PDFs or on printers. In PDF and Postscript, a hairline should have a width of 0. In the Windows print API, they should have a width of 1 and be drawn with the PS_COSMETIC pen. In these cases (printing or saving as PDF), drawing inkscape:vector-effect="hairline" lines with a width of 0 is reasonable. Cairo might require some small patches to treat these reasonably, but there seems to be some desire over on the Cairo team to handle hairlines consistently.

Revision history for this message
Lenge (spampot) wrote :

@Hachmann:
The original report was about hairlines, not about non-scaling lines, which is why zooming was mentioned. Non-scaling lines were added later, and the bug title was changed along with that. However, there are differences:

1.) A "hairline" is a line that is visible, but has a thickness of EXACTLY zero in all calculations. Objects with a "hairline" border have a visible border, but the border has absolutely NO influence on the objects' width or height (both are exactly the same as if the object had no border at all).
That's the important difference to "normal" lines (both scaling and non-scaling), which are either invisible (if their width is zero) or influence the objects width/height with their own thickness.
Hairlines are typically drawn with the smallest possible width (such as 1 device pixel) at whatever zoom, and their thickness remains zero when scaling operations are performed on the object.

Example: When I align an object to either the top or the bottom of a horizontal hairline, the object must end up in the exact same position in either case. The same holds for aligning to the left/right edges of vertical hairlines.

2.) A "non-scaling" line has a thickness that remains constant when any scaling operations (such as resizing) are performed on the object. If the border of an object is 2 mm and non-scaling, then it will stay 2 mm when the object is enlarged or shrunk. However, it will also remain "2 mm" when zooming, so in effect it DOES change its thickness when zooming (as do the entire page, the rulers, and the scale of what "2 mm" are).

The video you posted shows a line that doesn't change thickness when zooming, which is NOT what is expected from a "non-scaling" line. Instead, it should change thickness when zooming (just as "normal" lines), but NOT when the object is resized.

@Rick-firefang:
As far as I know, you are right that SVG doesn't have support for true hairlines. IMHO this is one of its most important shortcomings compared to other vector formats, and hairlines are so important that Inkscape should definitely have them. If that is not possible with "standard" SVG, they should be added as a custom feature.

A simple approach would be an option to treat lines with a width of exactly zero as hairlines. This means that they should be visible (unlike the SVG standard demands and unlike Inkscape currently draws them), but still remain ZERO (not "1 px" whatsoever) in all calculations such as positioning, width/height calculations etc.. To my knowlegde, a couple of other vector formats define and handle hairlines in this way.

Revision history for this message
Jonathan Hofinger (jhofinger) wrote :

Hi, this feature has been implemented in Inkscape 1.0, see https://wiki.inkscape.org/wiki/index.php/Release_notes/1.0#SVG_and_CSS.

Closing as fixed.

Closed by: https://gitlab.com/jhofinger

Changed in inkscape:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

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