THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/09/2011 at 05:54, xxxxxxxx wrote:
With R13 you can now access the font container. The GeClipMap class provides font access functions (I know not the first place to look for).
Here is a small example how to initialize and read out a font description. MY_FONT is just a FONT description in the resource files. I initialize with the "Arial" font as example. If not found it will use the default system font instead.
Bool LookAtCamera::Init(GeListNode *node)
{
BaseContainer *data=((BaseList2D* )node)->GetDataInstance();
if (!data) return FALSE;
GeData d(FONTCHOOSER_DATA, DEFAULTVALUE);
FontData* fd = (FontData* )d.GetCustomDataType(FONTCHOOSER_DATA);
if (!fd) return FALSE;
BaseContainer bc;
GeClipMap::EnumerateFonts(&bc, GE_CM_FONTSORT_FLAT);
LONG i=0;
while (TRUE)
{
LONG id = bc.GetIndexId(i++);
if (id==NOTOK) break;
BaseContainer *fbc = bc.GetContainerInstance(id);
if (fbc)
{
String name;
if (!GeClipMap::GetFontName(fbc, GE_FONT_NAME_DISPLAY, &name)) return FALSE;
if (name.Compare("Arial") == 0)
{
fd->SetFont(fbc);
if (!data->SetData(MY_FONT,d)->GetType()) return FALSE;
return TRUE;
}
}
}
BaseContainer bc2;
if (!GeClipMap::GetDefaultFont(GE_FONT_DEFAULT_SYSTEM, &bc2)) return FALSE;
fd->SetFont(&bc2);
if (!data->SetData(MY_FONT,d)->GetType()) return FALSE;
return TRUE;
}
EXECUTIONRESULT LookAtCamera::Execute(BaseTag *tag, BaseDocument *doc, BaseObject *op, BaseThread *bt, LONG priority, EXECUTIONFLAGS flags)
{
GeData d;
if (tag->GetParameter(DescLevel(MY_FONT),d,DESCFLAGS_GET_0))
{
FontData *fd = (FontData* )d.GetCustomDataType(FONTCHOOSER_DATA);
if (fd)
{
BaseContainer bc = fd->GetFont();
String name;
if (GeClipMap::GetFontName(&bc, GE_FONT_NAME_DISPLAY, &name))
GePrint(name);
}
}
return EXECUTIONRESULT_OK;
}
EDIT: corrected the initialization code
cheers,
Matthias