procedure AngleTextOut(CV: TCanvas;
const sText: String;
x, y, angle:integer);
var
LogFont: TLogFont;
SaveFont: TFont;
begin
SaveFont := TFont.Create;
SaveFont.Assign(CV.Font);
GetObject(SaveFont.Handle, sizeof(TLogFont), @LogFont);
with LogFontdo
begin
lfEscapement := angle *10;
lfPitchAndFamily := FIXED_PITCH or FF_DONTCARE;
end;
{with}
CV.Font.Handle := CreateFontIndirect(LogFont);
SetBkMode(CV.Handle, TRANSPARENT);
CV.TextOut(x, y, sText);
CV.Font.Assign(SaveFont);
SaveFont.Free;
end;
*********************************
procedure TForm1.Button1Click(Sender: TObject);
var
lf : TLogFont;
tf : TFont;
begin
with Form1.Canvasdo
begin
Font.Name := 'Arial';
Font.Size := 24;
tf := TFont.Create;
tf.Assign(Font);
GetObject(tf.Handle, sizeof(lf), @lf);
lf.lfEscapement := 450;
lf.lfOrientation := 450;
tf.Handle := CreateFontIndirect(lf);
Font.Assign(tf);
tf.Free;
TextOut(20, Height div 2, 'Rotated Text!');
end;
end;
==================================
procedure TForm1.FormMouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
var
LogFont : TLogFont;
newFont : TFont;
begin
with Form1.Canvasdo
begin
Font.Name := '黑体';
// 字体
Font.Size := 32;
// 字号
Font.Color:= $00ffcc;
// 颜色
// 创建新字体
newFont := TFont.Create;
newFont.Assign(Font);
// 新字体继承窗体字体的属性
// 为新字体设置旋转属性
GetObject(newFont.Handle, sizeof(LogFont), @LogFont);
LogFont.lfEscapement :=600;
//角度*10
LogFont.lfOrientation :=600;
//应设为同样的值
LogFont.lfWidth:=20;
//每个字符的大小
LogFont.lfHeight:=90;
newFont.Handle := CreateFontIndirect(LogFont);
Font.Assign(newFont);
newFont.Free;
// 在鼠标按下的位置显示文字
TextOut(X, Y, '旋转文字Demo');
end;
end;