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

bolded zero width space has non zero width in FM or LCD modes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 7
    • 6
    • client-libs
    • 2d
    • b28
    • generic
    • generic
    • Verified

      For algorithmically bolded Lucida Sans Regular \u200b char - which is a zero width
      space - will in some cases report its advance to be 1 pixel.

      Although this was first seen with LCD_HRGB, it is also reproducible in AA and BW modes if
      fractional metrics is enabled. Problem is reproducible with T2K rasterizer.

      ==========================
      import java.awt.*;
      import java.awt.image.*;

      public class met {
          public static void main(String[] s) {
              BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);

              Graphics g = bi.getGraphics();

              g.setFont(new Font("monospaced", Font.BOLD, 14));
              //g.setFont(new Font("Lucida Sans Regular", Font.BOLD, 14));
              FontMetrics fm = g.getFontMetrics();
              System.out.println("Bold: " + fm.charWidth('\u200b'));
              ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                                       RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
              fm = g.getFontMetrics();
              System.out.println("Bold + LCD: "+fm.charWidth('\u200b'));
              ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
                                       RenderingHints.VALUE_FRACTIONALMETRICS_ON);
              ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                                       RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
              fm = g.getFontMetrics();
              System.out.println("Bold FM OFF + AA: " + fm.charWidth('\u200b'));
              ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
                                       RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
              ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                                       RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
              fm = g.getFontMetrics();
              System.out.println("Bold FM ON + AA: " + fm.charWidth('\u200b'));
              ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
                                       RenderingHints.VALUE_FRACTIONALMETRICS_ON);
              ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                                       RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
              fm = g.getFontMetrics();
              System.out.println("Bold FM ON + nonAA: " + fm.charWidth('\u200b'));

              System.out.println("All printed values should be 0 to PASS");
          }
      }

            igor Igor Nekrestyanov (Inactive)
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: