ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Text vetorization

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
876 Views, 6 Replies

Text vetorization

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?

6 REPLIES 6
Message 2 of 7
philippe.leefsma
in reply to: Anonymous

Here is a link to a post that illustrate the use of AcGiTextEngine::tessellate method. I hope it will be helpful:

 

How to explode a text entity



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 7
Anonymous
in reply to: philippe.leefsma

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

 

Message 4 of 7
philippe.leefsma
in reply to: Anonymous

It gets invoked on my side. Attached is the sample I used to test.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 5 of 7
Anonymous
in reply to: Anonymous

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.

Message 6 of 7
nick83
in reply to: Anonymous

as i know this works just for vector fonts. true type fonts can't be vectorized

Message 7 of 7
Anonymous
in reply to: nick83

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost