Bug 77298 - inkscape fails to print thin lines to PDF
Summary: inkscape fails to print thin lines to PDF
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.12.16
Hardware: Other All
: medium normal
Assignee: Chris Wilson
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: cairo-1.14
  Show dependency treegraph
 
Reported: 2014-04-11 02:43 UTC by Jürgen Weigert
Modified: 2017-10-17 00:52 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
reproducer (1.29 KB, text/plain)
2014-04-11 02:45 UTC, Jürgen Weigert
Details
Example output from the reproducer with missing objects. (8.37 KB, text/plain)
2014-04-11 02:48 UTC, Jürgen Weigert
Details
Example output from the reproducer when good. (8.83 KB, text/plain)
2014-04-11 02:51 UTC, Jürgen Weigert
Details
suggested fix. (1.04 KB, patch)
2014-04-11 12:43 UTC, Jürgen Weigert
Details | Splinter Review
Suggested fix. Different approach. (583 bytes, patch)
2014-04-12 00:44 UTC, Jürgen Weigert
Details | Splinter Review
Don't cull thin lines on vector backends (20.75 KB, patch)
2015-09-21 12:17 UTC, Adrian Johnson
Details | Splinter Review
cairo test for thin lines (6.64 KB, patch)
2015-09-21 12:18 UTC, Adrian Johnson
Details | Splinter Review
attachment-30721-0.html (1.99 KB, text/html)
2015-09-21 16:16 UTC, Bill Spitzak
Details

Description Jürgen Weigert 2014-04-11 02:43:50 UTC
Since 1.12.3, cairo cannot render fine lines to pdf. 1.12.2 was the last version that worked.


http://cgit.freedesktop.org/cair/diff/?id=bdf83008f4b2c723fd8e65e2a92bc47a2e7bc442

introduced this code in cairo-compositor.c:_cairo_compositor_stroke

   if (_cairo_pen_vertices_needed (tolerance, style->line_width/2, ctm) <= 1)
        return CAIRO_INT_STATUS_NOTHING_TO_DO;

The idea was to avoid lines that would be invisible when rasterized. While this is a valid logic for raster backends, it is a bad idea for PDF output. There we want to see all fine lines.

My specific use case is generating a lasercutter drawing for an Epilog Zing laser with inkscape. There the hardware would raster anything thicker than 0.02mm, and cut 0.01mm or below. 1.12.3 skips lines below 0.036mm, 1.13.1 skips lines below 0.018mm -- which is still not enough to safely drive my lasercutter.

See also https://bugs.launchpad.net/inkscape/+bug/1174909

Check out the attached reproducer.
Comment 1 Jürgen Weigert 2014-04-11 02:45:43 UTC
Created attachment 97205 [details]
reproducer
Comment 2 Jürgen Weigert 2014-04-11 02:48:52 UTC
Created attachment 97206 [details]
Example output from the reproducer with missing objects.
Comment 3 Jürgen Weigert 2014-04-11 02:51:20 UTC
Created attachment 97207 [details]
Example output from the reproducer when good.
Comment 4 Jürgen Weigert 2014-04-11 12:43:41 UTC
Created attachment 97220 [details] [review]
suggested fix.

Please double check if num_vertices == 1 should never be done (for PDF).

I am not sure why this was introduced at all. With 1.12.2 the lowest num_vertices value was 4, which assured that all objects are rendered to the PDF.
Comment 5 Jürgen Weigert 2014-04-12 00:44:29 UTC
Created attachment 97247 [details] [review]
Suggested fix. Different approach.

