设置文本样式字体的定义数据。 支持的平台:仅窗口 签名工 务 局: object.SetFont Typeface, Bold, Italic, CharSet, PitchAndFamily
返回值(RetVal)无返回值。 言论以下部分提供了用于此方法的常量的定义。若要使用这些常量,请复制所需的定义并将其粘贴到应用程序的“声明”部分中。Microsoft 提供的常量的完整列表可以在win32api.txt 文件中找到,该文件随 Visual Basic 开发环境一起提供。 字符集参数指定字体的字符集。若要在 VB 或 VBA 应用程序中使用以下常量,请将定义复制到代码的“声明”部分。 Public Const ANSI_CHARSET = 0 Public Const DEFAULT_CHARSET = 1 Public Const SYMBOL_CHARSET = 2 Public Const SHIFTJIS_CHARSET = 128 Public Const OEM_CHARSET = 255 参数指定字体的间距和族值。该值由三种不同设置的组合确定。若要提供PitchAndFamily值,请从每个类别中选择一个设置,然后使用 OR 运算符将它们组合在一起。前两个类别中需要设置;球场和家庭。第三个类别是 TrueType 标志,仅在指定 TrueType 字体时使用。 To use the following constants in your VB or VBA application, copy the definitions into the Declaration section of your code. ' Pitch Values Public Const DEFAULT_PITCH = 0 Public Const FIXED_PITCH = 1 Public Const VARIABLE_PITCH = 2 ' Family Values Public Const FF_DONTCARE = 0 ' Don't care or don't know. Public Const FF_ROMAN = 16 ' Variable stroke width, serifed. Public Const FF_SWISS = 32 ' Variable stroke width, sans-serifed. Public Const FF_MODERN = 48 ' Constant stroke width, serifed or sans-serifed. Public Const FF_SCRIPT = 64 ' Cursive, etc. Public Const FF_DECORATIVE = 80 ' Old English, etc. ' TrueType Flag Public Const TMPF_TRUETYPE = &H4 ExamplesVBA: Sub Example_SetFont() ' This example finds the font information for the active text style. ' It then changes the font to bold. Dim typeFace As String Dim Bold As Boolean Dim Italic As Boolean Dim charSet As Long Dim PitchandFamily As Long ThisDrawing.ActiveTextStyle.GetFont typeFace, Bold, Italic, charSet, PitchandFamily MsgBox "The current text style has the following font properties:" & vbCrLf _ & "Typeface: " & typeFace & vbCrLf _ & "Bold: " & Bold & vbCrLf _ & "Italic: " & Italic & vbCrLf _ & "Character set: " & charSet & vbCrLf _ & "Pitch and Family: " & PitchandFamily ' Change the bold property Bold = Not Bold ThisDrawing.ActiveTextStyle.SetFont typeFace, Bold, Italic, charSet, PitchandFamily MsgBox "The current text style has the following font properties:" & vbCrLf _ & "Typeface: " & typeFace & vbCrLf _ & "Bold: " & Bold & vbCrLf _ & "Italic: " & Italic & vbCrLf _ & "Character set: " & charSet & vbCrLf _ & "Pitch and Family: " & PitchandFamily ' Reset the font Bold = Not Bold ThisDrawing.ActiveTextStyle.SetFont typeFace, Bold, Italic, charSet, PitchandFamily End Sub Visual LISP: (vl-load-com) (defun c:Example_SetFont() ;; This example finds the font information for the active text style. ;; It then changes the font to bold. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (vla-GetFont (vla-get-ActiveTextStyle doc) 'typeFace 'Bold 'Italic 'charSet 'PitchandFamily) (alert (strcat "The current text style has the following font properties:" "\nTypeface: " typeFace "\nBold: " (if (= Bold :vlax-true) "True" "False") "\nItalic: " (if (= Italic :vlax-true) "True" "False") "\nCharacter set: " (itoa charSet) "\nPitch and Family: " (itoa PitchandFamily))) ;; Change the bold property (setq Bold (if (= Bold :vlax-true) :vlax-false :vlax-true)) (vla-SetFont (vla-get-ActiveTextStyle doc) typeFace Bold Italic charSet PitchandFamily) (alert (strcat "The current text style has the following font properties:" "\nTypeface: " typeFace "\nBold: " (if (= Bold :vlax-true) "True" "False") "\nItalic: " (if (= Italic :vlax-true) "True" "False") "\nCharacter set: " (itoa charSet) "\nPitch and Family: " (itoa PitchandFamily))) ;; Reset the font (setq Bold (if (= Bold :vlax-true) :vlax-false :vlax-true)) (vla-SetFont (vla-get-ActiveTextStyle doc) typeFace Bold Italic charSet PitchandFamily) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:14
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.