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

Stroked text not measured correctly on Canvas (breaks effects/etc)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 8
    • javafx
    • None

      Stroked text not measured correctly on Canvas (breaks effects/etc)

      I broke this case when I pushed this changeset:
      RT-26270: Fix NGCanvas to use NGSpan/TextLayout
      http://jfxsrc.us.oracle.com/javafx/8.0/scrum/graphics/rt/rev/53aa1e174202


      Before that the text bounds were computed by the late NGTextHelper.
      I moved the needed functionality inside of NGCanvas, which was fine since it had all the support there to handle other shapes.

      What I missed is that the final bounds for stroked text is the union of the shape bounds and text logical bounds.
      If you have an old repo around the relevant code is in NGTextHelper lines 1198:1201:
                      // Stroked text requires visual bounds, when include padding
                      BaseBounds vBounds = computeBoundsVisual(null, IDENT);
                      // Union between logical and visual bounds
                      retBounds.deriveWithUnion(vBounds);

      Had the string in your test case had a 'q' or 'p' the bug would not have shown as much as it was the space of the font descent which was missing.

            fheidric Felipe Heidrich (Inactive)
            fheidric Felipe Heidrich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: