[vtkusers] How to set custom fonts to vtkVectorText using vtkFontConfigFreeTypeTools?

David Lonie david.lonie at kitware.com
Thu Jan 2 14:04:23 EST 2014


Hi there,

First off, sorry for the late reply! The holidays have created a bit of a
backlog ;-)

While most of the text rendering classes have been adapted to use the new
text engine, vtkVectorText is a bit different. Rather than rendering glyphs
to an image buffer like the other classes, it uses a hardcoded set of
polygons that are used to produce renderable text as polydata. From the
vtkVectorText documentation, it only supports

"...the ASCII alphanumeric characters a-z, A-Z, 0-9, [and] ASCII
punctuation marks. (The supported ASCII character set are the codes
(33-126) inclusive.) The only control character supported is the line feed
character '\n', which advances to a new line."

The good news is that the vtkTextActor3D class provides similar
functionality (rendering text to a arbitrarily oriented 3D plane), although
it will not produce polydata that can be used by other filters. I suggest
using this class as a replacement for vtkVectorText if possible. Other
pro-unicode classes that might be useful are vtkTextMapper and vtkTextActor.

As an aside, you no longer need to directly interact with
vtkFontConfigFreeTypeTools to use a custom font. Newer versions of VTK have
a VTK_FONT_FILE symbols that can be used in vtkTextProperty to indicate
that a specific font file should be loaded and used. See the
TestChartUnicode test for an example of this:

  // Exercise the support for extended characters using UTF8 encoded strings.

  chart->GetTitleProperties()->SetFontFamily(VTK_FONT_FILE);

  chart->GetTitleProperties()->SetFontFile("/path/to/fontfile.ttf");

  chart->SetTitle("\xcf\x85\xcf\x84\xce\xba");


Hope this helps!

Dave



On Sat, Dec 21, 2013 at 8:27 AM, yarram <somasekhar.vit at gmail.com> wrote:

> Hello,
>
> I know that we can use our own system/custom fonts in VTK now using
> vtkFontConfigFreeTypeTools. I want to set some text to vtkVectorText but
> with my own font style. Can someone tell me how to do this? Thanks in
> advance.
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/How-to-set-custom-fonts-to-vtkVectorText-using-vtkFontConfigFreeTypeTools-tp5725090.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140102/b9212e9a/attachment.htm>


More information about the vtkusers mailing list