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

Wrong comparison expression in constructor sun.font.CompositeStrike(CompositeFont, FontStrikeDesc)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 6
    • 5.0u1
    • client-libs
    • 2d
    • b43
    • generic
    • generic

      The constructor sun.font.CompositeStrike(CompositeFont, FontStrikeDesc) has an expression, which will always return false.

            CompositeStrike(CompositeFont font2D, FontStrikeDesc desc) {
                this.compFont = font2D;
                this.desc = desc;
                this.disposer = new FontStrikeDisposer(compFont, desc);
                if (desc.style != compFont.style) {
                    algoStyle = true;
                    if ((desc.style & Font.BOLD) == 1 &&
                        ((compFont.style & Font.BOLD) == 0)) {
                        boldness = 1.33f;
                    }
                    if ((desc.style & Font.ITALIC) == 1 && // <---- always false
                        (compFont.style & Font.ITALIC) == 0) {
                        italic = 0.7f; // <----------------------- never reached
                    }
                }
                strikes = new PhysicalStrike[compFont.numSlots];
            }

      The Font.ITALIC is specified in java.awt.Font:
      public static final int ITALIC = 2;

      The expression "(desc.style & Font.ITALIC) == 1" will always return false, because a bit by bit and-comparison with the value of 2 can never be equals 1.
      Example: 0xFFFFFFFF & 2 will return 2, not 1.
      As a result, the assignment to the italic float primitive will never be reached.

      There is no problem with the expression containing Font.BOLD, because the value of Font.BOLD is 1.
      ###@###.### 2005-03-11 15:15:57 GMT

            prr Philip Race
            jloefflm Johann Löfflmann (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: