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

Font.decode does not work with certain font styles for Asian locales

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.2.1
    • client-libs
    • 2d
    • sparc
    • solaris_7

      In our product we have a number of places where Font.decode("times-bold-14") is used. In jdk 1.1 this worked fine for both English and Asian locales. In java2 it only works for English locales. It causes Asian locales to have the translated text show up as little squares. This also fails for "helvetica" and "courier". If I replace "times" with "dialog", "sansserif" or "serif" it works ok. If there is a change we need to make, then please advise (and document). A simple test case is included. FontTest.java: import java.awt.*;
      import javax.swing.*;
      import java.util.*;

      class FontTest extends JFrame {

          ResourceBundle bundle;

          public FontTest() {
              bundle = ResourceBundle.getBundle("TestBundle", Locale.getDefault());
              JPanel p = new JPanel();
              JLabel l = new JLabel(bundle.getString("browser"));
              l.setFont(Font.decode("serif-bold-14"));
              p.add(l);
              getContentPane().add(p);
          }

          public static void main(String[] args) {
              FontTest ft = new FontTest();
              ft.pack();
              ft.validate();
              ft.show();
          }
      } TestBundle.properties:
      browser=Browser TestBundle_zh_TW.properties:
      browser=\u700f\u89bd\u5668

            pkejriwasunw Parry Kejriwal (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: