Hi James,

You should be able to go directly to the Font to get the Glyph's
directly.  osgText::Text itself will use the Glyph values to position
and size it's quads for rendering.  osgText supports Kerning so this
affects the position of text characters as well.

Robert.

On 2 May 2012 17:13, James Turner <[email protected]> wrote:
> Hi,
>
> I'm trying to port some existing code to use osgText instead of a previous 
> font-rendering library, and hitting up against the osgText API. In 
> particular, I'm struggling to measure text without setting it on a 
> osgText::Text instance.
>
> I guess this is because the font-size and pixel size (and even transformation 
> matrix?) must be known to compute a size, but the code I'm coming from 
> frequently does things like:
>
> double width = widthOfString("lorum ipsum etc");
> // or indeed, height of the string
>
> if (width > blah) {
>        ... take some action
> } else {
>        ... take some radically different action
> }
>
> The problem is if start setting line-wrapping or a maximum width on the 
> osgText::Text, it seems as if the computed bounding box is going to respect 
> those values. I think I need a way to measure the glyph bounds as if line 
> wrapping / maximum sizes were ignored. (Without saving / resetting / 
> restoring them)
>
> (There's also the issue of needed to create the text-node to perform the 
> measurement at all, but I guess I can't escape that)
>
> Am I missing some API features, or is this simply not possible?
>
> BTW, all this text will be drawn with no scaling / rotation, in screen-space, 
> with orthographic projection. I realise osgText can't assume that in the 
> general case, of course. So, for example, if I could abuse the Font API to 
> measure glyph bounds, that might work quite well for me.
>
> James
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to