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.