United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6703377 freetype: glyph vector outline is not translated correctly
JDK-6703377 : freetype: glyph vector outline is not translated correctly

Details
Type:
Bug
Submit Date:
2008-05-16
Status:
Closed
Updated Date:
2011-03-08
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
client-libs
OS:
linux,generic
Sub-Component:
2d
CPU:
x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:

Sub Tasks

Description
When freetype scaler is used outline is not translated correctly along y axis.

Testcase:
============
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;

import javax.swing.JComponent;
import javax.swing.JFrame;

public class BugDemo {

	public static class DemoComponent extends JComponent {
		@Override
		public void paintComponent(Graphics g) {
			Graphics2D g2 = (Graphics2D) g;
			FontRenderContext frc = new FontRenderContext(null, false, false);

			g2.translate(100, 100);
			
			g2.setColor(Color.GRAY);
			g2.drawLine(0,0,150,0);
			g2.drawLine(0,150,0,0);
			
			g2.setColor(Color.BLACK);
		    GlyphVector gv = g.getFont().createGlyphVector(frc, "test");
		    g2.drawGlyphVector(gv, 20, 20);

		    g2.setColor(Color.RED);
		    g2.fill(gv.getOutline(20,20));
		}
	}

	private static void createAndShowGUI() {
		JFrame.setDefaultLookAndFeelDecorated(true);
		JFrame frame = new JFrame("BugDemo");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().add(new DemoComponent());
		frame.pack();
		frame.setSize(200,200);
		frame.setVisible(true);
	}

	public static void main(String[] args) {
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				createAndShowGUI();
			}
		});
	}

}

                                    

Comments
EVALUATION

y axis in java and freetpye have different directions. 
Need to invert sign of y value of translation matrix before applying to freetype output.
                                     
2008-05-16
SUGGESTED FIX

http://sa.sfbay.sun.com/projects/java2d_data/7/6703377.1
                                     
2008-05-21



Hardware and Software, Engineered to Work Together