Hello
We use RealDWG 2014.
We want to implement our own viewer using RealDWG. How can I vectorize text objects in AcGiWorldGeometry::text method? I know AutoCAD uses Heidi driver to render texts, are any samples describing how to solve this problem?
Here is a link to a post that illustrate the use of AcGiTextEngine::tessellate method. I hope it will be helpful:
Thanks for reply. I have written sample code but function 'AcGiTextEngine::tessellate' doesn't call 'PolylineCallback'. Should I initialize something before using it?
// fPCallBack - polyline callback, receives vertices void fPCallBack(int x, int const *y, AcGePoint3d const *z, void *l)
{
printf("fPCallBack()\n");
}
// fUnicodeCallback - unicode function call back, does nothing in current implementation void fUnicodeCallback(long x, unsigned short const *y, int z, void *l)
{
printf("fUnicodeCallback()\n");
}
int main(void) { acdbSetHostApplicationServices(&gCreatentHostApp); long lcid = 0x00000409; // English acdbValidateSetup(lcid); AcDbDatabase *db = new AcDbDatabase(false, true); db->readDwgFile(L"test.dwg"); AcTransaction *trans = db->transactionManager()->startTransaction(); AcDbBlockTable *blockTable; db->getBlockTable(blockTable, AcDb::kForRead); AcGiTextEngine *pTextEngine = AcGiTextEngine::create(); if (blockTable != NULL) { AcDbBlockTableIterator *blockTableIt; blockTable->newIterator(blockTableIt); while (!blockTableIt->done()) { AcDbBlockTableRecord *block; blockTableIt->getRecord(block, AcDb::kForRead); AcDbBlockTableRecordIterator *blockIt; Acad::ErrorStatus e = block->newIterator(blockIt); while (!blockIt->done()) { AcDbEntity *entity; blockIt->getEntity(entity, AcDb::kForRead); if (entity->isKindOf(AcDbText::desc())) { AcDbText *pText = static_cast<AcDbText *>(entity); wprintf(L"Text: %s\n", pText->textString()); AcDbTextStyleTableRecord *pTextStyle; acdbOpenObject(pTextStyle, pText->textStyle(), AcDb::kForRead, false); bool bIsTTF = false; const ACHAR* pFileName; pTextStyle->fileName(pFileName); if(NULL != wcsstr(pFileName, L".TTF") || NULL != wcsstr(pFileName, L".ttf")) bIsTTF = true; pTextStyle->close(); AcGiTextStyle mStyle; fromAcDbTextStyle(mStyle, pText->textStyle()); if (bIsTTF) pTextEngine->tessellate(mStyle,pText->textString(),-1,true,NULL,(UnicodeCallback)fUnicodeCallback,(PolylineCallback)fPCallBack); else pTextEngine->tessellate(mStyle,pText->textString(),-1,true,0.0,NULL,(PolylineCallback)fPCallBack); } blockIt->step(); } blockTableIt->step(); } } db->transactionManager()->endTransaction(); delete db; return 0; }
It gets invoked on my side. Attached is the sample I used to test.
Regards,
Philippe.
Hello,
Thanks it works now, I didn't call setWorkingDatabase. Now I have another problem. In function AcGiGeometry::text I receive AcGiTextStyle object but for TrueType fonts function AcGiTextStyle::fileName returns NULL. RealDWG doesn't call AcDbHostApplicationServices::findFile for such fonts (with hint kTrueTypeFontFile) to search. I'm attaching sample file.
I implemented vectorization of TrueType fonts on my side but I need only get informations about fonts used in texts. I noticed that it works for AcDbText but doesn't for AcDbMText with the same style.