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

11x: Long string of Japanese characters in bold font is cut off (Japanese W95)

XMLWordPrintable

    • x86
    • windows_nt



      Name: vuC71690 Date: 02/11/98

      uwe@russia

      There's a number of bugs filed against JavaWorkshop and JavaStudio
      that report that Japanese text in bold font is not displayed properly.
      The tail of the string appears chopped.

      Below is a simple test case that displays two labels with the same
      Japanese text, one in bold and one in plain font. It appears that the
      bold text is cut off at exactly the width of the plain label.

      If you append some text in Latin to the caption you'll see that the
      japanese is cut off but the Latin appears at correct position (after
      the blank gap where the tail of the Japanese text should be).

      ----8<--------8<--------8<--------8<--------8<--------8<--------8<----
      import java.awt.*;
      import java.awt.event.*;

      public class TestFonts extends Frame {
        public TestFonts () {
          StringBuffer buf = new StringBuffer();
          for (char c = '\u304B'; c < '\u306D'; ++c)
            buf.append(c);
          String caption = buf.toString();

          addWindowListener(new WindowAdapter () {
            public void windowClosing(WindowEvent e) {
      System.exit(0);
            }
          });

          setLayout(new BorderLayout());
          setBackground(Color.white);

          Panel top = new Panel(new FlowLayout(FlowLayout.LEFT));
          Label bl = new Label(caption, Label.LEFT);
          bl.setBackground(Color.lightGray);
          Font boldLabelFont = new Font("dialog", Font.BOLD,14);
          bl.setFont(boldLabelFont);
          top.add(bl);
          add(top, "North");

          Panel mid = new Panel (new FlowLayout(FlowLayout.LEFT));
          Label pl = new Label(caption, Label.LEFT);
          pl.setBackground(Color.lightGray);
          Font plainLabelFont = new Font("dialog", Font.PLAIN,14);
          pl.setFont(plainLabelFont);
          mid.add(pl);
          add(mid, "Center");

          Panel info = new Panel(new BorderLayout());

          TextArea dbg = new TextArea();
          dbg.setEditable(false);
          dbg.setFont(new Font("monospaced", Font.PLAIN, 14));
          info.add(dbg, "Center");
          add(info, "South");

          pack();

          FontMetrics boldMetrics = bl.getToolkit().getFontMetrics(boldLabelFont);

          dbg.append("Bold label caption width is "
      + boldMetrics.stringWidth(caption) + "\n");

          Dimension bd = bl.getSize();
          dbg.append("Bold label size is "+bd.width+"x"+bd.height+"\n");

          FontMetrics plainMetrics = pl.getToolkit().getFontMetrics(plainLabelFont);

          dbg.append("Plain label caption width is "
      + plainMetrics.stringWidth(caption) + "\n");

          Dimension pd = pl.getSize();
          dbg.append("Plain label size is "+pd.width+"x"+pd.height+"\n");

          show();
        }

        public static void main(String[] args) {
          new TestFonts();
        }
      }
      ----8<--------8<--------8<--------8<--------8<--------8<--------8<----

      We discovered that this is a JDK 1.1.x bug that manifests on Japanese
      W95 only. All JDK up to 1.1.5-FCS that we tried has this bug.

      MSIE3 and Netscape Communicator 4 on JW95 does *NOT* has this bug.

      This bug does NOT manifest on NT, neither Japanese, nor "western".
      This bug, surpisingly, does NOT manifest on OSR2 Win95 PE. For tests
      on "western" windows we installed MSIE3 add-on for Japanese available
      from http://www.microsoft.com/msdownload/ieplatform/lang/lang.htm,
      that contains MS Gothic font. We than merged font.properties with
      font.properties.ja.

      JDK1.2T (the earliest version of 1.2 we had access to) on JW95 does
      NOT has this bug.

      The test case behavior suggested the following possible cause of this
      bug. Windows emulate bold font if there's none. GDI synthesizes bold
      fonts by outputting the text twice, offsetting the second output by
      one pixel. It appears that this overhang is not taken into account.
      See MS Knowledge Base, Article ID: Q74298 "Calculating Text Extents of
      Bold and Italic Text".

      Hook 3(hook3): js-i18n, jwsi18n
      ======================================================================

            mmartaksunw Michael Martak (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: