Bug 43073 - Exception when modifying font in a EscherGraphics2d
Summary: Exception when modifying font in a EscherGraphics2d
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-FINAL
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-09 06:46 UTC by David
Modified: 2007-08-09 07:28 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David 2007-08-09 06:46:00 UTC
Code:
EscherGraphics g = new EscherGraphics(group2, wb, Color.white,
verticalPointsPerPixel );
	    EscherGraphics2d g2d = new EscherGraphics2d(g);
Font font = new Font("Dialog", Font.PLAIN, 12);
g2d.setFont(font);
g2d.drawString("Hello World !", 0, 0);

This raises the exception:
java.lang.NumberFormatException: null
	at java.lang.Integer.parseInt(Integer.java:415)
	at java.lang.Integer.parseInt(Integer.java:497)
	at org.apache.poi.hssf.usermodel.FontDetails.create(FontDetails.java:98)
	at
org.apache.poi.hssf.usermodel.StaticFontMetrics.getFontDetails(StaticFontMetrics.java:88)
	at org.apache.poi.hssf.usermodel.EscherGraphics.drawString(EscherGraphics.java:285)
	at
org.apache.poi.hssf.usermodel.EscherGraphics2d.drawString(EscherGraphics2d.java:298)

This appears in poi-3.0.1-FINAL-20070705

Thank you very much
Comment 1 Nick Burch 2007-08-09 07:28:26 UTC
I've committed a fix to SVN which means you now get a much more helpful
exception in this situation.

(The problem is that you're requesting an unknown font, so we can't get the
properties for it. I think you actually want "dialog", with a lower case d, as
that does properties defined for it)