Marco,

There is a bug with rotated text - turning on the hints for antialiasing and 
fractional widths 
should fix this. It essentially has to do with calculating fractional spacing thus you 
are 
getting a stepped kind of effect.

>X-Authentication-Warning: capra.eng.sun.com: amith set sender to 
[EMAIL PROTECTED] using -f
>From: [EMAIL PROTECTED]
>X-Lotus-FromDomain: PETROBANK
>To: [EMAIL PROTECTED]
>Date: Wed, 26 May 1999 16:47:13 +0100
>Subject: [java2d] Problem with rotated text
>Content-Disposition: inline
>
>
>
>I am developing an applet to display simple map data that includes text
>displayed at various angles.
>
>The applet uses a canvas within a scrollpane. The data is first drawn on a
>buffered image using the Java 2D API before being 'painted' to the canvas.
>
>I am using the AffineTransform class to do the translation/rotation as
>shown below
>
>
>     FontMetrics fm = gc.getFontMetrics(); // gc = Graphics2D instance
>     Rectangle2D box = fm.getStringBounds(theText.trim(), gc);
>     float incrX = (float)(box.getWidth()/2.0);
>     float incrY = (float)(box.getHeight()/2.0);
>     gc.setPaint(Color.black);
>
>     // apply transform first
>     AffineTransform aft =
>(gc.getDeviceConfiguration()).getDefaultTransform();
>
>     // apply translation then rotate
>     aft.setToTranslation(currX, currY); // position of centre of text box
>     gc.transform(aft);
>     aft.setToRotation(Math.toRadians(-currAngle)); // rotation for this
>string
>     gc.transform(aft);
>
>        gc.drawString(theText.trim(), -incrX, incrY);
>
>     // undo the transform
>     aft.setToRotation(Math.toRadians(currAngle));
>     gc.transform(aft);
>     aft.setToTranslation(-currX, -currY);
>     gc.transform(aft);
>
>
>Although the first character of the text string is postioned & rotated
>correctly, each subsequent character seems to be slightly offset from the
>previous character below the (rotated) string baseline giving a stepped
>appearance.
>
>Has anyone any thoughts on how to cure this.
>
>
>Thanks in advance,
>
>Marco Rondelli
>
>P.S. Using JDK 1.2, IE 5.0, NT 4.0
>
>
>=====================================================================
>To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
>Java 2D Home Page: http://java.sun.com/products/java-media/2D/

Parry Kejriwal
Fonts & Text JAVA 2D


=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 2D Home Page: http://java.sun.com/products/java-media/2D/

Reply via email to