[vtkusers] Using fontconfig with vtkTextMapper/vtkTextProperty?
david.lonie at kitware.com
Thu Oct 20 10:55:08 EDT 2016
On Thu, Oct 20, 2016 at 10:48 AM, Elvis Stansvik <
elvis.stansvik at orexplore.com> wrote:
> 2016-10-20 16:41 GMT+02:00 David Lonie <david.lonie at kitware.com>:
> > Correct -- Set ForceCompiledFonts off on vtkFreeTypeTools, and set the
> > of the font using vtkTextProperty::SetFontFamilyAsString.
> > As you discovered, this requires the RenderingFreeTypeFontConfig module
> > be enabled and linked to the final application. There is an example
> usage in
> > Rendering/FreeTypeFontConfig/Testing/Cxx/TestSystemFontRendering.cxx if
> > get stuck.
> > Let us know if you have further issues, AFAIK this functionality is not
> > widely used.
> Yep, it now seems to work. E.g. I can now do:
> textProperty->SetFontFamilyAsString("Noto Sans");
> However, one thing puzzles me: The font is much smaller than what I
> would have expected. I set it to 10 points here, but the result is
> much smaller (see attached screenshot).
> My goal is to use
> QFontDatabase::systemFont(QFontDatabase::GeneralFont) to get the
> system font through Qt, and use its values for .fontSize() and
> .family() when constructing my vtkTextProperty, to make the font in
> VTK match my system font.
> Any idea why the text is rendered so small? The vtkTextProperty is set
> on a vtkTextMapper which in turn is set on a vtkActor2D.
It's hard to say. How does it compare to a VTK built-in font of the same
size? The glyph sizes are set by the freetype library, VTK doesn't have
much control over this. It just asks the library for glyphs of a certain
size/family and draws them into a texture. You may need to set a scaling
factor during the conversion if something seems iffy.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtkusers