-
Bug
-
Resolution: Not an Issue
-
P4
-
8
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
When using Calibri font in 12pt bold, the - sign is not rendered with the default antialiasing mode.
When using RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB oder RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR the - is not visible.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just run the code example below. Setting the Fomnt to Calibi, bold, 12, and then using RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB reproduces the problem.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The expected result when running the code above is to see three times -100.
ACTUAL -
The -100 rendered with enderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB is displayed as 100.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
final Font f = new Font("Calibri", Font.BOLD, 12);
final String str = "-100";
JTextField tf = new JTextField(9);
tf.setFont(f);
tf.setText(str);
@SuppressWarnings("serial")
JPanel panel = new JPanel() {
protected void paintComponent(java.awt.Graphics g) {
super.paintComponent(g);
g.setFont(f);
g.drawString(str, 3, 15);
((Graphics2D)g).setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
g.drawString(str, 3, 35);
((Graphics2D)g).setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
g.drawString(str, 3, 45);
};
};
panel.setPreferredSize(new Dimension(30, 50));
panel.setBackground(Color.WHITE);
JFrame frame = new JFrame();
frame.setSize(300, 200);
frame.setLocationRelativeTo(null);
frame.setLayout(new FlowLayout());
frame.add(tf);
frame.add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Setting a different Antialiasing Rendering Hint helps, but you must do it in every paint method.
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
When using Calibri font in 12pt bold, the - sign is not rendered with the default antialiasing mode.
When using RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB oder RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR the - is not visible.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just run the code example below. Setting the Fomnt to Calibi, bold, 12, and then using RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB reproduces the problem.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The expected result when running the code above is to see three times -100.
ACTUAL -
The -100 rendered with enderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB is displayed as 100.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
final Font f = new Font("Calibri", Font.BOLD, 12);
final String str = "-100";
JTextField tf = new JTextField(9);
tf.setFont(f);
tf.setText(str);
@SuppressWarnings("serial")
JPanel panel = new JPanel() {
protected void paintComponent(java.awt.Graphics g) {
super.paintComponent(g);
g.setFont(f);
g.drawString(str, 3, 15);
((Graphics2D)g).setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
g.drawString(str, 3, 35);
((Graphics2D)g).setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
g.drawString(str, 3, 45);
};
};
panel.setPreferredSize(new Dimension(30, 50));
panel.setBackground(Color.WHITE);
JFrame frame = new JFrame();
frame.setSize(300, 200);
frame.setLocationRelativeTo(null);
frame.setLayout(new FlowLayout());
frame.add(tf);
frame.add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Setting a different Antialiasing Rendering Hint helps, but you must do it in every paint method.