To display some text on a canvas at a certain rotation, call the CanvasTextOutAngle() procedure. Example: CanvasTextOutAngle(Form1.Canvas, 50, 50, 315, 'This is a test.');
Note: this will only work for true type fonts.
procedure CanvasTextOutAngle(C: TCanvas; X, Y: integer; Angle: word; S: string);
{ Output text at any angle on a canvas. This will }
{ only work with TrueType fonts. }
{ Code adapted from ZieglerSoft [http://www.zieglersoft.dk/uk.html] }
var
LogRec: TLOGFONT;
OldFontHandle,
NewFontHandle: HFONT;
begin
GetObject(C.Font.Handle, SizeOf(LogRec), Addr(LogRec));
LogRec.lfEscapement := Angle*10; {10th of a degree}
LogRec.lfOrientation := Angle*10;
NewFontHandle := CreateFontIndirect(LogRec);
OldFontHandle := SelectObject(C.Handle, NewFontHandle);
C.Brush.Style := bsClear;
C.TextOut(X, Y, S);
NewFontHandle := SelectObject(C.Handle, OldFontHandle);
DeleteObject(NewFontHandle);
end;
Blue Orb Software
[email protected]