some util methods in the ogre font class for calculating infos about how the text would look if rendered without actually creating a TextAreaOverlay would be nice, ideally something like
Code: Select all
void getTextSize(const String& text,Real& cx,Real &cy);
// (e.g. centered text, buttons that automatically scale to their label )
void getCharBounds(const String& text,const int iCharIndex,Rectangle& bounds);
// (e.g. for custom selection effects, custom blinking caret)
int getCharAtPos(const String& text,const Real x,const Real y);
// (e.g. clicking to place the caret)
the code for that is currently deep inside in TextAreaOverlayElement::updatePositionGeometry() and would have to be copied to be used for custom widgets or stuff like text billboards inside the scene (with depthcheck and depthwrite, not overlay).
i think all the viewport and resolution calc can be done afterwards, the font doesn't need to bother about that.
its all nothing thats desperately needed, but might be nice to have =)
edit : even stuff like charwidth,charheight could be calculated outside these basic functions by simply multiplicating the result, maybe convenience variants with viewport and fontsize params.
edit 2: meanwhile i think a smart iterator would be better than a visitor, it would remember the current position while "drawing" text or whatever, and provide info about the current char (widht,height, texcoords,isnewline,iswhitespace,...), it would probably be a derived class of one of the Ogre::UTFString:: iterators....
maybe i'll implement that thing soon if you guys don't find the time, any comments/ideas/... are welcome =)