Bug 84693 - Dotted lines not rendered correctly
Summary: Dotted lines not rendered correctly
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-05 19:23 UTC by a.amann
Modified: 2016-05-16 23:01 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Horizontal dotted line, gets misrendered by poppler (1.53 KB, text/plain)
2014-10-05 19:23 UTC, a.amann
Details
fat dots appear in the horizontal line, which should not be there (22.27 KB, text/plain)
2014-10-05 19:25 UTC, a.amann
Details
expected rendering of horizontal line (24.93 KB, image/png)
2014-10-05 19:26 UTC, a.amann
Details
fat dots appear in the horizontal line, which should not be there (22.27 KB, image/png)
2014-10-05 19:28 UTC, a.amann
Details
Horizontal dotted line, gets misrendered by poppler (1.53 KB, application/pdf)
2014-10-05 19:29 UTC, a.amann
Details
Avoid line joins on dashed lines (611 bytes, patch)
2016-03-16 12:45 UTC, Thomas Freitag
Details | Splinter Review
Omit join styles if angle is 0 (754 bytes, patch)
2016-03-17 12:15 UTC, Thomas Freitag
Details | Splinter Review
Problem on the + signs (40.24 KB, application/download)
2016-03-19 10:54 UTC, Albert Astals Cid
Details
Omit join styles if angle is 0 (1.62 KB, patch)
2016-03-20 10:52 UTC, Thomas Freitag
Details | Splinter Review
the diff of renderings of page 60 of bug-poppler77549-3.pdf (8.81 KB, image/png)
2016-05-11 21:42 UTC, Albert Astals Cid
Details
rendered with 600 dpi new, 72 dpi new, 72 dpi old (155.34 KB, image/png)
2016-05-12 07:55 UTC, Thomas Freitag
Details
the same clip with acrobat zoomed to 1200 % (3.67 KB, image/png)
2016-05-12 08:00 UTC, Thomas Freitag
Details

Description a.amann 2014-10-05 19:23:16 UTC
Created attachment 107371 [details]
Horizontal dotted line, gets misrendered by poppler

Fat Dotted lines are not always rendered correctly. See for example the attached pdf file "test.pdf", which was created using the following python snippet:

-----------------------
import numpy as np
import matplotlib.pylab as plt

fig, ax = plt.subplots()
fig.patch.set_visible(False)
ax.axis('off')

myx = np.linspace(0,1)
plt.plot(myx, np.zeros_like(myx), "b:",linewidth=10)


plt.savefig("test.pdf")
------------------------

When I open the resulting file in okular, I get annoying fat dots along the horizontal line as shown in the attached file "test_dump.png". If I save instead of .pdf in .png (or .eps) format, okular gives me what is shown in "test_dump_correct.png", which is also resembling what comes on the screen. 

This misrenedering happens with okular, but also with xpdf, which brought me to the conclusion that this might be a problem in poppler, which I understand is the underlying library.
Comment 1 a.amann 2014-10-05 19:25:30 UTC
Created attachment 107372 [details]
fat dots appear in the horizontal line, which should not be there
Comment 2 a.amann 2014-10-05 19:26:31 UTC
Created attachment 107373 [details]
expected rendering of horizontal line
Comment 3 a.amann 2014-10-05 19:28:23 UTC
Created attachment 107374 [details]
fat dots appear in the horizontal line, which should not be there
Comment 4 a.amann 2014-10-05 19:29:43 UTC
Created attachment 107375 [details]
Horizontal dotted line, gets misrendered by poppler
Comment 5 Albert Astals Cid 2014-10-05 21:48:34 UTC
I'm regtesting a patch, let's see if it doesn't break any file
Comment 6 Albert Astals Cid 2014-10-05 22:40:16 UTC
meh, the patch regresses other files, need to study more the code.
Comment 7 Thomas Freitag 2016-03-16 12:45:30 UTC
Created attachment 122346 [details] [review]
Avoid line joins on dashed lines

This patch could be a possible solution.

