如何绘制带有角度的字符串(50分)

W

whj

Unregistered / Unconfirmed
GUEST, unregistred user!
&nbsp; 在WINDOWS中对于字符串的输出都为水平方向,不知可否实现带有角度<br>(0~360)的字符串的效果
 
参见忆答问题:”求汉字旋转的控件“<br>http://www.gislab.ecnu.edu.cn/delphibbs/DispQ.asp?LID=98493
 
var<br>&nbsp; &nbsp; r:string; <br>&nbsp; &nbsp; LogFont:TLogFont;<br>&nbsp; &nbsp; NewFont,OldFont:THandle;<br>begin<br>&nbsp; &nbsp;SetBkMode(Canvas.Handle,Transparent);<br>&nbsp; &nbsp;LogFont.lfHeight :=20; <br>&nbsp; &nbsp;LogFont.lfWidth :=10;<br>&nbsp; &nbsp;LogFont.lfEscapement :=900; &nbsp; // 这一句是要旋转的角度*10<br>&nbsp; &nbsp;LogFont.lfWeight :=0;<br>&nbsp; &nbsp;LogFont.lfItalic :=0;<br>&nbsp; &nbsp;LogFont.lfUnderline :=0;<br>&nbsp; &nbsp;LogFont.lfStrikeOut :=0;<br>&nbsp; &nbsp;LogFont.lfCharSet :=DEFAULT_CHARSET;<br>&nbsp; &nbsp;r :='宋体'#0;<br>&nbsp; &nbsp;move(r[1],LogFont.lfFaceName[0],length(r)+1);<br>&nbsp; &nbsp;NewFont :=CreateFontIndirect(LogFont);<br>&nbsp; &nbsp;OldFont :=SelectObject(Canvas.Handle,NewFont);<br>&nbsp; &nbsp;Canvas.TextOut(100,100,'test');<br>&nbsp; &nbsp;SelectObject(Canvas.Handle,OldFont);<br>&nbsp; &nbsp;DeleteObject(NewFont);<br>end;<br>
 
来自Borland的答案<br>Answer:<br>Rotating fonts is a straight forward process, so long as the Windows<br>font mapper can supply a rotated font based on the font you request.<br>Note: Using a TrueType font virturally guarantees success.<br><br>Here is an example of creating a font that is rotated 45 degrees:<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; lf : TLogFont;<br>&nbsp; tf : TFont;<br>begin<br>&nbsp; with Form1.Canvas do begin<br>&nbsp; &nbsp; Font.Name := 'Arial';<br>&nbsp; &nbsp; Font.Size := 24;<br>&nbsp; &nbsp; tf := TFont.Create;<br>&nbsp; &nbsp; tf.Assign(Font);<br>&nbsp; &nbsp; GetObject(tf.Handle, sizeof(lf), @lf);<br>&nbsp; &nbsp; lf.lfEscapement := 450;<br>&nbsp; &nbsp; lf.lfOrientation := 450;<br>&nbsp; &nbsp; tf.Handle := CreateFontIndirect(lf);<br>&nbsp; &nbsp; Font.Assign(tf);<br>&nbsp; &nbsp; tf.Free;<br>&nbsp; &nbsp; TextOut(20, Height div 2, 'Rotated Text!');<br>&nbsp; end;<br>end;<br>
 
参考&lt;a href="DispQ.asp?LID=103305"&gt;关于矢量图的控件&lt;/a&gt;, 下载我最新的矢量绘图的示范控件 -- <br>HZHViewport控件的TextOut过程.<br>可以控制字符的角度, 并且有9个方位作为字符输出的控制点
 
HZH:怎么下不来?
 
多人接受答案了。
 

Similar threads

D
回复
0
查看
848
DelphiTeacher的专栏
D
D
回复
0
查看
646
DelphiTeacher的专栏
D
D
回复
0
查看
622
DelphiTeacher的专栏
D
顶部