CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

关于指定字体 (VBA/ActiveX)

2023-1-5 00:35| 发布者: admin| 查看: 586| 评论: 0|来自: AutoCAD

摘要: 字体定义构成每个字符集的文本字符的形状。

字体定义构成每个字符集的文本字符的形状。

一种字体可以由多种样式使用。若要为文本样式指定字体,请使用对象的属性。通过输入包含 AutoCAD 编译的 SHX 字体的字体文件,可以将该字体指定给文本样式。FontFileTextStyle

设置文本字体

本示例获取活动文本样式的当前字体值,然后将字体的字样更改为“PlayBill”。然后使用该方法设置新字体。若要查看更改字体的效果,请在运行示例之前向当前绘图添加一些内容。请注意,如果您的系统上没有 PlayBill 字体,则需要替换您拥有的字体才能使此示例正常工作。SetFontMTextText

Sub Ch4_UpdateTextFont()

  MsgBox ("Look at the text now...")

  Dim typeFace As String
  Dim SavetypeFace As String
  Dim Bold As Boolean
  Dim Italic As Boolean
  Dim charSet As Long
  Dim PitchandFamily As Long

  ' Get the current settings to fill in the
  ' default values for the SetFont method
  ThisDrawing.ActiveTextStyle.GetFont typeFace, Bold, Italic, charSet, PitchandFamily

  ' Change the typeface for the font
  SavetypeFace = typeFace
  typeFace = "PlayBill"
  ThisDrawing.ActiveTextStyle.SetFont typeFace, Bold, Italic, charSet, PitchandFamily
  ThisDrawing.Regen acActiveViewport
  MsgBox ("Now see how it looks after changing the font...")

  'Restore the original typeface
  ThisDrawing.ActiveTextStyle.SetFont SavetypeFace, Bold, Italic, charSet, PitchandFamily
  ThisDrawing.Regen acActiveViewport
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-11 21:20

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部