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 2008/04/03 11:18:15 UTC

DO NOT REPLY [Bug 44744] New: PDFGraphics2D.drawString( AttributedCharacterIterator it, float x, float y) throws NullPointerException

https://issues.apache.org/bugzilla/show_bug.cgi?id=44744

           Summary: PDFGraphics2D.drawString(AttributedCharacterIterator it,
                    float x, float y) throws NullPointerException
           Product: Fop
           Version: all
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: pdf
        AssignedTo: fop-dev@xmlgraphics.apache.org
        ReportedBy: yegor@dinom.ru


PDFGraphics2D.drawString(AttributedCharacterIterator it, float x, float y)
throws NullPointerException:

Exception in thread "main" java.lang.NullPointerException
        at org.apache.fop.svg.PDFGraphics2D.drawString(PDFGraphics2D.java:1559)
        at
org.apache.xmlgraphics.java2d.AbstractGraphics2D.drawString(AbstractGraphics2D.java:652)
        at com.yegor.fop.TestPDFGraphics.main(TestPDFGraphics.java:35)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)

A failing test is attached. 

It looks like drawString(AttributedCharacterIterator it, float x, float y) is
not   finished. The variable fontState which results in NPE is assigned to null
and never initialized. 

If possible, I'd like to have it fixed in FOP 0.95. I would be happy to upload
a patch but my knowledge of PDF is not enough for that :). Please suggest how
it can be fixed.

Shouldn't this method be re-written so that drawString(String str, float x,
float y) is called for each individual text run in the AttributedString? If so,
   how can I measure the length of a text run and advance the x co-ordinate?  

Regards,
Yegor


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

DO NOT REPLY [Bug 44744] PDFGraphics2D.drawString(AttributedCharacterIterator it, float x, float y) throws NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44744

Glenn Adams <gl...@skynav.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3

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

DO NOT REPLY [Bug 44744] PDFGraphics2D.drawString(AttributedCharacterIterator it, float x, float y) throws NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44744

--- Comment #4 from Glenn Adams <gl...@skynav.com> 2012-04-07 01:41:53 UTC ---
resetting P2 open bugs to P3 pending further review

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

DO NOT REPLY [Bug 44744] PDFGraphics2D.drawString( AttributedCharacterIterator it, float x, float y) throws NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44744





--- Comment #2 from Andreas L. Delmelle <ad...@apache.org>  2008-04-03 09:33:05 PST ---
(In reply to comment #0)
<snip /> 

Looking at it closer, the possibility of the NPE is immediately signaled by my
IDE when I open the file in question.

> Shouldn't this method be re-written so that drawString(String str, float x,
> float y) is called for each individual text run in the AttributedString?

Not sure, but this could actually turn out to be suboptimal, since the former
method may contain code that should only be called once. The initialization of
the fontState falls in that category.

I'm not really an expert on this part of the FOP-code, but have you tried
copy-pasting the first few lines of the drawString(String...) variant, where
the fontState is initialized?


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

DO NOT REPLY [Bug 44744] PDFGraphics2D.drawString( AttributedCharacterIterator it, float x, float y) throws NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44744





--- Comment #1 from Yegor Kozlov <ye...@dinom.ru>  2008-04-03 02:20:12 PST ---
Created an attachment (id=21775)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=21775)
failing test 


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

DO NOT REPLY [Bug 44744] PDFGraphics2D.drawString( AttributedCharacterIterator it, float x, float y) throws NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44744





--- Comment #3 from Jeremias Maerki <je...@apache.org>  2008-04-04 05:42:09 PST ---
I've disabled the method which makes PDFGraphics2D use the fallback
implementation from AbstractGraphics2D (which uses the TextLayout approach).
But I consider this to be suboptimal, just a temporary solution (whatever
"temporary" means in our project).

http://svn.apache.org/viewvc?rev=644697&view=rev

In the end, drawString(String, float, float) should rather call
drawString(AttributedCharacterIterator, float, float) than the other way
around. Mapping the more complex method to a number of calls to the simpler
method is not the most efficient method.

PDFTextPainter may provide some inspiration for an optimized implementation. It
already contains some code to paint an AttributedCharacterIterator, even if
that one is highly Batik-specific. So I'm leaving this bug open as a reminder.


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

DO NOT REPLY [Bug 44744] PDFGraphics2D.drawString( AttributedCharacterIterator it, float x, float y) throws NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44744


Andreas L. Delmelle <ad...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #21775|application/octet-stream    |text/plain
          mime type|                            |




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

DO NOT REPLY [Bug 44744] PDFGraphics2D.drawString( AttributedCharacterIterator it, float x, float y) throws NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44744


Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yegor@dinom.ru




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