Font antialiasing problem
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Nadezhda_Nikulina
Posted On:   Sunday, October 14, 2001 01:28 AM

Hello, Here is the code for painting italic-styled text. Turning antialiasing on changes string width and text slope. Can anyone point out what the problem is and how to get around it? Thanks in advance, Nadia import java.awt.*; import javax.swing.*; public class FontTest extends JFrame { public FontTest() { super("FontTest"); setSize(500,200); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); show(); } public void paint(Graphics g) { Graphics2D g2d=(Graphics2D)g; g2d.setFont(new Font("Arial",Font.ITALIC,24)); g2d.setColor(Color   More>>

Hello,




Here is the code for painting italic-styled text.
Turning antialiasing on changes string width and text slope.
Can anyone point out what the problem is and how to get
around it?




Thanks in advance,

Nadia



			
import java.awt.*;
import javax.swing.*;

public class FontTest extends JFrame {
public FontTest() {
super("FontTest");
setSize(500,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
show();
}
public void paint(Graphics g) {
Graphics2D g2d=(Graphics2D)g;
g2d.setFont(new Font("Arial",Font.ITALIC,24));
g2d.setColor(Color.black);
String text="Simple text";
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
g2d.drawString(text,100,100);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawString(text,100,120);
}
public static void main(String[] args) {
new FontTest();
}
}
   <<Less
About | Sitemap | Contact