fqj 发表于 2002-7-30 16:35:00

[求助]如何在AcDbTextStyleTable中添加一个TrueType字体?

wxj351 发表于 2002-7-30 20:42:00

TrueType字体,以.TTF为扩展名的,这种字体表示真实类型( TrueType)字体,该字
体拥有较高的字体质量。另外,使用各种真实类型字体可以给图增加更好的对比效果。
TrueType字体的方法1:(用Mtext不显示仿宋体)
(1)      建立一个新的字体样式表记录
(2)      使用SetFont()函数,设置TrueType字体。
(3)      使用add()函数添加到字体样式表中。
TrueType字体的方法2:
(1)      建立一个新的字体样式表记录
(2)      使用setFileName()函数和setBigFontFileName()函数,设置字母和TrueType字体。
(3)      使用add()函数添加到字体样式表中。

fqj 发表于 2002-7-30 21:09:00

Acad::ErrorStatus SetFont()
{
      Acad::ErrorStatus Er;      
      AcDbTextStyleTable * pTxt;
      Er=acdbCurDwg()->getTextStyleTable(pTxt,AcDb::kForWrite);
      if (Er!=Acad::eOk)
      {
                ads_alert("Error Get TextStyleTable");
                return Er;
      };
      AcDbTextStyleTableRecord* pRecord=new AcDbTextStyleTableRecord;
      pRecord->setFont("simfang.ttf",FALSE,FALSE,0,0);
         pRecord->setName("fqj");
      Er=pTxt->add(pRecord);
      pTxt->close();
      return Er;
}

wxj351 发表于 2002-7-31 17:28:00

SetFont()函数,用于将TrueType字型设置为字体样式。
Acad::ErrorStatus setFont(
   const char* pTypeface,
   Adesk::Boolean bold,
   Adesk::Boolean italic,
   int charset,
   int pitchAndFamily) const;
pTypeface      字体名
bold      true为粗体
italic      true为斜体
charset      字符集的值
pitchAndFamily      字距和字符族的值
TrueType常用字体
TrueType字体名      charset      pitchAndFamily
仿宋_GB2312          134      49
宋体                  134      2
黑体                  134      2
隶书               134      49
幼园                  134      49
楷体_GB2312      134      49

fqj 发表于 2002-8-1 10:26:00

Acad::ErrorStatus SetFont()
{
      Acad::ErrorStatus Er;      
      AcDbTextStyleTable * pTxt;
      Er=acdbCurDwg()->getTextStyleTable(pTxt,AcDb::kForWrite);
      if (Er!=Acad::eOk)
      {
                ads_alert("Error Get TextStyleTable");
                return Er;
      };
      AcDbTextStyleTableRecord* pRecord=new AcDbTextStyleTableRecord;
      pRecord->setFont("仿宋_GB2312",FALSE,FALSE,134,49);
      pRecord->setName("fqj");
      Er=pTxt->add(pRecord);
      pTxt->close();
      return Er;
}

wxj351 发表于 2002-8-2 18:02:00

AcDbTextStyleTable *pTextStyleTable;
   acdbHostApplicationServices()->workingDatabase()
      ->getSymbolTable(pTextStyleTable, AcDb::kForWrite);
    AcDbTextStyleTableRecord *pTextStyleTableRecord =
      new AcDbTextStyleTableRecord;
    pTextStyleTableRecord->setName("机械制图1");
//      pTextStyleTableRecord->setFont("宋体",0,0,134,2);
    pTextStyleTableRecord->setFont("仿宋_GB2312",FALSE,FALSE,134,49);
    pTextStyleTableRecord->setXScale(0.67);
      AcDbObjectId Id;
      pTextStyleTable->add(Id,pTextStyleTableRecord);
    pTextStyleTable->close();
    pTextStyleTableRecord->close();
      return Id;

fqj 发表于 2002-8-3 11:26:00

[此贴子已经被作者于2002-8-3 11:26:16编辑过]
页: [1]
查看完整版本: [求助]如何在AcDbTextStyleTable中添加一个TrueType字体?