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

Italicization problem in ru_RU.ISO8859-5 & ru_RU.KOI8-R Solaris environments.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.3.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_7, solaris_8

      Description


      Running with JDK 1.3 pre-FCS build E. Source code is attached. When
      run the test window has 5 tabs in a TabbedPane: (1) "AWT Labels",
      (2) "AWT TextFields", (3) "Swing Components", (4) "Java2D Stroke", and
      (5) "Java2D Fill". Each of the panes presents an string using
      (1) Plain, (2) Italic, (3) Bold, and (4) BoldItalic fonts. Generic fonts
      are used: (1) Serif, (2) SansSerif, (3) Monospaced, (4) Dialog, and
      (5) DialogInput.

      algol.eng.sun.com% uname -a
      SunOS algol.eng.sun.com 5.8 s28_31 sun4u sparc SUNW,Ultra-2

      The tests were run, logging into the language environments
      ru_RU.ISO8859-5

      AWT Labels and AWT TextFields
         Monospaced Italic is not italicized.
         DialogInput Italic is not italicized.
         Monospaced BoldItalic is not italicized.
         DialogInput BoldItalic is not italicized.
      Swing Components, Java2D Stroke, and Java2D Fill
         Italic and BoldItalic cell entries are not italicized.

      and ru_RU.KOI8-R

      AWT Labels
         Monospaced Italic is not italicized.
         DialogInput Italic is not italicized.
         Monospaced BoldItalic is not italicized.
         DialogInput BoldItalic is not italicized.
      AWT TextFields
         Bold, Italic, and BoldItalic is not rendered correctly at all.
      Swing Components, Java2D Stroke, and Java2D Fill
         Italic and BoldItalic cell entries are not italicized.

      allan.jacobs@Eng 1999-09-14


      import java.awt.BorderLayout;
      import java.awt.Button;
      import java.awt.Color;
      import java.awt.Container;
      import java.awt.Dimension;
      import java.awt.Font;
      import java.awt.FontMetrics;
      import java.awt.Graphics;
      import java.awt.GridLayout;
      import java.awt.Label;
      import java.awt.Rectangle;
      import java.awt.TextField;
      import java.awt.Toolkit;
      import java.awt.event.WindowEvent;
      import java.awt.event.WindowListener;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JPanel;
      import javax.swing.JTabbedPane;
      import java.text.DateFormatSymbols;
      import java.util.Locale;
      import java.util.Calendar;
      import java.lang.reflect.Constructor;

      /**
       * Demo program to identify problems with fonts.
       */

      public class FontTest extends JFrame implements WindowListener {

          static String testString;
          static String testDOW;
          static int fontSize = 20;

          private static String localeString =
              Locale.getDefault().toString() + "/" +
              Locale.getDefault().getDisplayLanguage();

          private static final String[] families =
          { "Serif", "SansSerif", "Monospaced", "Dialog",
            "DialogInput" /*, "Default" */
          };

          private static final int[] styles =
          { Font.PLAIN, Font.BOLD, Font.ITALIC, Font.BOLD + Font.ITALIC };

          private static final String[] styleNames =
          { "Plain", "Bold", "Italic", "BoldItalic" };

      private static String[] weekDays =
      (new DateFormatSymbols(Locale.getDefault())).getWeekdays();

          FontTest() {
              addWindowListener(this);
          }

          private void addPanel(JTabbedPane pane, int type) {

              JPanel jpanel = new JPanel();
              Container panelContainer = getContentPane();
              jpanel.setLayout(new GridLayout(families.length + 1,
                                              styles.length + 1));
              jpanel.add(new Label(localeString));

              switch (type) {
              case 0:
                  for (int i = 0; i < styles.length; ++i) {
                      jpanel.add(new Label(styleNames[i]));
                  }
                  for (int j = 0; j < families.length; ++j) {
                      jpanel.add(new Label(families[j]));
                      for (int i = 0; i < styles.length; ++i) {
                          Label label = new Label("foo!");
                          Font font = new Font(families[j], styles[i], fontSize);
                          //System.out.println(font);
                          label.setFont(font);
                          label.setText(testString);
                          jpanel.add(label);
                      }
                  }
                  pane.add(jpanel, "AWT Labels");
                  break;

              case 1:
                  for (int i = 0; i < styles.length; ++i) {
                      jpanel.add(new Label(styleNames[i]));
                  }
                  for (int j = 0; j < families.length; ++j) {
                      jpanel.add(new Label(families[j]));
                      for (int i = 0; i < styles.length; ++i) {
                          TextField textField = new TextField("foo!");
                          Font font = new Font(families[j], styles[i], fontSize);
                          //System.out.println(font);
                          textField.setFont(font);
                          textField.setText(testString);
                          jpanel.add(textField);
                      }
                  }
                  pane.add(jpanel, "AWT TextFields");
                  break;

              case 2:
                  for (int i = 0; i < styles.length; ++i) {
                      jpanel.add(new JLabel(styleNames[i]));
                  }
                  for (int j = 0; j < families.length; ++j) {
                      jpanel.add(new JLabel(families[j]));
                      for (int i = 0; i < styles.length; ++i) {
                          JLabel label = new JLabel("foo!");
                          Font font = new Font(families[j], styles[i], fontSize);
                          //System.out.println(font);
                          label.setFont(font);
                          label.setText(testString);
                          jpanel.add(label);
                      }
                  }
                  pane.add(jpanel, "Swing Components");
                  break;

              case 3:
              case 4:
                  for (int i = 0; i < styles.length; ++i) {
                      jpanel.add(new JLabel(styleNames[i]));
                  }
                  for (int j = 0; j < families.length; ++j) {
                      jpanel.add(new JLabel(families[j]));
                      for (int i = 0; i < styles.length; ++i) {

                          try {
                              JPanel label;
                              Constructor f2dConstructor;
                              Class f2dClass;
                              String f2dClassName;
                              Class args[] = new Class[] {
                                  Class.forName("java.lang.String"),
                                  Integer.TYPE, Integer.TYPE };
                              Object params[] = new Object[] {
                                  families[j],
                                  new Integer(styles[i]),
                                  new Integer(16) };

                              f2dClassName = (type == 3) ? "FontTest2DStroke"
                                                         : "FontTest2DText";
                              f2dClass = Class.forName(f2dClassName);
                              f2dConstructor = f2dClass.getConstructor(args);

                              label = (JPanel) f2dConstructor.newInstance(params);

                              jpanel.add(label);
                          } catch (ClassNotFoundException e) {
                              jpanel.add(new JLabel("*missing*"));
                          } catch (Exception e) {
                              e.printStackTrace();
                              System.exit(-1);
                          }
                      }
                  }
                  pane.add(jpanel, "Java2D " + ((type == 3) ? "Stroke" : "Fill"));
                  break;
              }
              pane.setSelectedComponent(jpanel);
              pack();
              setVisible(true);
          }

          public void windowDeactivated(WindowEvent e) {}
          public void windowDeiconified(WindowEvent e) {}
          public void windowIconified(WindowEvent e) {}
          public void windowOpened(WindowEvent e) {}
          public void windowActivated(WindowEvent e) {}
          public void windowClosing(WindowEvent e) {
              dispose();
          }
          public void windowClosed(WindowEvent e) {
              System.exit(0);
          }

          public static void main(String[] args) {
              boolean labelTest = false;
              boolean textFieldTest = false;
              boolean swingTest = false;
              boolean strokeTest = false;
              boolean textTest = false;

              // Use "Monday" in default langauge as test string.
              // Except: Turkish, Lithuanian, Latvian, choose Wednesday which has
              // non-ISO8859-1 chars.

              int weekday = (localeString.startsWith("lt") ||
                             localeString.startsWith("lv") ||
                             localeString.startsWith("tr")) ? 4 : 2;
      // testDOW = new DateFormatSymbols().getWeekdays()[weekday];
              testDOW = new DateFormatSymbols().getWeekdays()[Calendar.WEDNESDAY];
              testString = testDOW + "Abc";

      System.err.println("Locale: " + localeString);
      System.err.println("Variant: " + Locale.getDefault().getVariant());
      System.err.println("Country: " + Locale.getDefault().getCountry());
      System.err.println("User.language: " + System.getProperty("user.language"));
      System.err.println("User.region: " + System.getProperty("user.region"));
              if (Locale.getDefault().getVariant().equals("EURO"))
                  testString += "\u20ac";

              //String x = "ISO8859-9".toLowerCase();
              //for (int i=0; i < x.length(); ++i)
              //System.err.println((int)x.charAt(i));

              if (args.length == 0)
                  labelTest = textFieldTest = swingTest =
                      strokeTest = textTest = true;

              for (int i = 0; i < args.length; ++i)
                  if (args[i].equalsIgnoreCase("all"))
                      labelTest = textFieldTest = swingTest =
                          strokeTest = textTest = true;
                  else if (args[i].equalsIgnoreCase("label"))
                      labelTest = true;
                  else if (args[i].equalsIgnoreCase("text"))
                      textFieldTest = true;
                  else if (args[i].equalsIgnoreCase("swing"))
                      swingTest = true;
                  else if (args[i].equalsIgnoreCase("stroke"))
                      strokeTest = true;
                  else if (args[i].equalsIgnoreCase("fill"))
                      textTest = true;
                  else {
                      System.err.println("Unsupported argument: " + args[i]);
                      System.exit(-1);
                  }

              FontTest test = new FontTest();
              Container container = test.getContentPane();
              container.setLayout(new BorderLayout());

              String monoStatus;
              Font statusFont = new Font("monospaced", Font.PLAIN, fontSize);
              FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(statusFont);
              String testABC = "ABCdef";
              int wDOW = fm.stringWidth(testDOW);
              int wABC = fm.stringWidth(testABC);

              System.out.println("wDOW=" + wDOW + ", wABC=" + wABC);
              if (wABC * testDOW.length() == wDOW * testABC.length())
                  monoStatus = "Full Width ISO";
              else if (wABC * 2 * testDOW.length() == wDOW * testABC.length())
                  monoStatus = "Half Width ISO";
              else
                  monoStatus = "Unpredictable width";

              Label status = new Label(monoStatus);
              status.setFont(statusFont);
              container.add(status, BorderLayout.NORTH);

              JTabbedPane pane = new JTabbedPane();
              container.add(pane, BorderLayout.CENTER);

              if (labelTest)
                  test.addPanel(pane, 0);
              if (textFieldTest)
                  test.addPanel(pane, 1);
              if (swingTest)
                  test.addPanel(pane, 2);
              if (strokeTest)
                  test.addPanel(pane, 3);
              if (textTest)
                  test.addPanel(pane, 4);
              test.addWindowListener(test);
          }
      }

      allan.jacobs@Eng 1999-09-14

      Broken in build M (of course). Broken on Solaris 7.

      allan.jacobs@Eng 1999-11-11

        Attachments

          Activity

            People

            Assignee:
            sherman Xueming Shen
            Reporter:
            ajacobssunw Allan Jacobs (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: