tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Ritchey" <ritchey...@hotmail.com>
Subject OT: This is driving me nuts...
Date Tue, 21 Nov 2000 08:57:23 GMT
Ok this has been driving me nuts.  JDK1.3 is suppossed to support runtime 
loading of truetype fonts, but I just can't seem to get it to work.

Look at the code below ... (BTW I am runnin this on WIN32 so no worries 
about setting X up properly)

// CODE SNIPPET

BufferedImage image = new BufferedImage(500, 500, 
BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D = image.createGraphics();
graphics2D.setPaint(Color.orange);
Rectangle2D rectangle2D = new Rectangle2D.Double(0, 0, 500, 500);
graphics2D.fill(rectangle2D);

graphics2D.setPaint(Color.black);

graphics2D.setRenderingHint(
   RenderingHints.KEY_ANTIALIASING,
   RenderingHints.VALUE_ANTIALIAS_ON);

FileInputStream in = new FileInputStream("arial.ttf");

// This font loads, you can call font.getName() and it will return its name.

Font font = Font.createFont(Font.TRUETYPE_FONT, in);
graphics2D.setFont(font.deriveFont(Font.PLAIN, 18));

// However it does not draw the font to the graphic.
graphics2D.drawString("TESTING", 0, 0);

// Yet this works perfectly fine.
Font font2 = new Font("Arial", Font.PLAIN, 18);
graphics2D.setFont(font2);
graphics2D.drawString("TESTING", 0, 250);

// END CODE SNIPPET

I just don't get it ...
This has been driving me nuts.

I know this is offtopic but I can't find the solution anywhere, and everyone 
one on this list seems pretty knowledgable, so i figured what the hey.

Thanks,
Dan

_____________________________________________________________________________________
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com


Mime
View raw message