Class

# TextShape

<div class="rst-class">

forsearch

</div>

Shape

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Draws a text string in a vector graphics environment.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                 | Type                                 | Read-Only | Shared |
|------------------------------------------------------|--------------------------------------|-----------|--------|
| `Bold<textshape.bold>`                               | `Boolean</api/data_types/boolean>`   |           |        |
| `FillColor<textshape.fillcolor>`                     | `Color</api/data_types/color>`       |           |        |
| `FillOpacity<textshape.fillopacity>`                 | `Double</api/data_types/double>`     |           |        |
| `FontName<textshape.fontname>`                       | `String</api/data_types/string>`     |           |        |
| `FontSize<textshape.fontsize>`                       | `Double</api/data_types/double>`     |           |        |
| `FontUnit<textshape.fontunit>`                       | `FontUnits</api/graphics/fontunits>` |           |        |
| `HorizontalAlignment<textshape.horizontalalignment>` | `Alignment<textshape.alignment>`     |           |        |
| `Italic<textshape.italic>`                           | `Boolean</api/data_types/boolean>`   |           |        |
| `Rotation<textshape.rotation>`                       | `Double</api/data_types/double>`     |           |        |
| `Scale<textshape.scale>`                             | `Double</api/data_types/double>`     |           |        |
| `Text<textshape.text>`                               | `String</api/data_types/string>`     |           |        |
| `Underline<textshape.underline>`                     | `Boolean</api/data_types/boolean>`   |           |        |
| `VerticalAlignment<textshape.verticalalignment>`     | `Alignment<textshape.alignment>`     |           |        |
| `X<textshape.x>`                                     | `Double</api/data_types/double>`     |           |        |
| `Y<textshape.y>`                                     | `Double</api/data_types/double>`     |           |        |

## Enumerations

<div id="textshape.alignment">

<div class="rst-class">

forsearch

</div>

</div>

TextShape.Alignment

### Alignment

> Used to set the HorizontalAlignment and VerticalAlignment properties. (Left, Top, Center, Baseline, Right, Bottom)
>
> | Enum     | Value |
> |----------|-------|
> | Left     | 0     |
> | Top      | 1     |
> | Center   | 2     |
> | Baseline | 3     |
> | Right    | 4     |
> | Bottom   | 5     |

## Property descriptions

<div id="textshape.bold">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.Bold

**Bold** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, applies the bold style to the text.
>
> On macOS, apps can only display font styles that are available. You cannot force a font to display in bold or italic if it does not have bold or italic variations available. In this situation, the Bold property will not affect the font.
>
> This code sets the text to Bold:
>
> ``` xojo
> Var s As New TextShape
> s.Text = "Hello World"
> s.Bold = True
> g.DrawObject(s)
> ```

<div id="textshape.fillcolor">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.FillColor

**FillColor** As `Color</api/data_types/color>`

> The color of the interior of the shape.

<div id="textshape.fillopacity">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.FillOpacity

**FillOpacity** As `Double</api/data_types/double>`

> The opacity of the interior, from 0 (completely transparent) to 100 (opaque).
>
> This example sets the Fill to 10% opacity.
>
> ``` xojo
> Var a As New TextShape
> a.Text = "Hello world!"
> a.FontSize = 24
> a.FillOpacity = 10
> a.FillColor = Color.Red
> g.DrawObject(a)
> ```

<div id="textshape.fontname">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.FontName

**FontName** As `String</api/data_types/string>`

> Name of the font used to display the text.
>
> You can enter any font that is installed on the computer or the names of the two metafonts, "System" and "SmallSystem".
>
> The System font is the font used by the system software as its default font. Different operating systems use different default fonts. If the system software supports both a large and small System font, you can also specify the "SmallSystem" font as your TextFont.
>
> On macOS, "SmallSystem" specifies the OS's smaller system font and may make the control smaller in size as well. On Windows and Linux, "SmallSystem" is the same as "System".
>
> This code sets the FontName property.
>
> ``` xojo
> Me.FontName = "Helvetica"
> ```

<div id="textshape.fontsize">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.FontSize

**FontSize** As `Double</api/data_types/double>`

> Point size of the font used to display the text.
>
> If you enter zero as the FontSize, your app will use the font size that works best for the platform on which it is running.
>
> This code sets the font size to 16 points.
>
> ``` xojo
> Me.FontSize = 16
> ```

<div id="textshape.fontunit">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.FontUnit

**FontUnit** As `FontUnits</api/graphics/fontunits>`

> The units in which the FontSize is measured. Use `FontUnits</api/graphics/fontunits>` rather than the numeric values in code.
>
> ``` xojo
> Me.FontUnit = FontUnits.Point
> ```

<div id="textshape.horizontalalignment">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.HorizontalAlignment

**HorizontalAlignment** As `Alignment<textshape.alignment>`

