-
Bug
-
Resolution: Unresolved
-
P4
-
9
-
windows
See the discussion: http://mail.openjdk.java.net/pipermail/swing-dev/2016-April/005797.html
The text width can be differ for different graphics transforms.
To reproduce the issue run the following code sample on Windows:
-------------------------------
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
public class CharWidthTest {
static final String TEXT = "The quick brown fox jumps over the lazy dog"
+ "The quick brown fox jumps over the lazy dog";
static final String LONG_TEXT = TEXT + TEXT.toUpperCase();
public static void main(String[] args) {
BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D g = img.createGraphics();
int textWidth1 = g.getFontMetrics().stringWidth(LONG_TEXT);
g.scale(2, 2);
int textWidth2 = g.getFontMetrics().stringWidth(LONG_TEXT);
g.dispose();
if (textWidth1 != textWidth2) {
throw new RuntimeException("Text size is different!");
}
}
}
-------------------------------
The text width can be differ for different graphics transforms.
To reproduce the issue run the following code sample on Windows:
-------------------------------
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
public class CharWidthTest {
static final String TEXT = "The quick brown fox jumps over the lazy dog"
+ "The quick brown fox jumps over the lazy dog";
static final String LONG_TEXT = TEXT + TEXT.toUpperCase();
public static void main(String[] args) {
BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D g = img.createGraphics();
int textWidth1 = g.getFontMetrics().stringWidth(LONG_TEXT);
g.scale(2, 2);
int textWidth2 = g.getFontMetrics().stringWidth(LONG_TEXT);
g.dispose();
if (textWidth1 != textWidth2) {
throw new RuntimeException("Text size is different!");
}
}
}
-------------------------------