AutoCAD supports the Unicode character-encoding standard. A Unicode font can contain 65,535 characters, with shapes for many languages. All of the AutoCAD SHX shape fonts that are shipped with the product support Unicode fonts.
The text files for some alphabets contain thousands of non-ASCII characters. To accommodate such text, AutoCAD supports a special type of shape definition known as a Big Font file. You can set a style to use both regular and Big Font files. Specify normal fonts using the FileName property. Specify Big Fonts using the BigFontFileName property.
AutoCAD allows you to specify an alternate font to use when a specified font file cannot be located. Use the FONTALT system variable and the SetSystemVariable member method of the Application to change the alternate font used.
The following example code changes the FileName and BigFontFileName properties. You need to replace the path information listed in this example with path and file names appropriate for your system.
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
<CommandMethod("ChangeFontFiles")> _
Public Sub ChangeFontFiles()
'' Get the current document and database
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
'' Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
'' Open the current text style for write
Dim acTextStyleTblRec As TextStyleTableRecord
acTextStyleTblRec = acTrans.GetObject(acCurDb.Textstyle, _
OpenMode.ForWrite)
'' Change the font files used for both Big and Regular fonts
acTextStyleTblRec.BigFontFileName = "C:\AutoCAD\Fonts\bigfont.shx"
acTextStyleTblRec.FileName = "C:\AutoCAD\Fonts\italic.shx"
'' Save the changes and dispose of the transaction
acTrans.Commit()
End Using
End Sub
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
[CommandMethod("ChangeFontFiles")]
public static void ChangeFontFiles()
{
// Get the current document and database
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
// Start a transaction
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// Open the current text style for write
TextStyleTableRecord acTextStyleTblRec;
acTextStyleTblRec = acTrans.GetObject(acCurDb.Textstyle,
OpenMode.ForWrite) as TextStyleTableRecord;
// Change the font files used for both Big and Regular fonts
acTextStyleTblRec.BigFontFileName = "C:/AutoCAD/Fonts/bigfont.shx";
acTextStyleTblRec.FileName = "C:/AutoCAD/Fonts/italic.shx";
// Save the changes and dispose of the transaction
acTrans.Commit();
}
}