You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by bu...@apache.org on 2007/04/13 01:28:56 UTC

DO NOT REPLY [Bug 42109] New: - [PATCH] ZWSP works as backspace when font is embedded

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42109>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42109

           Summary: [PATCH] ZWSP works as backspace when font is embedded
           Product: Fop
           Version: 1.0dev
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: pdf
        AssignedTo: fop-dev@xmlgraphics.apache.org
        ReportedBy: paul@vinkenoog.nl


When fonts are embedded in the PDF, zero-width spaces have a backspace effect:
the text following the ZWSP is left-shifted by about one character's width, so
it partly overprints the preceding text. At the end of a text area containing
ZWSPs there's extra whitespace, up to the point where the text would have ended
had it been rendered correctly.

Observed with Times, Verdana and MSMincho, but not with Courier, and only if the
font is embedded in the PDF file. It makes no difference whether the metrics
file has an entry for ZWSP (8203d) or not.

Attached are a FO and a PDF file demonstrating the effect. I also attach a patch
that intercepts non-stretchable ZWSPs before they are written to the PDF stream.
This doesn't address the cause of the problem so it's probably not the best
solution, but at least it cures the disease. And there's no point in writing
zero-dimension areas to the PDF anyway.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

Re: DO NOT REPLY [Bug 42109] - [PATCH] ZWSP works as backspace when font is embedded

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
I'd be interested to know what these errors were. Maybe we can somehow
improve the testing process. Maybe we could even download the necessary
libraries (JUnit, XMLUnit, hyphenation patterns) through Apache Ivy....

On 24.05.2007 00:32:58 bugzilla wrote:
> http://issues.apache.org/bugzilla/show_bug.cgi?id=42109
> ------- Additional Comments From paul@vinkenoog.nl  2007-05-23 15:32 -------
> > Paul, please make it a habit of running the test suite (done automatically
> > when building from the command-line using Ant) when you want to submit
> > something.
> 
> OK. I set it up a while ago but ran into a lot of errors and didn't have time to
> fully investigate what went wrong. So I went back to "build package". But I'll
> try again next time, and be a little more perseverant.


Jeremias Maerki


DO NOT REPLY [Bug 42109] - [PATCH] ZWSP works as backspace when font is embedded

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42109>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42109





------- Additional Comments From paul@vinkenoog.nl  2007-04-14 09:28 -------
I dug a little deeper (though not to the bottom) and found out that the problem
arises when PDFRenderer.escapeText() generates the string to be inserted in the
content stream. Zero-width spaces get converted to normal spaces here, and an
adjustment is added which is equal to charwidth(space) - charwidth(zwsp). With
Times for instance, this is inserted: "( ) 250 " (without the quotes). With
Helvetica it's "( ) 278 ". In either case, the appearance of the PDF is correct.

The character widths are queried from the parent area's Font object. If they are
correct (as is the case with non-embedded Base-14 fonts), there's no visible
(back)space in the PDF. (However, if you copy-and-paste the text, it contains
spaces where the ZWSPs were.)

But if the font is embedded in the PDF, the width of the regular space character
seems to be reported wrongly by the font and - for Times - this is inserted:
"<0003> 777 " (<0003> being the correct code for space). The adjustment is way
too large, hence the backspace effect.

Anyway, even if rendered correctly, ZWSPs are useless once they've done their
job as break-opportunity indicators. They add dead weight to the PDF and mess up
copy-and-paste. As I assume that other renderers have no need for them either, I
think it would be best if they weren't added to the area tree at all. So I'll
upload another patch that can be used instead of the previous one (or alongside
it; they're not in each other's way).

Side note: while working on this, I also discovered that if ZWSPs are inserted
through <fo:character>s, they are not used for line breaking.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

DO NOT REPLY [Bug 42109] - [PATCH] ZWSP works as backspace when font is embedded

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42109>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42109





------- Additional Comments From bowditch_chris@hotmail.com  2007-04-13 01:32 -------
Thanks for spotting this and submitting a patch. Good work.

Bug Confirmed. I tested your FO with Arial in PDF and the same affect occured.

I was a little concerned that your fix was PDF specific, so I tried to 
recreate the issue in Postscript but the bug doesn't seem to affect the 
Postscript Renderer.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

DO NOT REPLY [Bug 42109] - [PATCH] ZWSP works as backspace when font is embedded

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42109>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42109


paul@vinkenoog.nl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #19942|0                           |1
        is obsolete|                            |




------- Additional Comments From paul@vinkenoog.nl  2007-04-12 16:43 -------
Created an attachment (id=19943)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=19943&action=view)
Patch for org\apache\fop\render\pdf\PDFRenderer.java

Sorry, seem to have added the entire Java file instead of just the patch! Hope
I get it right this time.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

DO NOT REPLY [Bug 42109] - [PATCH] ZWSP works as backspace when font is embedded

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42109>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42109





------- Additional Comments From paul@vinkenoog.nl  2007-04-12 16:33 -------
Created an attachment (id=19941)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=19941&action=view)
PDF built from example FO


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

DO NOT REPLY [Bug 42109] - [PATCH] ZWSP works as backspace when font is embedded

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42109>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42109





------- Additional Comments From paul@vinkenoog.nl  2007-05-23 15:32 -------
> Paul, please make it a habit of running the test suite (done automatically
> when building from the command-line using Ant) when you want to submit
> something.

OK. I set it up a while ago but ran into a lot of errors and didn't have time to
fully investigate what went wrong. So I went back to "build package". But I'll
try again next time, and be a little more perseverant.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

DO NOT REPLY [Bug 42109] - [PATCH] ZWSP works as backspace when font is embedded

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42109>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42109





------- Additional Comments From paul@vinkenoog.nl  2007-04-12 16:38 -------
Created an attachment (id=19942)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=19942&action=view)
Patch for org\apache\fop\render\pdf\PDFRenderer.java


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

DO NOT REPLY [Bug 42109] - [PATCH] ZWSP works as backspace when font is embedded

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42109>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42109





------- Additional Comments From paul@vinkenoog.nl  2007-04-14 09:32 -------
Created an attachment (id=19961)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=19961&action=view)
Patch to keep zero-width spaces out of the area tree


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

DO NOT REPLY [Bug 42109] - [PATCH] ZWSP works as backspace when font is embedded

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42109>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42109


paul@vinkenoog.nl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #19941|application/unknown         |application/pdf
          mime type|                            |




-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

DO NOT REPLY [Bug 42109] - [PATCH] ZWSP works as backspace when font is embedded

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42109>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42109





------- Additional Comments From paul@vinkenoog.nl  2007-04-12 16:31 -------
Created an attachment (id=19940)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=19940&action=view)
Example FO


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

DO NOT REPLY [Bug 42109] - [PATCH] ZWSP works as backspace when font is embedded

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42109>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42109


jeremias@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Additional Comments From jeremias@apache.org  2007-05-21 00:37 -------
Thanks a lot for that patch, Paul. I've applied it:
http://svn.apache.org/viewvc?view=rev&rev=540049

Paul, please make it a habit of running the test suite (done automatically when
building from the command-line using Ant) when you want to submit something. One
of the test cases needed to be adjusted to account for the missing ZWSPs in the
area tree. Thanks.

BTW, the only case where the ZWSP probably shouldn't be removed is when at some
point we will support tagged PDF. But at the moment, this is probably the most
elegant solution.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.