JDK-6703377 : freetype: glyph vector outline is not translated correctly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,linux
  • CPU: generic,x86
  • Submitted: 2008-05-16
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b28Fixed
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
SUGGESTED FIX http://sa.sfbay.sun.com/projects/java2d_data/7/6703377.1
21-05-2008

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.
16-05-2008