示例#1
0
AcDbObjectId CreateTextStyle(const CString& style, const CString& winFont, Adesk::Boolean bold, Adesk::Boolean italic, int charset, int pitchAndFamily)
{
	/*
	//pTextStyleTblRcd->setFileName(_T("simfang.ttf"));
	//pTextStyleTblRcd->setBigFontFileName("hzdx");
	pTextStyleTblRcd->setXScale(0.8);
	//pTextStyleTblRcd->setFont("_T(楷体_GB2312"),Adesk::kFalse,Adesk::kFalse,GB2312_CHARSET,49);
	//pTextStyleTblRcd->setFont(_T("宋体"),Adesk::kFalse,Adesk::kFalse,GB2312_CHARSET,2);
	pTextStyleTblRcd->setFont(winFont,Adesk::kFalse,Adesk::kFalse,GB2312_CHARSET,16);
	*/

	AcDbTextStyleTable *pTextStyleTbl;
	acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pTextStyleTbl, AcDb::kForWrite);
	AcDbObjectId fontId;
	if(pTextStyleTbl->getAt(style, fontId) == Acad::eKeyNotFound)
	{
		AcDbTextStyleTableRecord *pTextStyleTblRcd=new AcDbTextStyleTableRecord;
		pTextStyleTblRcd->setName(style);
		pTextStyleTblRcd->setFont(winFont,bold,italic,charset,pitchAndFamily);
		pTextStyleTbl->add(fontId,pTextStyleTblRcd);
		pTextStyleTblRcd->close();
	}
	pTextStyleTbl->close();

	return fontId;
	//acdbHostApplicationServices()->workingDatabase()->setTextstyle(fontId);
}
示例#2
0
AcDbObjectId GetTextStyle(const CString& style)
{
	AcDbTextStyleTable *pTextStyleTbl;
	acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pTextStyleTbl, AcDb::kForWrite);
	AcDbObjectId fontId;
	pTextStyleTbl->getAt(style, fontId);
	pTextStyleTbl->close();

	return fontId;
}
示例#3
0
// Given the name of a text style, look up that name and
// return the db id of the TextStyleTableRecord.
//
Acad::ErrorStatus 
rx_getTextStyleId(const char         *styleName,
                        AcDbDatabase *db,
                        AcDbObjectId &styleId)
{
    AcDbTextStyleTable *pStyleTable;
    Acad::ErrorStatus es = db->getSymbolTable(
                              pStyleTable, AcDb::kForRead);
    if (es == Acad::eOk) {
        es = pStyleTable->getAt(styleName, styleId, Adesk::kFalse);
        pStyleTable->close();
    }
    return es;
}