-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.0
-
x86
-
windows_nt
Name: gsC80088 Date: 02/11/99
Run the program listed below. The bright green rectangle
displayed should extend to the advance point on the end of the
string of characters. However, it clearly does not do this.
import java.awt.*;
import java.awt.geom.*;
import java.awt.font.*;
import javax.swing.*;
public class TestApp2 extends JComponent
{
static String MyStr = "lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll";
static Font MyFont = new Font( "Serif" , Font.ITALIC , 18 );
static Rectangle2D bounds;
static double advance;
public void paint( Graphics ga )
{
Graphics2D g = (Graphics2D) ga;
g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
g.setRenderingHint( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED );
g.setFont( MyFont );
g.setColor( Color.green );
g.fillRect( (int)( bounds.getX() ) , (int)( bounds.getY() ) + 100 ,
(int)( advance ) , (int)( bounds.getHeight() ) );
g.setColor( Color.black );
g.drawString( MyStr , 0 , 100 );
}
public static void main( String[] in )
{
JFrame MyFr2 = new JFrame();
MyFr2.addNotify();
Graphics2D g = (Graphics2D)( MyFr2.getGraphics() );
g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
g.setRenderingHint( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED );
FontRenderContext TempFrc = g.getFontRenderContext();
TextLayout tl = new TextLayout( MyStr , MyFont , TempFrc );
bounds = tl.getBounds();
advance = tl.getAdvance();
JFrame MyFr = new JFrame();
JComponent MyCr = new TestApp2();
MyFr.getContentPane().setLayout( new BorderLayout( 0 , 0 ) );
MyFr.getContentPane().add( "Center" , MyCr );
MyCr.setMinimumSize( new Dimension( 400 , 400 ) );
MyCr.setPreferredSize( new Dimension( 400 , 400 ) );
MyFr.pack();
MyFr.show();
}
}
}
(Review ID: 53415)
======================================================================
- duplicates
-
JDK-4202971 NativeFontWrapper.getGlyphInfo is inaccurate for antialiased text
- Closed