欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > windows >内容正文

windows

Delphi利用Windows GDI实现文字倾斜

发布时间:2025/3/8 windows 22 豆豆
生活随笔 收集整理的这篇文章主要介绍了 Delphi利用Windows GDI实现文字倾斜 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

2019独角兽企业重金招聘Python工程师标准>>>

procedure TForm1.FormPaint(Sender: TObject);
var
  FLogFont: tagLogFontW;
  hTempFont, hPrevFont: HFONT; //字体句柄
  hTempDC: HDC; //设备描述表或图形设备句柄
  TempString: string; //输出的文字
begin
  FLogFont.lfHeight := 10; //字高
  FLogFont.lfWidth := 10; //字宽
  FLogFont.lfWeight := 1;  //字体笔划粗细程度
  FLogFont.lfUnderline := 0; //没有下划线
  FLogFont.lfStrikeOut := 0; //没有删除线
  FLogFont.lfItalic := 0; //斜体效果否
  FLogFont.lfCharSet := GB2312_CHARSET; //字符集
  FLogfont.lfEscapement := 450; //倾斜度
  // FLogFont.lfOrientation := 450;  //方向与倾斜度取值同
  FLogFont.lfFaceName := '宋体';//字体名称
  //创建逻辑字体
  hTempFont := CreateFontIndirect(FLogFont);
  TempString := '测试';

  hTempDC := GetDC(Handle); //取出窗口设备的当前字体,并替换为新字体
  hPrevFont := SelectObject(hTempDC, hTempFont);//设置设备窗口的文字色彩
  SetTextColor(hTempDc, clRed);
  TextOut(hTempDc, 200 , 200, PChar(TempString), Length(TempString));
  SelectObject(hTempDc, hPrevFont);
  DeleteObject(hTempFont);
  ReleaseDC(Handle, hTempDC);
end;

转载于:https://my.oschina.net/u/582827/blog/232720

总结

以上是生活随笔为你收集整理的Delphi利用Windows GDI实现文字倾斜的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。