From the course: Learning HTML Canvas

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Drawing text

Drawing text

From the course: Learning HTML Canvas

Start my 1-month free trial

Drawing text

- [Instructor] In addition to drawing shapes, and curves, and paths, and so on, you can also draw text directly onto the canvas using a variety of text drawing functions. In fact, drawing text is very similar to drawing any other paths. You can stroke and fill text using the same fillStyle and strokeStyle as you would for other path and shape operations. So it's important to note that when you draw text on the canvas, it is not affected by any kind of CSS rules in the page. It's just a path, and it's drawn using the current canvas settings. And it's also important to note that you shouldn't use text on the canvas as a replacement for regular document text because that makes accessibility really, really hard. In fact, screen readers won't be able to read the text that you draw on the canvas, so if have any grand ideas about using canvas to replace headings like h1s or h2s, yeah, it sounds like a great idea, but you should probably find another way to do that, because…

Contents