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

[macosx] Problems when rendering Thai texts on OS X 10.9 Mavericks

XMLWordPrintable

    • 2d
    • os_x

      FULL PRODUCT VERSION :
      1.7.0_45
      1.8.0-ea-b121
      1.7.0_60-ea-b02

      ADDITIONAL OS VERSION INFORMATION :
      ProductName: Mac OS X, ProductVersion: 10.9.1, BuildVersion: 13B42

      A DESCRIPTION OF THE PROBLEM :
      Rendering diacritic characters in Thai texts does not work in DIALOG-Font, SANS_SERIF-Font and several other fonts, when running on OS X 10.9.
       

      ADDITIONAL REGRESSION INFORMATION:
      Works on OS X 10.8.5 (Mountain Lion) with same JVM


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      create a Java application with a TextArea or TextField and paste a Thai text into the field.
      You can use the URL "http://translate.google.com/#auto/th/ABCD%20you%20are%20the%20greatest" for this.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Should render correct diacritic characters
      ACTUAL -
      Diacritic characters are rendered as separate character.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.BorderLayout;
      import java.awt.Font;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      import javax.swing.JComboBox;
      import javax.swing.JFrame;
      import javax.swing.JTextArea;
      import javax.swing.JTextField;

      public class ThaiText
          implements ActionListener
      {
          JTextField textField;
          JTextArea textArea;

          public ThaiText()
          {
              JFrame frame = new JFrame("ThaiText <"+System.getProperty("java.runtime.version")+">");
              
              // create a text fiels and a text area
              textField = new JTextField(30);
              frame.add(textField, BorderLayout.NORTH);
              
              textArea = new JTextArea(10, 30);
              frame.add(textArea, BorderLayout.CENTER);
              
              // create a font list
              String[] action = new String[]
                      {
                          "Lucida Grande", // Error
                          Font.DIALOG, // Error
                          Font.SANS_SERIF, // Error
                          Font.MONOSPACED, // OK
                          "Ayuthaya", // OK
                          "Thonburi", // Error
                      };
              JComboBox<String> combo = new JComboBox<String>(action);
              combo.setSelectedIndex(0);
              combo.addActionListener(this);
              frame.add(combo, BorderLayout.SOUTH);

              // set a THAI text
              // you can use url "http://translate.google.com/#auto/th/ABCD%20you%20are%20the%20greatest"
              // to create it too
              String text = "ABCD ????????????????????????????????????????????????????????????????????????";
              textField.setText(text);
              textArea.setText(text);
              
              System.err.println("ThaiText.ThaiText() Initial Font: "+textField.getFont());
              frame.pack();
              frame.setVisible(true);
          }
          
          @Override
          public void actionPerformed(ActionEvent e)
          {
              String fontName = (String)((JComboBox)e.getSource()).getSelectedItem();
              
              Font font = Font.decode(fontName);
              if(font==null)
              {
                  System.err.println("ERROR ThaiText.actionPerformed() font == null");
                  return;
              }
              textArea.setFont(font);
              textField.setFont(font);
              
              // just to see the font type etc.
              textArea.setToolTipText(font.toString());
              textField.setToolTipText(font.toString());
          }
          
          private static void createAndShowGUI()
          {
              new ThaiText();
          }
          
          public static void main(String[] args)
          {
              javax.swing.SwingUtilities.invokeLater(new Runnable()
              {
                  public void run()
                  {
                      createAndShowGUI();
                  }
              });
          }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use MONOSPACED font or "Ayuthaya"-font

            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: