Sets the definition data of the font for the TextStyle.
Supported platforms: Windows only
VBA:
object.SetFont Typeface, Bold, Italic, CharSet, PitchAndFamily
Type: TextStyle
The object this method applies to.
Access: Input-only
Type: String
The typeface (font name).
Access: Input-only
Type: Boolean
Sets the TextStyle to bold.
Access: Input-only
Type: Boolean
Sets the TextStyle to italic.
Access: Input-only
Type: Long
The character set for the font. (See the available values in the Remarks section.)
Access: Input-only
Type: Long
The pitch and family definitions for the font. (See the available values in the Remarks section.)
No return value.
The following section provides definitions for constants to use with this method. To use these constants, copy the definitions you need and paste them into the Declarations section of your application. A complete list of the constants that are available from Microsoft can be found in the file win32api.txt, which is provided with the Visual Basic Development Environment.
The CharSet parameter specifies the character set for the font. To use the following constants in your VB or VBA application, copy the definitions into the Declaration section of your code.
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
The PitchAndFamily parameter specifies the pitch and family values for the font. The value is determined by a combination of three different settings. To provide the PitchAndFamily value, choose a setting from each of the categories, and then use the OR operator to combine them. A setting is required from the first two categories; the pitch and the family. The third category, the TrueType Flag, is only used when you are specifying a TrueType font.
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
VBA:
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) )