Make font rendering match Qt 5

Hi all,

I'm trying to get the font rendering of matplotlib match the look of
Qt 5 as much as possible. My target system is Kubuntu 15.10, with Qt
5.5.1 and matplotlib 1.5.1.

What I've done is (not completely robust, but still):

from matplotlib import rcParams


# Make matplotlib use system font.
font = QFontDatabase.systemFont(QFontDatabase.GeneralFont)
rcParams[''] = 'sans-serif'
rcParams['font.sans-serif'] =
rcParams['font.size'] = font.pointSize()
rcParams['font.weight'] = 100 + font.weight() * 8 # 0-99 -> 100-900

This gets me quite close. See the attached screenshot, and compare the
font rendering in the matplotlib figure compared to surrounding Qt

Is there something that can get me even closer to 100% the same look?
I'm guessing it's down to how Qt does hinting / gamma? I've
experimented with the text.hinting and text.hinting_factor RC
parameters, but with no luck. The looks is still slightly different.

When used in a UI like this, it would be very nice if matplotlib could
default to using the system font, and take care to render it the same
way as the UI framework (Qt, Gtk, ...).

Thanks in advance for any advice.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mpl_font_vs_qt5_font.png
Type: image/png
Size: 10657 bytes
Desc: not available
URL: <>