15.4 Styling Text

From most viewpoints, text objects are no different from any other object type; you can not only transform but also style (choose fill or stroke, adjust opacity, apply filters, etc.) a text object as a whole without even going into the Text tool (and, of course, without losing the ability to edit the text). However, only the Text tool allows you to change style properties specific to text (such as font family and font size) as well as apply style to spans (fragments) of a text in an object.

SVG

To have a different style, a span of text must be enclosed within a span element. You don’t need to think about it, of course; for any overlapping or nested spans you create or delete, Inkscape manages the span elements automatically.

The two places where you can change text styles are the controls bar of the Text tool (above the canvas) and the Text and Font dialog. The former is faster and more convenient, while the latter provides access to more options.

When you have a text span selected in the Text tool, most (but not all) style-changing commands and style-reporting UI elements apply to that text span, not to the entire text object. For example, you can easily change the color of a span of text by selecting it and clicking a color swatch in the palette, using the Fill and Stroke dialog (8.1.1 Paint), or color gestures (8.5 The Selected Style Indicator: Color Gestures). Similarly, you can assign or remove a stroke or adjust opacity of the span. However, blur or other filters cannot be applied to a span; if you try this, the entire text object will be blurred or filtered.

Assigning a gradient or pattern fill to a span is possible, though it is a bit tricky. You need to create a separate object with the gradient or pattern you need, copy it (), then select a text span with the Text tool, and paste the style () onto it. Unfortunately, you cannot then edit such a gradient on a span by dragging the handles in the Gradient tool.

In general, the paste style trick is very handy when styling text spans—it allows you to quickly transfer styles (including not only color but also font, size, letter spacing, etc.) between objects and parts of your text. To copy a style from a text span, you don’t even need to select it; just place the text editing cursor anywhere inside the span and press .

With regard to fonts, Inkscape behaves as could be expected from a modern graphic application: It allows you to use any outline fonts (TrueType, OpenType, Type 1) that are installed in your operating system.

The list of all font families (not individual fonts), with graphic samples for each family, opens from the controls bar of the Text tool. You can choose a family by scrolling through the list; if you know the name of the font you need, you can click to place the cursor in the editing field and start typing; a dropdown list of possible completions will appear.

The same list of font families is also available in the Text and Font dialog (), as shown in Figure 15-19. Here, instead of a small generic sample, you can see a preview of the selected text object in the chosen font with the chosen font size.

Many fonts contain variants within the same families. In the controls bar, you can set bold, italic (oblique), or bold italic variants for your selected span, using the two toggle buttons; the and shortcuts, expectedly, work the same as these two buttons. In the Text and Font dialog, you have a complete list of all variants available in the family, which apart from italic and various weights (light, medium, bold, heavy, etc.) may include variations along the width axis (condensed, stretched, etc.). Once you choose a style you need in the dialog, click Apply for the changes to take effect.

Both in the controls bar and in the dialog, font size may only be set in px units (A.6 Coordinates and Units). However, in many cases you don’t even need to use that numeric control; you can simply scale an entire text object instead, for example, with the Selector tool (6.2 The Selector: Scaling) or keyboard shortcuts. Both font size controls will then take this scaling into account when displaying font sizes; for example, if you set a text object to 12 px font size but then scale it up twice, you will see its font size reported as 24 px.