Creating QFont for a very specific font family/style pair

  • I am subclassing QGraphicsTextItem, and am trying to set its font.

    I am writing this app for myself only, and have a very particular font I wish to use:

    Futura Condensed ExtraBold, which is on my system.

    I have created a QFontDatabase to look at how Qt registers my fonts. 'Futura' is what is listed under families. When I run:


    one of the return values is:

    PyQt4.QtCore.QString(u'Condensed ExtraBold')

    I just can't for the life of me figure out how to set the exact 'style' of a QFont. I see how to set it generically to bold, or to a certain weight, but in this case, that style, Condensed ExtraBold, is a totally different looking font than say, Bold Oblique, Condensed Light Oblique, etc, which are all styles of Futura.

    I only seem to be able to figure out how to hint at the style I might want. How can I explicitly use Futura Condensed ExtraBold?


    I should add, I've tried QFont("Futura Condensed ExtraBold"), and Qt defaults to some bogus font that is certainly not Futura Condensed ExtraBold.

  • I found a solution.

    I moved the specific .ttf I wanted to a resources directory in my app so it would be bundled with it in the future. I then used:


    Once I had done so, I was actually not able to do this:


    but I could simple do


    and the style it would find was ExtraBold

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.