AutoCAD は、Unicode 体系をサポートしています。Unicode フォントには、さまざまな言語の文字形状に対応する 65,535 文字が含まれています。製品に付属するすべての AutoCAD SHX シェイプ フォントが、Unicode フォントをサポートします。
漢字などのテキスト ファイルには、ASCII 以外の文字が多数含まれています。このような文字を収容するために、AutoCAD はビッグフォント ファイルという特殊なシェイプ定義を使用しています。文字スタイルでは、通常のフォント ファイルとビッグフォント ファイルを両方とも使用できます。FileName プロパティを使用して、通常のフォントを指定します。ビッグフォントは、BigFontFileName プロパティを使用して指定します。
AutoCAD では、指定したフォント ファイルが見つからない場合に使用する代替フォントを指定できます。使用する代替フォントを変更するには、システム変数 FONTALT と Application の SetSystemVariable メンバー メソッドを使用します。
次のコード例では、FileName プロパティと BigFontFileName プロパティを変更しています。この例に示しているパス情報を、各自のシステムに応じたパスおよびファイル名に置き換える必要があります。
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();
}
}
Sub ChangeFontFiles()
ThisDrawing.ActiveTextStyle.BigFontFile = _
"C:/AutoCAD/Fonts/bigfont.shx"
ThisDrawing.ActiveTextStyle.fontFile = _
"C:/AutoCAD/Fonts/italic.shx"
End Sub