Co-authors: Paul Cheeseman, Ravi Patel, Syed Moinudeen
Problem
This article originates from a problem we investigated where some users of the IBM Semeru Runtime were not able to properly view Thai characters on the Windows operating system. The IBM Semeru Runtimes is generally a drop-in replacement for any OpenJDK based Java distribution, providing a no-cost Java runtime environment optimised for performance with broad platform support, so this improper display of Thai characters on Windows was a bit of a surprise. Instead of the expected Thai characters, users may see blank squares or rectangular placeholders commonly referred to as "tofu" which indicate that the system is unable to render the text properly. This typically occurs because the runtime cannot find a font that supports the Thai script. The issue can be reproduced with a simple standalone Java program, as shown below.
Example Java program
import javax.swing.*;
import java.awt.*;
public class ThaiFontTest {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame("Thai Font Rendering Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 200);
String thaiText = "\u0E2A\u0E27\u0E31\u0E14\u0E35";
JLabel label = new JLabel(thaiText, SwingConstants.CENTER);
label.setFont(new Font("Dialog", Font.PLAIN, 24));
frame.getContentPane().add(label);
frame.setVisible(true);
});
}
}
If you have not installed IBM Semeru Runtimes on your system, it's really easy with SDKMAN. The below commands can be used to install IBM Semeru 21 and to check java version.
sdk install java 21.0.6-sem
$ java -version
openjdk version "21.0.6" 2025-01-21 LTS
IBM Semeru Runtime Open Edition 21.0.6.0 (build 21.0.6+7-LTS)
Eclipse OpenJ9 VM 21.0.6.0 (build openj9-0.49.0, JRE 21 Mac OS X aarch64-64-Bit 20250121_371 (JIT enabled, AOT enabled)
OpenJ9 - 3c3d179854
OMR - e49875871
JCL - e01368f00df based on jdk-21.0.6+7)
As shown below, blank squares or rectangular placeholders may be displayed instead of the expected Thai characters: