Hello, is there a way to create a text element with font that is not currently available?
Let's say I need to create a text element which uses 'simplex' font in first version of MicroStation V8i where normally is installed only one SHX font - 'msdefault'.
I have tried all methods (I can imagine) in MDL and API as well to get a font number using name 'simplex' but always I try to find font by name I get NULL instead of FontP.
This is what I do:
MSDgnFileP dgnFile = FontManager::GetMSDgnFileP(model); FontNumMapP fontNumMap = FontManager::GetFontMap(dgnFile); UInt32 num = 0xFFFFFFFF; FontP font = fontNumMap->FindFontByName(&num, (MSWCharCP)L"simplex", FINDFONT_All);
font is NULL...
I used to use the same method (FindFontByName) and it works as long as the font is loaded in MicroStation. Here's a better way which loads the font as long as it exists in one of the folders MicroStation scans for fonts (MS_FONTPATH):
extern "C" DLLEXPORT int GetFontByName (char *fontName ){ Bentley::Ustn::Text::FontNumMap* fonts = Bentley::Ustn::Text::FontManager::GetFontMap(mdlModelRef_getActive()); UInt32 fnum = -666; Bentley::WString wFontName(fontName); FontCP font = Text::FontManager::FindSystemFont(wFontName.c_str()); if (font == NULL) return(-1); fonts->GetFontNumber(fnum, *font, TRUE); return(fnum);}