Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8298146

Thai/Laotian font displayed in the wrong position in java.awt.TextField

XMLWordPrintable

      Laotioan font is displayed in the wrong position on a java.awt.TextField
      The issue is observed in JDK 11.0.18 while not observed in 8u.
      See the attached images jdk8.png and jdk11.png
      Also, the issue is reproducible on Windows 10 and Server 2019.

      [Steps to reproduce]
      1. Confirm dokchamp.ttf is in C:\Windows\Fonts
      2. Run test code (TestFont.java)

      $ cat TestFont.java

      import java.awt.Button;
      import java.awt.Font;
      import java.awt.Frame;
      import java.awt.TextField;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      public class TestFont extends Frame implements ActionListener {
      private static Frame inFrame;
      private static TextField txfCode;
      private static Button btnOk;

      public static void main(String[] args) {
      new TestFont();
      }

      TestFont() {
      inFrame = new Frame();
      inFrame.setLayout(null);
      inFrame.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
      inFrame.setSize(300, 100);
      inFrame.setTitle("TestFont");

      txfCode = new TextField("\u0e02");
      txfCode.setBackground(new java.awt.Color(102,102,102));
      txfCode.setForeground(java.awt.Color.white);
      txfCode.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
      txfCode.setBounds(10, 52, 240, 20);
      inFrame.add(txfCode);

      btnOk = new Button("Exit");
      btnOk.setBounds(260, 50, 30, 24);
      inFrame.add(btnOk);
      btnOk.addActionListener(this);

      inFrame.setVisible(true);
      }

      @Override
      public void actionPerformed(ActionEvent e) {
      Font fntUser = txfCode.getFont();
      System.err.println("User: Font="+fntUser);
      System.exit(0);
      }

      }

      $ javac TestFont.java
      $ java -Dfile.encoding=x-windows-874 TestFont

        1. jdk8.png
          jdk8.png
          3 kB
        2. jdk11.png
          jdk11.png
          3 kB
        3. FixedTestFont.java
          1 kB

            alitvinov Anton Litvinov (Inactive)
            shadowbug Shadow Bug
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: