TextFont Property (ActiveX)

Specifies the font for new text.

Supported platforms: Windows only

Signature

VBA:

object.TextFont
object

Type: PreferencesDisplay

The object this property applies to.

Property Value

Read-only: No

Type: String

The name of the new font.

Remarks

The initial value for this property is Courier.

Examples

VBA:

Sub Example_TextFont()
    ' This example returns the current setting of
    ' TextFont. It then changes the value, and finally
    ' it resets the value back to the original setting.
    
    Dim preferences As AcadPreferences
    Dim currTextFont As String
    
    Set preferences = ThisDrawing.Application.Preferences
    
    ' Retrieve the current TextFont value
    currTextFont = preferences.Display.TextFont
    MsgBox "The current value for TextFont is " & preferences.Display.TextFont, vbInformation, "TextFont Example"
    
    ' Change the value for TextFont
    preferences.Display.TextFont = "TestTextFont"
    MsgBox "The new value for TextFont is " & preferences.Display.TextFont, vbInformation, "TextFont Example"
    
    ' Reset TextFont to its original value
    preferences.Display.TextFont = currTextFont
    MsgBox "The TextFont value is reset to " & preferences.Display.TextFont, vbInformation, "TextFont Example"
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_TextFont()
    ;; This example returns the current setting of
    ;; TextFont. It then changes the value, and finally
    ;; it resets the value back to the original setting.
    (setq acadObj (vlax-get-acad-object))
    (setq preferences (vla-get-Preferences acadObj))
    
    ;; Retrieve the current TextFont value
    (setq currTextFont (vla-get-TextFont (vla-get-Display preferences)))
    (alert (strcat "The current value for TextFont is " currTextFont))
    
    ;; Change the value for TextFont
    (vla-put-TextFont (vla-get-Display preferences) "TestTextFont")
    (alert (strcat "The new value for TextFont is " (vla-get-TextFont (vla-get-Display preferences))))
    
    ;; Reset TextFont to its original value
    (vla-put-TextFont (vla-get-Display preferences) currTextFont)
    (alert (strcat "The TextFont value is reset to " (vla-get-TextFont (vla-get-Display preferences))))
)