Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/09/2011 at 02:14, xxxxxxxx wrote:
User Information: Cinema 4D Version: 13 Platform: Windows ; Language(s) : C++ ;
--------- hello,
I'm using the Fontchooser (FONT ID {} ) in a res file of my plugin. And now I like to read the font name which the user choosen (to print out in an xml file). How can I do this. I know in the last versions it doesn't works with the FontData class !
thanks Marky
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
On 13/09/2011 at 02:24, xxxxxxxx wrote:
hello Matthias, thanks for this example. But unfortunately I get always a DA_NIL value for the GeData in my Init() function. Do you know why ? regards Marky
On 13/09/2011 at 03:58, xxxxxxxx wrote:
Indeed there is a problem. I will look into it.
On 13/09/2011 at 04:43, xxxxxxxx wrote:
Ok, I corrected the Init() routine. As example I intialize it with the "Arial" font. If not found it will use the default system font instead.
On 13/09/2011 at 05:41, xxxxxxxx wrote:
fine, that's working now. My last question, how can I set a font in a osplinetext object?
BaseObject* text = BaseObject::Alloc(Osplinetext); GeData data; BaseContainer *bc = text->GetDataInstance(); data.SetString(op->GetDataInstance()->GetString(TXT_ID_PAINTSPLINETEXT_TEXT,"")); bc->SetParameter( DescLevel(PRIM_TEXT_TEXT), data); bc->SetParameter( DescLevel(PRIM_TEXT_FONT), ?????
regards Marky
On 13/09/2011 at 06:41, xxxxxxxx wrote:
You set it the same as I did in the Init() routine just with the PRIM_TEXT_FONT parameter ID.
On 13/09/2011 at 07:13, xxxxxxxx wrote:
super, it works. thanks a lot