Declaration
property Font: TFont;
Description
The font used by
DrawText and
MeasureText.
Note:
◼To draw the text with transparency, set
FontTransparency
◼For more advanced styling, set
TextStyling
Examples
// Draw a semi-transparent text box onto a bitmap
const
Horz_Margin = 8;
Vert_Margin = 3;
Center_Text = False;
var
x, y: Integer;
tw, rw, rh: Integer;
iec: TIECanvas;
ss: string;
begin
ss := 'This is my text';
x := 100;
y := 100;
iec := TIECanvas.Create( Bitmap.Canvas );
iec.Font.Size := 30;
iec.Font.Style := [fsBold];
tw := iec.TextWidth( ss );
rw := imax( tw + 2 * Horz_Margin, iec.TextWidth( ss ) + 2 * Horz_Margin );
rh := iec.TextHeight( ss ) + 2 * Vert_Margin;
if Center_Text then
Dec( x, rw div 2 );
iec.Brush.Color := clYellow;
iec.Brush.Style := bsSolid;
iec.Brush.Transparency := 196;
iec.Pen.Color := clBlack;
iec.Pen.Style := psSolid;
iec.Rectangle( x, y, x + rw, y + rh );
iec.Brush.Style := bsClear;
iec.DrawText( ss, x + ( rw - tw ) div 2, y + Vert_Margin );
iec.Free();
end;