是否可以在 HTML canvas 中使用 HTML unicode?

Is it possible to use HTML unicodes inside HTML canvas?

我正在尝试构建一个二维国际象棋游戏,发现 HTML 中内置了国际象棋棋子的 Unicode,是否可以使用 canvas 中的棋子?如果是,怎么做?

Unicode 本身与 HTML 没有任何关系,尽管 HTML 支持 Unicode character escapes

无论如何,您可以只在 <canvas>:

中呈现文本

const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");

const size = 16;
ctx.font = `${size}px sans-serif`;
ctx.fillText("\u2654", 0, size); // See https://en.wikipedia.org/wiki/Chess_symbols_in_Unicode
<canvas></canvas>