CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2023 开发者帮助

FontFile 属性 (ActiveX)

2024-5-18 18:57| 发布者: admin| 查看: 170| 评论: 0|原作者: admin|来自: AutoCAD

FontFile 属性 (ActiveX)

指定主字体文件名,该文件名包含组成字符集的文本字符形状的定义。

支持的平台:仅限 Windows

签名

VBA:

object.FontFile
对象

类型:TextStyle

此属性应用于的对象。

属性值

只读:

类型:字符串

主字体文件路径。

言论

若要指定亚洲语言字体文件,请使用该属性。BigFontFile

在某些情况下,更改分配给文本样式的字体文件后,字体名称可能无法正确更新。最常见的情况是在打开图形文件期间发生字体替换之后。建议使用对象的属性和方法同时更改字体文件和字体名称(字体)。有关使用字体的详细信息,请参阅《ActiveX 开发人员指南》中的关于分配字体FontFileSetFontTextStyle

注意:设置此属性后,必须调用该方法以查看对文本的更改。Regen

例子

VBA:

Sub Example_FontFile()
    ' This example returns the current setting of
    ' the FontFile property. It then changes the value, and
    ' finally resets the value back to the original setting.
    
    Dim textStyle1 As AcadTextStyle
    Dim currFontFile As String
    Dim newFontFile As String
    
    Set textStyle1 = ThisDrawing.ActiveTextStyle
    
    ' Retrieve the current FontFile value
    currFontFile = textStyle1.fontFile
    MsgBox "The current value for FontFile is " & currFontFile, vbInformation, "FontFile Example"
    
    ' Change the value for FontFile
    newFontFile = "C:/AutoCAD/Fonts/italic.shx"
    textStyle1.fontFile = newFontFile
    MsgBox "The new value for FontFile is " & textStyle1.fontFile, vbInformation, "FontFile Example"
        
    ' Reset font file
    textStyle1.fontFile = currFontFile
    MsgBox "The value for FontFile has been reset to " & textStyle1.fontFile, vbInformation, "FontFile Example"
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_FontFile()
    ;; This example returns the current setting of
    ;; the FontFile property. It then changes the value, and
    ;; finally resets the value back to the original setting.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    (setq textStyle1 (vla-get-ActiveTextStyle doc))
    
    ;; Retrieve the current FontFile value
    (setq currFontFile (vla-get-FontFile textStyle1))
    (alert (strcat "The current value for FontFile is " currFontFile))
    
    ;; Change the value for FontFile
    (setq newFontFile (findfile "./Fonts/italic.shx"))
    (vla-put-FontFile textStyle1 newFontFile)
    (alert (strcat "The new value for FontFile is " (vla-get-FontFile textStyle1)))
        
    ;; Reset font file
    (if (= (findfile currFontFile) nil)
	(setq currFontFile (findfile (strcat (getenv "WinDir") "\\Fonts\\" currFontFile)))
    )
  
    (vla-put-FontFile textStyle1 (findfile currFontFile))
    (alert (strcat "The value for FontFile has been reset to " (vla-get-FontFile textStyle1)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2025-3-14 05:56

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部