Greek letters in HTML5 canvas

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.

+3
source share
3 answers

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">
+11
source

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);
+8
source

α β? UTF-8, . :

canvas2.cx.fillText("α", 50, 50);
+1

All Articles