[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Graphics' (#lcl)

# TCanvas.TextRect

Draws text on the canvas at the specified location using the given style.

## Declaration

Source position: graphics.pp line 1159

`public procedure TCanvas.TextRect(`
`const ARect: TRect;`
`X: Integer;`
`Y: Integer;`
`const Text: string`
`); procedure TCanvas.TextRect(`
`ARect: TRect;`
`X: Integer;`
`Y: Integer;`
`const Text: string;`
`const Style: TTextStyle`
`); virtual;`

## Arguments

`ARect` |  | Rectangle within which the specified text is drawn.
`X` |  | Horizontal text start (respected only if TextStyle.Alignment = taLeftJustify).
`Y` |  | Vertical position of the top of the text (respected only if TextStyle.Layout = tlTop).
`Text` |  | Text to be drawn.

## Arguments

`ARect` |  | Rectangle within which the specified text is drawn.
`X` |  | Horizontal text start (respected only if TextStyle.Alignment = taLeftJustify).
`Y` |  | Vertical position of the top of the text (respected only if TextStyle.Layout = tlTop).
`Text` |  | Text to be drawn.
`Style` |  | Optional parameter which determines whether the text is justified, word-wrapped, clipped, etc. If omitted, the current TextStyle for the canvas is used.

## Description

Writes Text string within a specified rectangle, according to predefined Style.

The boundaries of the text rectangle are specified in ARect. X, Y define the starting point for writing the Text within the rectangle.

TextStyle determines whether the text is justified, centered, word-wrapped, clipped at the rectangle boundaries, etc. If the Style argument is omitted, defaults are assumed.

Note: The exact text position depends on the specified rectangle, the X, Y coordinates, and settings in TextStyle:

- TextStyle.Alignment = taLeftJustify: Text begins at X
- TextStyle.Alignment = taCenter: Text center is in the center of the rectangle (horizontally)
- TextStyle.Alignment = taRightJustify: Text ends at right edge of the rectangle
- TextStyle.Layout = tlTop: Top of the text is at Y
- TextStyle.Layout = tlCenter: Text center is in the center of the rectangle (vertically)
- TextStyle.Layout = tlBottom: Text sits above the bottom edge of the rectangle