Contributed by Patrick Himmelmann. Now we have something to discuss. Maybe we find a third alternative, so that the logic for raster backends continues to discard small objects, but the logic for vector backends includes everything?
Comment 6 Sebastien Bacher 2014-06-06 10:01:26 UTC
Could somebody review the suggested change there?
Comment 7 Adrian Johnson 2014-06-06 11:05:15 UTC
This is not really a pdf specific problem. We need to always pass strokes through to the vector backends no matter how thin. I don't know the best way to do this as I am not familiar with that code that these patches modify.
Comment 8 Jürgen Weigert 2014-10-07 18:28:26 UTC
(In reply to Sebastien Bacher from comment #6)
> Could somebody review the suggested change there?

Patrick's version is best, please go ahead with this patch!
Comment 9 Jürgen Weigert 2015-03-22 16:01:59 UTC
@Chris Wilson et all:

I'd like to raise priority on this issue.
We know the issue to exist for several years now on Linux systems. Recently we see more and more Windows systems to suffer from the same issue. The attached patch is simple and fixes the issue. 

Is there anything I can do to summon a cairo maintainer here?
Comment 10 Sebastien Bacher 2015-09-21 07:13:06 UTC
is there anyone wanting to review that one?
Comment 11 Adrian Johnson 2015-09-21 12:17:46 UTC
Created attachment 118380 [details] [review]
Don't cull thin lines on vector backends

The patch didn't work for my test case and broke many other tests.

Attached is a new patch that seems to fix the bug. The patch ensures a minimum line width when calculating stroke extents on vector backends.
Comment 12 Adrian Johnson 2015-09-21 12:18:55 UTC
Created attachment 118381 [details] [review]
cairo test for thin lines

This patch contains a cairo test for thin lines.
Comment 13 Bill Spitzak 2015-09-21 16:16:17 UTC
Created attachment 118385 [details]
attachment-30721-0.html

This seems excessively complex, rather than having the later handler (the
one turning a non-zero float into a zero fixed) be patched instead. I
figure it would be correct for all backends to turn very tiny but non-zero
line widths into the smallest ones they can render.


On Mon, Sep 21, 2015 at 5:18 AM, <bugzilla-daemon@freedesktop.org> wrote:

> *Comment # 12 <https://bugs.freedesktop.org/show_bug.cgi?id=77298#c12> on
> bug 77298 <https://bugs.freedesktop.org/show_bug.cgi?id=77298> from Adrian
> Johnson <ajohnson@redneon.com> *
>
> Created attachment 118381 [details] [review] <https://bugs.freedesktop.org/attachment.cgi?id=118381> [details] <https://bugs.freedesktop.org/attachment.cgi?id=118381&action=edit> [review] <https://bugs.freedesktop.org/page.cgi?id=splinter.html&bug=77298&attachment=118381>
> cairo test for thin lines
>
> This patch contains a cairo test for thin lines.
>
> ------------------------------
> You are receiving this mail because:
>
>    - You are watching the QA Contact of the bug.
>
>
Comment 14 Adrian Johnson 2015-09-21 21:28:39 UTC
(In reply to Bill Spitzak from comment #13)
> Created attachment 118385 [details]
> attachment-30721-0.html
> 
> This seems excessively complex, rather than having the later handler (the
> one turning a non-zero float into a zero fixed) be patched instead. I
> figure it would be correct for all backends to turn very tiny but non-zero
> line widths into the smallest ones they can render.

We don't want to alter the line width on the vector backends. If a 0.001mm line width is specified for pdf that is the line width it should use. My patch only alters the line width when the extents are measured for the purpose of culling 0 width/height objects.
Comment 15 Adrian Johnson 2015-10-17 08:11:56 UTC
I've commit my patch and testcase.
Comment 16 ~suv 2015-10-17 10:39:12 UTC
@Adrian - the commit broke the quartz backend (and based on comments on irc the gl backend too):

  CC       cairo-quartz-surface.lo
cairo-quartz-surface.c:2265:12: error: too few arguments to function call, expected 5, have 4
                         content);
                                ^
./cairoint.h:1335:1: note: '_cairo_surface_init' declared here
cairo_private void
^
./cairo-compiler-private.h:133:27: note: expanded from macro 'cairo_private'
#define cairo_private       cairo_private_no_warn cairo_warn
                            ^
./cairo-compiler-private.h:120:31: note: expanded from macro 'cairo_private_no_warn'
#define cairo_private_no_warn   __attribute__((__visibility__("hidden")))
                                ^
1 error generated.
make[3]: *** [cairo-quartz-surface.lo] Error 1
Comment 17 Adrian Johnson 2015-10-17 11:34:35 UTC
Should be fixed now.
Comment 18 ~suv 2015-10-17 11:45:30 UTC
(In reply to Adrian Johnson from comment #17)
> Should be fixed now.

Thx a lot - build fix confirmed for quartz, quartz-image, xml and tee surface backends.
Comment 19 Damien Grassart 2015-10-17 11:53:07 UTC
It seems the GL backend still doesn't compile as a couple uses of _cairo_surface_init weren't updated:

cairo-gl-source.c:76:5: error: too few arguments to function ‘_cairo_surface_init’
cairo-gl-source.c:103:5: error: too few arguments to function ‘_cairo_surface_init’
Comment 20 Damien Grassart 2015-10-17 12:10:26 UTC
There's also a similar error for _cairo_path_fixed_approximate_stroke_extents():

cairo-gl-msaa-compositor.c:584:6: error: too few arguments to function ‘_cairo_path_fixed_approximate_stroke_extents’
Comment 21 Eduard Braun 2017-10-16 19:53:35 UTC
This issue is not fixed yet, see comments downstream:
https://bugs.launchpad.net/inkscape/+bug/1174909

Could someone have another look at this?
Comment 22 Adrian Johnson 2017-10-16 19:58:06 UTC
Can you test with git master. There was a fix a couple of weeks ago for thin curved lines:

https://cgit.freedesktop.org/cairo/commit/?id=bec8c7508ebc0f69266f9aebe9903539391c519b
Comment 23 Eduard Braun 2017-10-17 00:52:38 UTC
Ah, great! Issue is indeed fixed in current master (132794f6832ea83e2f9a72e11b05080d2cdf80f8).


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.