O'Reilly logo

Core HTML5 Canvas: Graphics, Animation, and Game Development by David Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Text

Nearly every Canvas-based application deals with text. Some applications merely configure and display text, whereas other applications provide sophisticated text editing support.

The canvas element only minimally supports text; at the time this book was written, it does not offer many of the features that you will find in basic text editors, features such as text selection, copy and paste, and text scrolling. However, it does support basic necessities such as stroking and filling text, placing text within the canvas, and measuring the width, in pixels, of an arbitrary string. The Canvas context provides three methods pertaining to text:

strokeText(text, x, y)

fillText(text, x, y)

measureText(text)

The measureText() method ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required