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

Canvas text rendering handles control character inconsistently, such as line feed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 7u6
    • 7u6
    • javafx


      context.font = "24pt Arial";
      context.textAlign = "center";
      context.fillStyle = "blue";
      context.fillText("Hello World!\nand\n3rd Line", x, y);

      The above code snipped will currently render text into multiple lines. But will have inconsistent alignment with JavaFX Text.

      - HTML5 Canvas strips out control characters, and only renders single line of text per fillText(...)
      - JavaFX Text however will create multiple lines and align them according to baseline, origin and wrapping width.

        1. CanvasTextAlignAfterFix.png
          40 kB
          Thor Johannesson
        2. CanvasTextAlignBeforeFix.png
          40 kB
          Thor Johannesson

            thor Thor Johannesson (Inactive)
            thor Thor Johannesson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: