A.5 Text Styles

A text style defines the font and color to be used in labeling spatial features.

The class attribute must have the value "text". For the font, you can specify its style (plain, italic, and so on), font family, size, and weight. To specify the foreground color, you use the fill attribute.

The following example defines a text style:

<?xml version="1.0" standalone="yes"?>
<svg width="1in" height="1in">
   <g class="text" style="font-style:plain; font-family:Dialog; font-size:14pt;
             font-weight:bold; fill:#0000ff">
    Hello World!
   </g>
</svg>

In the preceding example, the text "Hello World!" is displayed only when the style itself is being previewed in a style creation tool, such as the Map Builder tool. When the style is applied to a map, it is always supplied with an actual text label that the map visualization component obtains from a theme.

A text style can provide a floating white background around the rendered text, to make the labels easier to read on a map that has many features. Figure A-2 shows the label Vallejo with a white background wrapping tightly around the letters.

Figure A-2 Text Style with White Background

Description of Figure A-2 follows
Description of "Figure A-2 Text Style with White Background"

To achieve the result shown in Figure A-2, you must specify the float-width attribute in the <g> element of the text style definition. The following example uses the float-width attribute (shown in bold in the example) to specify a white background that extends 3.5 pixels from the boundary of each letter. (The Hello World! text is ignored when the style is applied to the display of labels.)

<?xml version="1.0" standalone="yes"?>
<svg width="1in" height="1in">
<desc></desc>
<g class="text"  float-width="3.5"  
   style="font-style:plain; font-family:Dialog; font-size:12pt; font-weight:bold;
     fill:#000000">
 Hello World!
</g>
</svg>