This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 31st, when you will be able to use this site as normal.

    Forum Stats

  • 3,890,899 Users
  • 2,269,649 Discussions
  • 7,916,821 Comments

Discussions

Problem with Graphics2D setFont Method in java 1.6

854607
854607 Member Posts: 8
edited May 1, 2011 11:18PM in Abstract Window Toolkit (AWT)
Hi,

We are migrating one of our multithreaded J2SE application from java 1.4 to 1.6.

The application work is following :
1. Get the input data
2. from the input data create a ps file
3. create pcl file from the above created ps file
4. send the pcl to printer to printing.

I am encountering an error in step 2(creating a ps file). The ps file is created by implementing a Printable interface and then we are using Graphics2D setFont method to set the font of the printable.

The application fails due to the setFont method and produces NaN and Infinity values in the ps file. But if I comment all the setFont methods then the application works fine in java 1.6.

Could you please let me know what is the issue and what could be the work around for this?

[I have put one more post. The link is : http://forums.oracle.com/forums/thread.jspa?threadID=2206264&stqc=true]

Edited by: 851604 on Apr 25, 2011 2:17 AM

Answers

  • StanislavL
    StanislavL Member Posts: 309
    Not enough info to say something. Does it depend on font family/size? e.g. Arial, 10 works fine but Arial 20 fails.
    Which OS and exact JDK version do you use?

    Do you have SSCCe or at least some code snippets?
  • 854607
    854607 Member Posts: 8
    No it does not depend on font family/size.

    I am using UNIX os and JDK version i will update you shortly.

    Here a small illustration of what I am doing:

    public class A implements Printable{

    public int print(Graphics graphics, PageFormat pageFormat, int pi){

    drawImage((Graphics2D)graphics);

    }

    public void drawImage(Graphics2D g2){

    g2.setFont(new Font("Arial", 1 , 24));

    // some other stuff for drawString and drawLine

    }

    }

    This setFont method creates Nan and Infinity values in the ps file produced.

    If i comment out his part of code and then run the application then it works fine.
  • 854607
    854607 Member Posts: 8
    Could you please guide me on this?
This discussion has been closed.