[vtkusers] vtkTextActor/vtkTextProperty baseline alignment?

David Lonie david.lonie at kitware.com
Fri Apr 4 07:52:14 EDT 2014


On Thu, Apr 3, 2014 at 4:22 PM, Sean McBride <sean at rogue-research.com>wrote:

> Hi all,
>
> If I create a vtkTextActor then tell its vtkTextProperty to:
>
> SetVerticalJustificationToBottom()
> SetValue(10.0, 10.0)
>
> should I expect alignment relative to the font's baseline?  I'm finding
> that as the string changes to include/exclude character with descenders
> (like 'p') that the text bounces up and down.  Is that expected or a bug?
>  Either way, how can I get alignment on the baseline?
>

This is the expected behavior at the moment, as it makes it easier to, say,
align a text box to a bottom corner of the viewport without worrying about
multiline, decenders, rotations, etc pushing text out of the rendered area.

I think your desired functionality would be quite useful for certain
applications, but is currently beyond the capabilities of vtkTextActor.

That said, it should be possible to manually adjust the text actor to get
what you want. Using vtkTextRenderer::GetBoundingBox, you can find out how
many pixels lie between the edge of the texture and the baseline for a
given string, as the bounding box will use the starting pen position on the
baseline as (0,0). A bit messy, but that's the only way I can think of to
get the current code to do what you want.

Feel free to file a feature request for this, I think it would be a nice
addition to our text rendering capabilities.

Hope this helps,

Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140404/6d1015a2/attachment.html>


More information about the vtkusers mailing list