> Sets the horizontal alignment of the <span class="title-ref">TextShape</span>.
>
> The choices are: Left, Center, or Right. The default is Center. The alignment is relative to the `Object2D</api/graphics/object2d>`.X property.
>
> This example aligns the <span class="title-ref">TextShape</span> to the left.
>
> ``` xojo
> Var ts As New TextShape
> ts.X = 20
> ts.Text = "Hello World"
> ts.HorizontalAlignment = TextShape.Alignment.Left
> ```

<div id="textshape.italic">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.Italic

**Italic** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, applies the italic style to the text.
>
> Mac apps can only display font styles that are available. You cannot force a font to display in bold or italic if it does not have bold or italic variations available. In this situation, the Italic property will not affect the font.
>
> The following sets the Italic property for the control.
>
> ``` xojo
> Me.Italic = True
> ```

<div id="textshape.rotation">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.Rotation

**Rotation** As `Double</api/data_types/double>`

> Clockwise rotation, in radians, around the X, Y point. Only set the rotation after you have drawn all your objects.
>
> This code rotates the text 0.9 radians.
>
> ``` xojo
> Var a As New TextShape
> a.Text = "Hello World!"
> a.Rotation = 0.90
> g.DrawObject(a)
> ```

<div id="textshape.scale">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.Scale

**Scale** As `Double</api/data_types/double>`

> The scaling factor relative to the object's original size.
>
> The following code rescales the <span class="title-ref">TextShape</span> by a factor of 5.
>
> ``` xojo
> Var a As New TextShape
> a.Text = "Hello World!"
> a.Scale = 5
> g.DrawObject(a)
> ```

<div id="textshape.text">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.Text

**Text** As `String</api/data_types/string>`

> The text to draw.
>
> The text can be only one text style (font, font size, style) specified by the other <span class="title-ref">TextShape</span> properties. Use the FillColor property to change the color of the text. Use a carriage return between text to display with multiple lines. The default text is an empty string.

<div id="textshape.underline">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.Underline

**Underline** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, applies the underline style to the text.
>
> This code underlines the control's text.
>
> ``` xojo
> Me.Underline = True
> ```

<div id="textshape.verticalalignment">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.VerticalAlignment

**VerticalAlignment** As `Alignment<textshape.alignment>`

> Sets the vertical alignment of the <span class="title-ref">TextShape</span>.
>
> The choices are: Top, Baseline, or Bottom. The default is Baseline. The alignment is relative to the `Object2D</api/graphics/object2d>`.X and Y properties.
>
> This code aligns the <span class="title-ref">TextShape</span> to the top:
>
> ``` xojo
> Var ts As New TextShape
> ts.X = 20
> ts.Text = "Hello World"
> ts.VerticalAlignment = TextShape.Alignment.Top
> ```

<div id="textshape.x">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.X

**X** As `Double</api/data_types/double>`

> The horizontal position of the center or main anchor point.
>
> This example sets the horizontal position to 100 pixels from the left of the containing `Canvas</api/user_interface/desktop/desktopcanvas>`.
>
> ``` xojo
> Var a As New TextShape
> a.Text = "Hello World!"
> a.X = 100
> g.DrawObject(a)
> ```

<div id="textshape.y">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TextShape.Y

**Y** As `Double</api/data_types/double>`

> The vertical position of the center or main anchor point.

## Notes

The X,Y properties specify the center of the text baseline. Text that contain line breaks are not supported. TextShapes can be rotated, but doing so is memory intensive, especially for large strings.

Although they will appear in auto-complete and compile, the Border, BorderColor and BorderWidth properties do not do anything with StringShape.

Use the `FillColor<object2d.fillcolor>` property to change the color of the text.

## Sample code

This example draws text rotated 90 degrees. Put it in the Paint event handler of a Canvas:

``` xojo
Var t As New TextShape
t.Text = "Hello World"
t.FontName = "Helvetica"
t.Bold = True
t.Rotation = 3.14159 / 2 ' (radians, 90 degrees = pi/2)
t.Y = 100
g.DrawObject(t)
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This example aligns the <span class="title-ref">TextShape</span> to the left.

``` xojo
Var t As New TextShape
t.X = 20
t.Y = 20
t.Text = "Hello World"
t.HorizontalAlignment = TextShape.Alignment.Left
g.DrawObject(t)
```

## Compatibility

|                       |                       |
|-----------------------|-----------------------|
| **Project Types**     | Console, Desktop, Web |
| **Operating Systems** | All                   |

<div class="seealso">

`Object2D</api/graphics/object2d>` parent class; `ArcShape</api/graphics/arcshape>`, `CurveShape</api/graphics/curveshape>`, `FigureShape</api/graphics/figureshape>`, `FolderItem</api/files/folderitem>`, `Group2D</api/graphics/group2d>`, `Graphics</api/graphics/graphics>`, `OvalShape</api/graphics/ovalshape>`, `Picture</api/graphics/picture>`, `PixmapShape</api/graphics/pixmapshape>`, `RectShape</api/graphics/rectshape>`, `RoundRectShape</api/graphics/roundrectshape>` classes.

</div>
