FontFile Property (ActiveX)

Specifies the primary font file name of which contains the definitions for the shapes of the text characters that make up a character set.

Supported platforms: Windows only

Signature

VBA:

object.FontFile
object

Type: TextStyle

The object this property applies to.

Property Value

Read-only: No

Type: String

The primary font file path.

Remarks

To specify an Asian-language font file, use the BigFontFile property.

In some instances, the name of the font might not update correctly after changing the font file assigned to a text style. The most common situation in which this might occur is after a font substitution happens during the opening of a drawing file. It is recommended to change both the font file and font name (typeface) together using the FontFile property and SetFont method of an TextStyle object. See the About Assigning Fonts in the ActiveX Developer's Guide for more information on working with fonts.

Note: Once this property has been set, you must call the Regen method to see the changes to the text.

Examples

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

Visual 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)))
)