IGxGraphics.MeasureTextRF

Syntax

MeasureTextRF(Text: String; Font: IGxFont; Rect: IGxRectF; Format: IGxStringFormat): IGxRectF;

Parameters

Text. Text.

Font. Text font.

Rect. Rectangle that sets maximum layout area for the text. If the rectangle with the null sizes is set, it calculates the area that the specified text occupies in accordance with the specified parameters.

Format. Text format.

Description

The MeasureTextRF method calculates the size of the text with the specified format.

Fore Example

Executing the example requires a form with the button named Button1 and the ImageBox component named ImageBox1. Add links to the Drawing, Forms system assemblies.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);

Var

BMP: IGxBitmap;

Graph: IGxGraphics;

GraphClass: GxGraphicsClass;

Font: IGxFont;

Brush: IGxBrush;

Format: IGxStringFormat;

r: IGxRectF;

Begin

BMP := GxBitmap.CreateNew(ImageBox1.ClientWidth, ImageBox1.ClientHeight, GxPixelFormat.Unknown);

Font := New GxFont.Create("Times New Roman", 16, GxFontStyle.BoldItalic, GxUnit.World);

Brush := New GxSolidBrush.Create(GxColor.FromName("Red"));

Format := New GxStringFormat.Create;

Format.Alignment := GxStringAlignment.Center;

Format.LineAlignment := GxStringAlignment.Center;

Format.Trimming := GxStringTrimming.None;

GraphClass := New GxGraphics.Create;

Graph := GraphClass.FromImage(BMP);

r := New GxRectF.Create(0, 0, 0, 0);

r := Graph.MeasureTextRF("PROGNOZ", Font, r, Null);

r.Width := r.Width / 2;

Graph.DrawTextRF("PROGNOZ", Font, Brush, r, Format);

ImageBox1.Image := BMP;

End Sub Button1OnClick;

After executing the example clicking the button in the ImageBox component displays the new bitmap with rectangle truncated by width where the "PROGNOZ" label with corresponding defined settings is rendered in the middle.

See also:

IGxGraphics