Is there a way to print Greek letters on HTML5 canvas? I tried using html entity name and number like
canvas2.cx.fillText("ξ", 50, 50);
and
canvas2.cx.fillText("ξ", 50, 50);
but he just prints it literally because the canvas does not know to interpret these characters.
Just use UTF-8.
You do not need to avoid characters in order to write them in HTML or Canvas.
Use the correct title in the document:
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF8">
If you want to limit your JavaScript ASCII source code, but should still contain non-ASCII characters in a string, you can use the Unicode escape sequence: (small xi code is U + 03BE):
canvas2.cx.fillText("\u03be", 50, 50);
α β? UTF-8, . :
α
β
canvas2.cx.fillText("α", 50, 50);