Here is a screenshot to my problem:
http://img84.imageshack.us/img84/2149/testfontyy8.png
(Or http://img84.imageshack.us/my.php?image=testfontyy8.png if the above
doesn't work).
The first (ugly) text is produced by Graphics2D.fill(TextLayout.getOutline()).
The second (nice) is produced by TextLine.draw(Graphics2D).
Can someone explain the difference?? Shouldn't they be equivalent? I need the
text as a Shape instance, otherwise I wouldn't bother, I would just pick the
second...
This is the test code:
[code]
public class TestFont {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame f = new JFrame();
f.add(new JPanel() {
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
TextLayout tl = new TextLayout(
"The quick brown fox jumped over the lazy dog",
new Font("Helvetica", 1, 12),
g2d.getFontRenderContext());
Shape s = tl.getOutline(null); //shape
g2d.transform(AffineTransform.getTranslateInstance(100,
100));
g2d.fill(s); //drawing the Shape derived from TextLayout
tl.draw(g2d, 0, 100); //drawing through TextLayout
}
});
f.setSize(600, 600);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
});
}
}
[/code]
I use Java 1.6.0_10-rc-b28, on XP.
Thanks for any insights on the issue.
Dimitris Andreou
[Message sent by forum member 'ounos' (ounos)]
http://forums.java.net/jive/thread.jspa?messageID=328191
===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[email protected] and include in the body of the message "help".