@Albert: I'm not sure if You like it, but I don't have any better idea at the moment. And because that PDF is rather hypothetical (instead of one moveto and one lineto tons of lineto's to draw one horizontal line) I wouldn't care if You reject this patch J
Comment 8 Thomas Freitag 2016-03-17 08:59:05 UTC
Stop any investigation! I just encountered a hint in the spec:

Join styles shall be significant only at points where consecutive segments of a path connect at an angle; segments that meet or intersect fortuitously shall receive no special treatment.

If I take that into account, I can solve this issue without any doubt. I just regtest a new patch.
Comment 9 Thomas Freitag 2016-03-17 12:15:17 UTC
Created attachment 122372 [details] [review]
Omit join styles if angle is 0

This patch solves it
Comment 10 Albert Astals Cid 2016-03-19 10:54:14 UTC
I'm going to go on the almost-nit-picking side and say that the "+" signs of the attached page have rounded corners on Adobe Reader (old linux version, if you have a newer windows version around check, maybe it changed) and the unpatched poppler but with your patch they don't have them anymore (have to zoom a lot to see the difference).

Do you think it's worth investigating why?
Comment 11 Albert Astals Cid 2016-03-19 10:54:48 UTC
Created attachment 122427 [details]
Problem on the + signs
Comment 12 Thomas Freitag 2016-03-20 09:51:03 UTC
(In reply to Albert Astals Cid from comment #10)
> I'm going to go on the almost-nit-picking side and say that the "+" signs of
> the attached page have rounded corners on Adobe Reader (old linux version,
> if you have a newer windows version around check, maybe it changed) and the
> unpatched poppler but with your patch they don't have them anymore (have to
> zoom a lot to see the difference).
> 

In the actual windows versions it has round corners, too, so it's not nit-picking, it's a really regression!

> Do you think it's worth investigating why?

Of course, even it can become heavy. I first will try to reduce it to the plus signs. I wonder, why it runs into the line join section in splash... I need to find out. If I just look at the output it should run in the line cap section...

I come back when I find the reason.
Comment 13 Thomas Freitag 2016-03-20 10:49:46 UTC
I think, I have it: The plus signs are drawn to and from to the endpoints, so the endpoints are no really endpoints and therefore no line caps, but there are line joins. But my former patch doesn't distinguish between an angle of 0 and an angle of 360 degrees. I'll upload a new one.
Comment 14 Thomas Freitag 2016-03-20 10:52:31 UTC
Created attachment 122438 [details] [review]
Omit join styles if angle is 0

This also detects angles of 360 degrees
Comment 15 Albert Astals Cid 2016-05-10 21:40:58 UTC
I see some small changes in rendering in
page 60 of bug-poppler77549-3.pdf (bottom right)
and
page 114 of title_font_compresses.pdf

Not sure if you have those files

$ sha256sum bug-poppler77549-3.pdf
5485834aee424661a4fa49fdeaab650e4d57834fc0cafbf989a29db501b5106e  bug-poppler77549-3.pdf
$ sha256sum title_font_compresses.pdf 
ca35993bc13a2a14fa48440740b727e6a971739fd7f4090c9ecd9486358c94ec  title_font_compresses.pdf
Comment 16 Thomas Freitag 2016-05-11 08:48:33 UTC
(In reply to Albert Astals Cid from comment #15)
> I see some small changes in rendering in
> page 60 of bug-poppler77549-3.pdf (bottom right)
> and
> page 114 of title_font_compresses.pdf
> 
> Not sure if you have those files
> 

I have bug-poppler77549-3.pdf, but I can't find title_font_compresses.pdf.

I looked at the page 60 and can confirm that the output is different with and without the patch, but to be true, I can't see the difference, neither in comparing the PNG's nor by looking at the difference picture, even if rendered with 300 dpi. So I created an histogram of the difference picture (300 dpi, colorspace grey):

  Histogram:
 155530745: (  0,  0,  0) #000000 gray(0,0,0)
         1: (  0,  0,  0) #000000 gray(0,0,0)
         3: (  1,  1,  1) #010101 gray(1,1,1)
        18: (  2,  2,  2) #020202 gray(2,2,2)
        14: (  3,  3,  3) #030303 gray(3,3,3)
        12: (  4,  4,  4) #040404 gray(4,4,4)
         1: (  5,  5,  5) #050505 gray(5,5,5)
         1: (  6,  6,  6) #060606 gray(6,6,6)
         5: ( 18, 18, 18) #121212 gray(18,18,18)

I interprete this that from round about 155 million pixels there are 55 pixels different, with a highest difference of 18, so not completely different but there are differences in anti aliasing effects.
And when I look at the page itself I encounter that there are a lot "dashed" vertical or horizontal lines, and my patch omit join styles for horizontal and vertical lines, which seems to be correct according to the PDF spec.

If You have another opinion please give me more information where You worry about.

If You think that the differences of title_font_compresses.pdf has other reasons please send me that pdf so that I can have a look at it.
Comment 17 Albert Astals Cid 2016-05-11 21:42:56 UTC
Created attachment 123631 [details]
the diff of renderings of page 60 of bug-poppler77549-3.pdf

Look at the bottom right-ish part, there's a vertical line that is around 9 pixels tall that changes, seems a specific enough change that may be a problem?

I can be convinced it's "ok", but 9 pixels one after the other seems a reasonable "big ish" change.
Comment 18 Thomas Freitag 2016-05-12 07:55:43 UTC
Created attachment 123639 [details]
rendered with 600 dpi new, 72 dpi new, 72 dpi old

You are really good in detecting differences, Albert. I haven't seen the differences before.
But I fear I can't do anything in this case, look at this screenshot, from left to right:
- is rendered with 600 dpi with my patch. You see a nearly solid line, and the output is with 600 dpi the same or nearly the same as without my patch
- is rendered with 72 dpi with my patch
- is rendered with 72 dpi without my patch
My conclusion is that the vertical line must be a dashed line, but so thin, that even with 600 dpi You can't see the gaps, there it just looks like a solid line, where with 72 dpi you can see some anti-aliasing effects of the dashes which are different because omitting the join styles.
Comment 19 Thomas Freitag 2016-05-12 08:00:31 UTC
Created attachment 123640 [details]
the same clip with acrobat zoomed to 1200 %

This is how acrobat shows it when zoomed to 1200 %. It is similar what pdftoppm produces when rendered with 600 dpi, but acrobat has some special handling for thin lines.
And one last point: The differences vanishes between with and without my patch when increasing the resolution!
Comment 20 Albert Astals Cid 2016-05-16 23:01:10 UTC
Ok, you've convinced me.

Pushed!


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.