-
Bug
-
Resolution: Not an Issue
-
P4
-
8, 11, 16
-
x86_64
-
windows_10
A DESCRIPTION OF THE PROBLEM :
Using the Graphics2d fillOutline with AWT Font Arial 11pt size leads to an non working kerning. Spaces between letters like 2 and A are extreme big, while others are touching each other.
---------- BEGIN SOURCE ----------
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;
import java.text.AttributedString;
import javax.swing.JFrame;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
public class CheckLabel {
public static void main(String[] args) {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(new Component() {
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
AttributedString attributedString = new AttributedString("PwA");
FontData fontData = new FontData("Arial", 11, SWT.NONE); //$NON-NLS-1$
java.awt.Font awtFont = new java.awt.Font(fontData.getName(), fontData.getStyle(), fontData.getHeight());
attributedString.addAttribute(TextAttribute.FONT, awtFont);
TextLayout tl = new TextLayout("PwA", attributedString.getIterator().getAttributes(), g2d.getFontRenderContext());
//shape is created from the outline of the textlayout
Shape outline = tl.getOutline(AffineTransform.getTranslateInstance(0, 20));
g2d.fill(outline);
g2d.setTransform(AffineTransform.getScaleInstance(2, 2));
Shape outline2 = tl.getOutline(AffineTransform.getTranslateInstance(0, 100));
g2d.fill(outline2);
}
@Override
public Dimension getSize() {
return new Dimension(100, 100);
}
});
f.setSize(400, 400);
f.setVisible(true);
}
}
---------- END SOURCE ----------
FREQUENCY : always
Using the Graphics2d fillOutline with AWT Font Arial 11pt size leads to an non working kerning. Spaces between letters like 2 and A are extreme big, while others are touching each other.
---------- BEGIN SOURCE ----------
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;
import java.text.AttributedString;
import javax.swing.JFrame;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
public class CheckLabel {
public static void main(String[] args) {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(new Component() {
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
AttributedString attributedString = new AttributedString("PwA");
FontData fontData = new FontData("Arial", 11, SWT.NONE); //$NON-NLS-1$
java.awt.Font awtFont = new java.awt.Font(fontData.getName(), fontData.getStyle(), fontData.getHeight());
attributedString.addAttribute(TextAttribute.FONT, awtFont);
TextLayout tl = new TextLayout("PwA", attributedString.getIterator().getAttributes(), g2d.getFontRenderContext());
//shape is created from the outline of the textlayout
Shape outline = tl.getOutline(AffineTransform.getTranslateInstance(0, 20));
g2d.fill(outline);
g2d.setTransform(AffineTransform.getScaleInstance(2, 2));
Shape outline2 = tl.getOutline(AffineTransform.getTranslateInstance(0, 100));
g2d.fill(outline2);
}
@Override
public Dimension getSize() {
return new Dimension(100, 100);
}
});
f.setSize(400, 400);
f.setVisible(true);
}
}
---------- END SOURCE ----------
FREQUENCY : always
- duplicates
-
JDK-8253835 Kerning broken on Arial, 11Pt Size on Graphics2d fillOutline
- Closed