CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

使用 Unicode 和大字体 (.NET)

2023-1-1 12:17| 发布者: admin| 查看: 313| 评论: 0|来自: AutoCAD

AutoCAD 支持 Unicode 字符编码标准。Unicode 字体可以包含 65,535 个字符,具有多种语言的形状。产品附带的所有 AutoCAD SHX 形状字体都支持 Unicode 字体。

某些字母表的文本文件包含数千个非 ASCII 字符。为了容纳此类文本,AutoCAD 支持一种称为大字体文件的特殊类型的形状定义。您可以将样式设置为同时使用常规字体文件和大字体文件。使用属性指定普通字体。使用属性指定大字体。FileNameBigFontFileName

注意:字体文件名不能包含逗号。

AutoCAD 允许您指定在找不到指定字体文件时要使用的备用字体。使用应用程序的 FONTALT 系统变量和成员方法更改使用的备用字体。SetSystemVariable

更改字体文件

下面的示例代码更改和属性。您需要将此示例中列出的路径信息替换为适合您的系统的路径和文件名。FileNameBigFontFileName

VB.NET

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

C#

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();
    }
}

VBA/ActiveX 代码参考

Sub ChangeFontFiles()
    ThisDrawing.ActiveTextStyle.BigFontFile = _
                  "C:/AutoCAD/Fonts/bigfont.shx"
 
    ThisDrawing.ActiveTextStyle.fontFile = _
                  "C:/AutoCAD/Fonts/italic.shx"
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 13:54

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部