-
Enhancement
-
Resolution: Unresolved
-
P4
-
6, 7, 8, 11, 14.0.2
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
I observed the issue in
- version 14.0.2 under Windows 10
- version 11.0.8 under Linux Mint 10.3 (=> Ubuntu 18.04)
A DESCRIPTION OF THE PROBLEM :
Background:
The Mongolian script (Unicode range 0x1800 - 18FF) is a "complex" script, requiring for proper shaping paying attention to the context of each character (for instance, in OpenType, OT tables like "isol", "init", "medi", "fina" and "rlig" are required, as with Arabic).
If a Mongolian text is set into an AWT / Swing control it is not correctly shaped, unless some additional text is also added in some other "complex" script, like Arabic or DevanÄgarÄ«.
I am convinced the problem is in the `src/java.desktop/share/classes/sun/font/FontUtilies.java` class; in its method `public static boolean isComplexCharCode(int code)` around line 290, there is the following code:
```
else if (code < 0x1780) {
return false;
}
else if (code <= 0x17ff) { // 1780 - 17FF Khmer
return true;
}
else if (code < 0x200c) {
return false;
}
```
which returns `false` for the Mongolian range. I propose to correct it into:
```
else if (code < 0x1780) {
return false;
}
else if (code <= 0x18ff) { // 1780 - 17FF Khmer
return true; // 1800 - 18FF Mongolian
}
else if (code < 0x200c) {
return false;
}
```
which returns true if the passed-in character code is a Khmer or a Mongolian character.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set a Mongolian text (for instance "á ªá á ¢á ¨á á ") into an AWT / Swing control and a Mongolian + DevanÄgarÄ« or DevanÄgarÄ« + Mongolian text in another (for instance "á ªá á ¢á ¨á á ठनà¥à¤à¥à¤à¥à¤¦" or "ठनà¥à¤à¥à¤à¥à¤¦ á ªá á ¢á ¨á á ").
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Mongolian text is correctly shaped in both cases
ACTUAL -
The Mongolian text is correctly shaped in the second case, as the other "complex" text triggers the proper shaping, but it is incorrectly shaped in the first case (something like "á ª á á ¢ á ¨ á ").
The example source attached below shows wrong and correct shaping cases for Swing labels; other controls exhibit the same behaviour.
---------- BEGIN SOURCE ----------
package com.vistamaresoft.swingtest;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Main
{
private JFrame frame;
private static Main window;
public Main()
{
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setTitle("Mongolian Swing Test");
frame.setBounds(100, 100, 300, 200);
//Set up the GUI.
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
JLabel label = new JLabel("á ªá á ¢á ¨á á "); // NOT CORRECT
panel.add(label);
label = new JLabel("Abc á ªá á ¢á ¨á á "); // NOT CORRECT
panel.add(label);
label = new JLabel("á ªá á ¢á ¨á á Ùتاب "); // CORRECT
panel.add(label);
label = new JLabel("Ùتاب á ªá á ¢á ¨á á "); // CORRECT
panel.add(label);
label = new JLabel("á ªá á ¢á ¨á á ठनà¥à¤à¥à¤à¥à¤¦"); // CORRECT
panel.add(label);
label = new JLabel("ठनà¥à¤à¥à¤à¥à¤¦ á ªá á ¢á ¨á á "); // CORRECT
panel.add(label);
frame.setContentPane(panel);
}
public static void main(String[] args)
{
window = new Main();
window.frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
As adding arbitrary strings to UI element to trigger the correct shaping is in general not feasible, I am not aware of any workaround.
FREQUENCY : always
I observed the issue in
- version 14.0.2 under Windows 10
- version 11.0.8 under Linux Mint 10.3 (=> Ubuntu 18.04)
A DESCRIPTION OF THE PROBLEM :
Background:
The Mongolian script (Unicode range 0x1800 - 18FF) is a "complex" script, requiring for proper shaping paying attention to the context of each character (for instance, in OpenType, OT tables like "isol", "init", "medi", "fina" and "rlig" are required, as with Arabic).
If a Mongolian text is set into an AWT / Swing control it is not correctly shaped, unless some additional text is also added in some other "complex" script, like Arabic or DevanÄgarÄ«.
I am convinced the problem is in the `src/java.desktop/share/classes/sun/font/FontUtilies.java` class; in its method `public static boolean isComplexCharCode(int code)` around line 290, there is the following code:
```
else if (code < 0x1780) {
return false;
}
else if (code <= 0x17ff) { // 1780 - 17FF Khmer
return true;
}
else if (code < 0x200c) {
return false;
}
```
which returns `false` for the Mongolian range. I propose to correct it into:
```
else if (code < 0x1780) {
return false;
}
else if (code <= 0x18ff) { // 1780 - 17FF Khmer
return true; // 1800 - 18FF Mongolian
}
else if (code < 0x200c) {
return false;
}
```
which returns true if the passed-in character code is a Khmer or a Mongolian character.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set a Mongolian text (for instance "á ªá á ¢á ¨á á ") into an AWT / Swing control and a Mongolian + DevanÄgarÄ« or DevanÄgarÄ« + Mongolian text in another (for instance "á ªá á ¢á ¨á á ठनà¥à¤à¥à¤à¥à¤¦" or "ठनà¥à¤à¥à¤à¥à¤¦ á ªá á ¢á ¨á á ").
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Mongolian text is correctly shaped in both cases
ACTUAL -
The Mongolian text is correctly shaped in the second case, as the other "complex" text triggers the proper shaping, but it is incorrectly shaped in the first case (something like "á ª á á ¢ á ¨ á ").
The example source attached below shows wrong and correct shaping cases for Swing labels; other controls exhibit the same behaviour.
---------- BEGIN SOURCE ----------
package com.vistamaresoft.swingtest;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Main
{
private JFrame frame;
private static Main window;
public Main()
{
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setTitle("Mongolian Swing Test");
frame.setBounds(100, 100, 300, 200);
//Set up the GUI.
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
JLabel label = new JLabel("á ªá á ¢á ¨á á "); // NOT CORRECT
panel.add(label);
label = new JLabel("Abc á ªá á ¢á ¨á á "); // NOT CORRECT
panel.add(label);
label = new JLabel("á ªá á ¢á ¨á á Ùتاب "); // CORRECT
panel.add(label);
label = new JLabel("Ùتاب á ªá á ¢á ¨á á "); // CORRECT
panel.add(label);
label = new JLabel("á ªá á ¢á ¨á á ठनà¥à¤à¥à¤à¥à¤¦"); // CORRECT
panel.add(label);
label = new JLabel("ठनà¥à¤à¥à¤à¥à¤¦ á ªá á ¢á ¨á á "); // CORRECT
panel.add(label);
frame.setContentPane(panel);
}
public static void main(String[] args)
{
window = new Main();
window.frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
As adding arbitrary strings to UI element to trigger the correct shaping is in general not feasible, I am not aware of any workaround.
FREQUENCY : always
- relates to
-
JDK-8246036 [macos] Mongolian characters and Yi Syllables are displayed as rectangles
- Closed
-
JDK-8252220 Errors in shaping Mongolian characters
- Open
-
JDK-8297334 Tifinagh characters not rendered properly in JavaFX
- Closed