[vtkusers] Using fontconfig with vtkTextMapper/vtkTextProperty?

David Lonie david.lonie at kitware.com
Thu Oct 20 11:29:50 EDT 2016

On Thu, Oct 20, 2016 at 11:27 AM, Elvis Stansvik <
elvis.stansvik at orexplore.com> wrote:

> Using built-in fonts I also get text rendered smaller than expected.
> However, I think it's a matter of DPI. I guess VTK assumes a DPI of 72
> somewhere?
> With the following, the text is rendered in the expected size:
>     auto logicalDpiY = QApplication::screens().at(0)-
> >logicalDotsPerInchY();
>     ...
>     textProperty->SetFontSize(qRound(10 * (logicalDpiY / 72.0)));
>     textProperty->SetFontFamilyAsString("Noto Sans");
> So I'm compensating for VTK's assumption about 72 DPI by increasing
> the font size (on my system Qt's logicalDotsPerInchY() reports
> 96.2526).
> I guess I should also figure out how to be notified when the widget is
> moved to another screen and update the size, since the DPI of the
> other screen might be different.

Aha, yes, VTK does assume 72 DPI by default. We very recently added the
ability to change that for text rendering purposes. Call
vtkRenderWindow::SetDPI to update it to what Qt is using, and the text
rendering should adjust accordingly. Let me know if that fixes it.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161020/6c157169/attachment.html>

More information about the vtkusers mailing list