# TextRendering class
{: .no_toc }

Aggregates everything needed to draw a piece of text inside a control: the font, the padding, the fill that supplies the text colour, an optional array of outlines, the alignment within the available area, and the overflow behaviour. Accessed as `<state>.TextRendering`, [**WaynesLabel.TextRendering**](/tB/Packages/CustomControls/WaynesLabel.md#textrendering), and [**CellRenderingOptions.TextRendering**](/tB/Packages/CustomControls/WaynesGrid/CellRenderingOptions.md#textrendering).

A newly-constructed **TextRendering** pre-sets its [**Fill**](#fill) to solid black so that text is immediately visible.

```tb check_build
With lblTitle.TextRendering
    .Font.Size = 18
    .Font.Weight = tbBold
    .Alignment = tbAlignMiddleCenter
    .Fill.ColorPoints.SetSolidColor vbWhite
End With
```

[**Fill**](#fill) can hold a gradient just as well as a solid colour, so glyphs themselves can be painted with a top-to-bottom or corner-to-corner colour transition. [**Outlines**](#outlines) is an array of [**Border**](/tB/Packages/CustomControls/Styles/Borders.md#border-class) elements stroked around the glyphs --- a single thin black outline gives a "stickered" look; layering several outlines with different [**StrokeSize**](/tB/Packages/CustomControls/Styles/Borders.md#strokesize) values produces a glow or drop-shadow:

```tb check_build project=cc-private
With btnGo.NormalState.TextRendering
    .Font.Size = 32
    .Font.Weight = tbBold
    .Alignment = tbAlignMiddleCenter
    .Fill.SetSimplePattern vbWhite, &HCCCCFF, _
            Pattern:=tbGradientNorthToSouth
    Dim outline(0 To 0) As CustomControlsPackage.Border
    Set outline(0) = New CustomControlsPackage.Border
    outline(0).StrokeSize = 2
    outline(0).Fill.ColorPoints.SetSolidColor vbBlack
    .Outlines = outline
End With
```

> [!IMPORTANT]
>
> [**Border**](/tB/Packages/CustomControls/Styles/Borders.md#border-class) is a **Private** component of the package, so naming it
> takes the **CustomControlsPackage** library symbol prefixed with an asterisk in *Project
> Settings* --- the control package, not the **CustomControls** DESIGNER library listed
> beside it --- plus the package qualifier used above. See [Exposing a library's private
> symbols](/Features/Packages/Library-Symbols.md#exposing-a-librarys-private-symbols)
> for the setting and where to find it. Unlike [**Borders**](/tB/Packages/CustomControls/Styles/Borders.md), which has
> [**SetSimpleBorder**](/tB/Packages/CustomControls/Styles/Borders.md#setsimpleborder), there is no package-side method that puts
> an outline in place instead, so this is the only way to add one from code.

Setting [**OverflowMode**](#overflowmode) to **tbShrinkToFit** scales the glyphs down rather than truncating with an ellipsis when the text is too long for the available width --- useful on fixed-width labels whose caption is set at runtime from data of unpredictable length.

The two samples above, the label given a dark **BackgroundFill** for its white text:

![A label reading Monthly report in large white bold letters on a dark blue fill, and a blue button whose large bold caption, Go, is drawn in a white-to-pink gradient with a black outline](/Reference/Built-In/CustomControls/Styles/Images/TextRendering.png){:width="521" height="215"}

* TOC
{:toc}

## Properties

### Alignment
{: .no_toc }

How the text is positioned horizontally and vertically within the available area (after [**Padding**](#padding) is applied). A member of [**TextAlignment**](/tB/Packages/CustomControls/Enumerations/TextAlignment.md). Default: **tbAlignMiddleCenter**.

### Fill
{: .no_toc }

The [**Fill**](/tB/Packages/CustomControls/Styles/Fill.md) that supplies the text colour or gradient. Pre-set to a solid black fill on construction.

### Font
{: .no_toc }

The [**FontStyle**](#fontstyle-class) sub-object that gives the font size, weight, italic / underline / strikeout flags.

### OverflowMode
{: .no_toc }

How text longer than the available width is truncated. A member of [**TextOverflowMode**](/tB/Packages/CustomControls/Enumerations/TextOverflowMode.md). Default: **tbAppendEllipsis**.

### Outlines
{: .no_toc }

An array of [**Border**](/tB/Packages/CustomControls/Styles/Borders.md#border-class) elements describing one or more outlines that are stroked around the rendered glyphs. Read-write; an uninitialised array means no outline. Assigning it needs a `Border()` array, which the project can only declare when the package is imported with an asterisk --- see the note above.

### Padding
{: .no_toc }

The [**Padding**](/tB/Packages/CustomControls/Styles/Padding.md) sub-object holding per-side padding inserted around the text inside its bounding rectangle. The [**Alignment**](#alignment) is applied to the padded region.

## Events

### OnChanged
{: .no_toc }

Raised when [**Alignment**](#alignment) or [**OverflowMode**](#overflowmode) is assigned, when [**Outlines**](#outlines) is replaced or any of its elements raises **OnChanged**, or when [**Font**](#font), [**Padding**](#padding), or [**Fill**](#fill) raise their own **OnChanged**.

## FontStyle class

The font metrics that control how [**TextRendering**](#) lays out text. Accessed as [**TextRendering.Font**](#font). A **FontStyle** has no font name: the face is the package's choice.

### Italic
{: .no_toc }

When **True**, glyphs are rendered with italic styling. **Boolean**. Default: **False**.

### Size
{: .no_toc }

The font size in typographic points. [**PointSize**](/tB/Packages/CustomControls/Enumerations/PointSize.md). Default: 12.

### Strikeout
{: .no_toc }

When **True**, a horizontal line is drawn through the middle of each glyph. **Boolean**. Default: **False**.

### Underline
{: .no_toc }

When **True**, an underline is drawn beneath each glyph. **Boolean**. Default: **False**.

### Weight
{: .no_toc }

The font weight on the OpenType `wght` scale. A member of [**FontWeight**](/tB/Packages/CustomControls/Enumerations/FontWeight.md). Default: **tbNormal**.

> [!NOTE] BETA 1045
> Only three weights are drawn: 100 to 500 alike, as regular text; 600 as semibold; and 700 to 900 alike, as bold. See [**FontWeight**](/tB/Packages/CustomControls/Enumerations/FontWeight.md).

### OnChanged
{: .no_toc }

Raised when any of the five font-style fields is assigned. The parent [**TextRendering**](#) listens for this event and re-raises its own.
