-
Bug
-
Resolution: Unresolved
-
P3
-
7, 8, 9, 10
-
x86
-
other
FULL PRODUCT VERSION :
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [versão 10.0.15063]
A DESCRIPTION OF THE PROBLEM :
In our application we use Font objects with a AffineTransform in order to rotate the font and render text sideways.
In some cases, the text shown is really brief, such as a single character in mandarin, and so we use larger fonts.
The sideways rendering works fine up to font size 100 (inclusive). If the font size exceeds 100, the text simply stops being rendered at all. We do not have that problem if we don't use AffineTransform to rotate te text.
The problem happens when drawing the string directly in a Graphics object (Such as the BufferedImage, provided as an example, or the Graphics2D of a Component), however, it seems to work fine when changing the font of a JLabel.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the sample source code attached. It will generate two images in the current directoy. The first one, named "works.png" show a text being correctly rendered using font size of 100. The second image, name "doesnt_work.png" shows that a text of size larger than 100 doesn't render at all.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Rendered text of size larger than 100 and with rotation
ACTUAL -
No rendered text at all
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import javax.imageio.*;
import java.io.*;
public class Test {
public static void main(String[] args) throws Exception {
AffineTransform affineTransform90Degrees = new AffineTransform();
affineTransform90Degrees.rotate(Math.toRadians(90));
Graphics2D graphics;
BufferedImage image;
image = new BufferedImage(200, 500, BufferedImage.TYPE_4BYTE_ABGR_PRE);
graphics = image.createGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, 200, 500);
graphics.setColor(Color.BLACK);
// Works with any size up to 500
graphics.setFont(new Font("Arial", Font.PLAIN, 100).deriveFont(affineTransform90Degrees));
graphics.drawString("Test", 0, 100);
graphics.dispose();
ImageIO.write(image, "PNG", new File("works.png"));
image = new BufferedImage(200, 500, BufferedImage.TYPE_4BYTE_ABGR_PRE);
graphics = image.createGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, 200, 500);
graphics.setColor(Color.BLACK);
// Doesn't work with any size larger than 100
graphics.setFont(new Font("Arial", Font.PLAIN, 101).deriveFont(affineTransform90Degrees));
graphics.drawString("Test", 0, 100);
graphics.dispose();
ImageIO.write(image, "PNG", new File("doesnt_work.png"));
}
}
---------- END SOURCE ----------
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [versão 10.0.15063]
A DESCRIPTION OF THE PROBLEM :
In our application we use Font objects with a AffineTransform in order to rotate the font and render text sideways.
In some cases, the text shown is really brief, such as a single character in mandarin, and so we use larger fonts.
The sideways rendering works fine up to font size 100 (inclusive). If the font size exceeds 100, the text simply stops being rendered at all. We do not have that problem if we don't use AffineTransform to rotate te text.
The problem happens when drawing the string directly in a Graphics object (Such as the BufferedImage, provided as an example, or the Graphics2D of a Component), however, it seems to work fine when changing the font of a JLabel.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the sample source code attached. It will generate two images in the current directoy. The first one, named "works.png" show a text being correctly rendered using font size of 100. The second image, name "doesnt_work.png" shows that a text of size larger than 100 doesn't render at all.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Rendered text of size larger than 100 and with rotation
ACTUAL -
No rendered text at all
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import javax.imageio.*;
import java.io.*;
public class Test {
public static void main(String[] args) throws Exception {
AffineTransform affineTransform90Degrees = new AffineTransform();
affineTransform90Degrees.rotate(Math.toRadians(90));
Graphics2D graphics;
BufferedImage image;
image = new BufferedImage(200, 500, BufferedImage.TYPE_4BYTE_ABGR_PRE);
graphics = image.createGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, 200, 500);
graphics.setColor(Color.BLACK);
// Works with any size up to 500
graphics.setFont(new Font("Arial", Font.PLAIN, 100).deriveFont(affineTransform90Degrees));
graphics.drawString("Test", 0, 100);
graphics.dispose();
ImageIO.write(image, "PNG", new File("works.png"));
image = new BufferedImage(200, 500, BufferedImage.TYPE_4BYTE_ABGR_PRE);
graphics = image.createGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, 200, 500);
graphics.setColor(Color.BLACK);
// Doesn't work with any size larger than 100
graphics.setFont(new Font("Arial", Font.PLAIN, 101).deriveFont(affineTransform90Degrees));
graphics.drawString("Test", 0, 100);
graphics.dispose();
ImageIO.write(image, "PNG", new File("doesnt_work.png"));
}
}
---------- END SOURCE ----------