Text Handling in SVG
Text handling in SVG is carried out with three elements— <text>, which is always used when laying out text, and, optionally, <tspan> and <tref> elements.
The <text> Element
To lay out text, the SVG rendering engine needs to know, in addition to what characters to render, where to place the text, what font and font size to use, and so on. You saw in Listing 23.1, the rollover button example, how text is used with a rollover button.
It is important to notice the difference in how the x and y attributes of <rect> and <text> elements are used. Listing 23.21 illustrates the difference in usage.
Listing 23.21. The Difference in Usage of x and y Attributes in <text> and <rect> Elements (DiffTextRect.svg)
<?xml version="1.0" standalone="no"?> ... |
Get Special Edition Using XML, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.