-
Bug
-
Resolution: Not an Issue
-
P3
-
11.0.8
-
x86_64
-
windows_10
A DESCRIPTION OF THE PROBLEM :
BOLD style text (with some fonts, eg: Arial Black), has different width in Java 11.0.8 and Java 8
REGRESSION : Last worked in version 8u261
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
A sample program (attached) to draw some text in JPanel, using Arial Black font in BOLD style, can reproduce the issue.
Noticeably, this occurs only for few fonts (counter-eg: Lucida Sans)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The width of the text should be equal to its width in Oracle Java 8
ACTUAL -
Width of BOLD text is not as much as it is in Java 8
---------- BEGIN SOURCE ----------
import javax.swing .*;
import java.awt .*;
public class ReproduceBoldIssue extends JPanel {
static final String line1 = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG";
static final String line2 = "the quick brown fox jumps over the lazy dog";
static final String line3 = "0123456789";
@Override
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
// Define rendering hint, font name, font style and font size
//g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setFont(new Font("Arial Black", Font.BOLD, 22));
g2.setColor(Color.RED);
g2.drawString(line1, 10, 100);
g2.drawString(line2, 10, 120);
g2.drawString(line3, 10, 140);
}
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setTitle("Bold Text Demo");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(new ReproduceBoldIssue());
frame.pack();
frame.setSize(720, 350);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
FREQUENCY : always
BOLD style text (with some fonts, eg: Arial Black), has different width in Java 11.0.8 and Java 8
REGRESSION : Last worked in version 8u261
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
A sample program (attached) to draw some text in JPanel, using Arial Black font in BOLD style, can reproduce the issue.
Noticeably, this occurs only for few fonts (counter-eg: Lucida Sans)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The width of the text should be equal to its width in Oracle Java 8
ACTUAL -
Width of BOLD text is not as much as it is in Java 8
---------- BEGIN SOURCE ----------
import javax.swing .*;
import java.awt .*;
public class ReproduceBoldIssue extends JPanel {
static final String line1 = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG";
static final String line2 = "the quick brown fox jumps over the lazy dog";
static final String line3 = "0123456789";
@Override
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
// Define rendering hint, font name, font style and font size
//g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setFont(new Font("Arial Black", Font.BOLD, 22));
g2.setColor(Color.RED);
g2.drawString(line1, 10, 100);
g2.drawString(line2, 10, 120);
g2.drawString(line3, 10, 140);
}
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setTitle("Bold Text Demo");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(new ReproduceBoldIssue());
frame.pack();
frame.setSize(720, 350);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
FREQUENCY : always
- relates to
-
JDK-8251471 Applying BOLD style on text does not increase the width in Java 11
- Closed