-
Bug
-
Resolution: Unresolved
-
P4
-
6, 7, 8, 9
-
windows_10
Reproducer:
{code}
import javax.swing.*;
import java.awt.*;
public class Test {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame();
JEditorPane editorPane = new JEditorPane("text/html",
"<html><head><style>body {font-family:'Segoe UI'; font-size:12pt;}</style></head><body>\u4e2d</body></html>");
// if the following line is commented out, font fallback will work as expected
editorPane.getFontMetrics(new Font("Segoe UI", Font.PLAIN, 12));
frame.add(editorPane);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(200, 100);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
});
}
}
{code}
Expected result: Chinese hieroglyph is displayed in the text area.
Actual result: 'missing glyph' box is displayed in the text area.
If the line, containing 'getFontMetrics' invocation is commented out or removed, sample program produces expected result.
Issue is caused by equals/hashCode methods in java.awt.Font not distinguishing 'physical' font instances and font-fallback-enabled ones (generated by sun.font.FontUtilities.getCompositeFontUIResource), so font metrics caches in sun.font.FontDesignMetrics and javax.swing.text.GlyphPainter1 get confused.
{code}
import javax.swing.*;
import java.awt.*;
public class Test {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame();
JEditorPane editorPane = new JEditorPane("text/html",
"<html><head><style>body {font-family:'Segoe UI'; font-size:12pt;}</style></head><body>\u4e2d</body></html>");
// if the following line is commented out, font fallback will work as expected
editorPane.getFontMetrics(new Font("Segoe UI", Font.PLAIN, 12));
frame.add(editorPane);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(200, 100);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
});
}
}
{code}
Expected result: Chinese hieroglyph is displayed in the text area.
Actual result: 'missing glyph' box is displayed in the text area.
If the line, containing 'getFontMetrics' invocation is commented out or removed, sample program produces expected result.
Issue is caused by equals/hashCode methods in java.awt.Font not distinguishing 'physical' font instances and font-fallback-enabled ones (generated by sun.font.FontUtilities.getCompositeFontUIResource), so font metrics caches in sun.font.FontDesignMetrics and javax.swing.text.GlyphPainter1 get confused.
- links to
-
Review openjdk/jdk/7313