HTML5 Guidelines for Web Developers

(coco) #1

132 Chapter 5—Canvas


Figure 5.17 Font formatting with the “font” attribute

At the time of this writing, no browser supported @font-face without problems.
In Firefox, for example, the webfont Scriptina in the last line only appears in Can-
vas if it is used at least once in the HTML document. The correct implementation
of small-caps is also missing in Firefox, which is why the second to last example
is not displayed correctly either.

5.6.2 Horizontal Anchor Point


The attribute textAlign determines the horizontal anchor point of Canvas texts:

context.textAlign = [
left | right | center | *start | end
]

The keywords left, right, and center are familiar from the CSS attribute text-
align, whereas start and end are already CSS3 extensions that allow for text di-
rection, depending on the appropriate language. Some languages are written not
from left to right but sometimes from right to left, as for example, Arabic and
Hebrew.
Free download pdf