procedure
TForm1
.
FormPaint(Sender: TObject);
var
LF: TLogFont;
fnt: HFont;
innerContainer: GraphicsContainer;
graphics : TGPGraphics;
brush: TGPSolidBrush;
FontFamily: TGPFontFamily;
Font: TGPFont;
PN: TGPPen;
begin
graphics := TGPGraphics
.
Create(self
.
Canvas
.
Handle);
brush:= TGPSolidBrush
.
Create(MakeColor(
255
,
0
,
0
,
255
));
FontFamily := TGPFontFamily
.
Create(
'Times New Roman'
);
Font := TGPFont
.
Create(fontFamily,
36
, FontStyleRegular, UnitPixel);
PN := TGPPen
.
Create(MakeColor(
255
,
0
,
0
,
0
));
graphics
.
SetTextRenderingHint(TextRenderingHintAntiAlias);
graphics
.
SetSmoothingMode(SmoothingModeAntiAlias);
graphics
.
DrawString(
'Текст GDI+'
,
15
, font, MakePoint(
20.0
,
10.0
), brush);
PN
.
SetWidth(
5
);
graphics
.
DrawLine(PN,
20
,
10
,
300
,
100
);
innerContainer := graphics
.
BeginContainer();
LF
.
lfHeight :=
50
;
LF
.
lfUnderline :=
1
;
LF
.
lfEscapement :=
300
;
StrPCopy(LF
.
lfFaceName,
'Arial Bold'
);
Fnt := CreateFontIndirect(LF);
Canvas
.
Font
.
Handle := Fnt;
Canvas
.
TextOut(
0
,
300
,
'Текст GDI'
);
Canvas
.
Pen
.
Width :=
5
;
Canvas
.
LineTo(
25
,
205
);
DeleteObject(Fnt);
graphics
.
EndContainer(innerContainer);
PN
.
Free;
Font
.
Free;
brush
.
Free;
FontFamily
.
Free;
graphics
.
Free;
end
;