1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
procedure TForm1.TestImprimeTexte(cv : TCanvas; chaine: string; x, y: integer);
var
rectf : TGPRectF;
graphics : TGPGraphics;
solidBrush : TGPSolidBrush;
fontFamily: TGPFontFamily;
gpfont: TGPFont;
origine : TpointD;
stringFormat : TGPstringFormat;
gpFontStyle : TFontStyle;
gpUnit : TUnit;
cvTest : TCanvas;
begin
cvTest := cv;
cv.font.color := clRed;
cv.font.size := 12;
cv.brush.style := bsClear;
origine := PointD(0,0);
graphics := TGPGraphics.Create(cv.Handle);
solidBrush:= TGPSolidBrush.Create(ColorToARGB(cv.font.color));
fontFamily:= TGPFontFamily.Create('Arial');
//Style de la font
gpFontStyle := FontStyleRegular;
gpUnit := UnitPixel;
gpfont:= TGPFont.Create(fontFamily, cv.font.size, gpFontStyle , gpUnit);
stringFormat := TGPstringFormat.create;
rectf.x := x;
rectf.y := y;
graphics.DrawString(chaine, -1, gpFont, MakePoint(rectf.X, rectf.y), stringFormat, solidBrush);
cv.textOut(Round(rectf.X), Round(rectf.Y), chaine);
graphics.Free;
solidBrush.Free;
fontFamily.Free;
gpfont.Free;
end; |
Partager