Assign Fonts
From AutoCAD ActiveX
Fonts define the shapes of the text characters that make up each character set. A single font can be used by more than one style. To assign a font to a text style, use the FontFile property of the TextStyle object. By entering the font file containing an AutoCAD-compiled SHX font, you assign that font to the text style.
This example gets the current font values for the active text style and then changes the typeface for the font to “PlayBill.” The new font is then set using the SetFont method. To see the effects of changing the typeface, add some Mtext or Text to your current drawing before running the example. Note that, if you don't have the PlayBill font on your system, you need to substitute a font you do have in order for this example to work.
Sub Ch4_UpdateTextFont()
MsgBox ("Look at the text now...")Dim typeFace As StringDim SavetypeFace As StringDim Bold As BooleanDim Italic As BooleanDim charSet As LongDim PitchandFamily As Long' Get the current settings to fill in the' default values for the SetFont methodThisDrawing.ActiveTextStyle.GetFont typeFace, _Bold, Italic, charSet, PitchandFamily' Change the typeface for the fontSavetypeFace = typeFacetypeFace = "PlayBill"ThisDrawing.ActiveTextStyle.SetFont typeFace, _Bold, Italic, charSet, PitchandFamilyThisDrawing.Regen acActiveViewportMsgBox ("Now see how it looks after changing the font...")'Restore the original typefaceThisDrawing.ActiveTextStyle.SetFont SavetypeFace, _Bold, Italic, charSet, PitchandFamilyThisDrawing.Regen acActiveViewportEnd Sub