用Delphi中的TFont不能实现字体的任意角度偏转,要用到API中的LOGFONT结构。
typedef struct tagLOGFONT { // lf
LONG lfHeight;
LONG lfWidth;
LONG lfEscapement;
LONG lfOrientation;
LONG lfWeight;
BYTE lfItalic;
BYTE lfUnderline;
BYTE lfStrikeOut;
BYTE lfCharSet;
BYTE lfOutPrecision;
BYTE lfClipPrecision;
BYTE lfQuality;
BYTE lfPitchAndFamily;
TCHAR lfFaceName[LF_FACESIZE];
} LOGFONT;
其中
LONG lfEscapement;
是指定字体角度的参数。比如
lfEscapement = 300
在Delphi中声明用TLogFont。
procedure Form1.WildTextOut(Buf : String);
var
LF : TLOGFONT;
HFONT : THandle;
begin
with LF do begin
...
lfEscapement = 900;
...
end;
HFONT := CreateFontInDirect(LF);
hOldFont = SelectObject(Canvas.Handle,HFONT);
TextOut(Canvas.Handle,Buf);
SelectObject(Canvas.Handle,hOldFont);
end;