[vtkusers] Using fontconfig with vtkTextMapper/vtkTextProperty?

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


On Thu, Oct 20, 2016 at 12:25 PM, Elvis Stansvik <
elvis.stansvik at orexplore.com> wrote:

> Den 20 okt. 2016 5:30 em skrev "David Lonie" <david.lonie at kitware.com>:
> >
> > 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.
>
> Aha, thanks for the tip. On my way home now but will test tomorrow. Do you
> know if it's in 7.1rc1? I'm building my Debian package from that tag
>

It is. We added this about a year ago, but like the fontconfig stuff, it
hasn't seen widespread use yet so any feedback would be great :)

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


More information about the vtkusers mailing list