-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Raise error when zero length is provided to dash
- Loading branch information
1 parent
371ef9d
commit e65c244
Showing
2 changed files
with
13 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e65c244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
What is the reason for the "zero length" restriction? Currently, I have a problem to render SVG files with dotted lines, because they are represented as a sequence of lines with zero length. My understanding is that line with zero length should be represented as a single point in SVG. (this understanding can be wrong ... of course)
When I comment out this small if case, SVG generation works well. Do you think, there could be some switch, which would disable this restriction in case of SVG for example?
Thanks and have a nice day.
Petr
e65c244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nowass I can't tell for sure as I'm not the author but it appears that 0 dash length is indeed invalid.
Here's a relevant part from PDF Spec [1]:
Basically, Line Dash Pattern array specifies advances. All 0 values would provide no advancement effectively not letting to draw the line.
[1]: PDF Reference 1.7, Section 4.3.2: Details of Graphic State Parameters, Line Dash Pattern
e65c244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @pointlessone,
thanks for your feedback ... honestly, this I didn't know that.
On the other hand, my understanding of this specification is that it zero length is not forbidden if there is another one non-zero. I would say that it depends on which segment length is zero ... for example, a segment defined by [0,2] (ON phase 0 units, OFF phase 2 units) should be still valid. Therefore the check should verify if not all values are zero, and if there are some zeroes in which phases it is.
This is my feeling which is based on how the dashed lines are interpreted by several different software (viso, inkscape, smartDraw, ...) ... but maybe I am wrong ...
P.S. as I mentioned ... if this if case is commented out, prawn-svg module knows how to handle this kind of line, and the dotted lines are rendered correctly
e65c244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right about all dash length being zero. This appears to be a Prawn bug. Could you please file an issue? Also PRs are much appreciated as well. ;)
e65c244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm my own understanding of the above... we're currently raising on
any?
values that are zero in the array, that probably should beall?
(I'll leave it up to whoever fixes this to confirm that 😄 )
e65c244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@practicingruby Your understanding is correct.
e65c244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @practicingruby
I have just tried generate dotted line defined by dashed array [0,1.25] (in SVG image) with
all?
option and it seems to work well (PdfXchange Editor & Acrobat reader DC used for output verification)e65c244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @practicingruby @pointlessone,
I have one stupid question ... how should I proceed to have this problem fixed? Unfortunately, I am not such programmer guru to be able to provide a "reasonable" fix :-/
From my point of view, the new issue was created (#999) ... should I take any other action ?
e65c244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nowass Unfortunately we don't have much time available at the moment. So your options are either wait for us or persuade someone else to provide a fix.
I understand that is inconvenient but so is the nature of free open source work.
e65c244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pointlessone ok, clear ... do I understand correctly, that most probably it will be fixed, but nobody knows when? :-)
e65c244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nowass It will definitely get fixed but yes, no one knows when.
e65c244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pointlessone OK, clear :-)
e65c244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nowass @pointlessone See pull request #1001 for a fix 😃