Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Creating QFont for a very specific font family/style pair
Forum Updated to NodeBB v4.3 + New Features

Creating QFont for a very specific font family/style pair

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    syr123
    wrote on last edited by
    #1

    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:

    fontdatabase.styles(QString("Futura"))

    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?

    edit

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

    1 Reply Last reply
    0
    • S Offline
      S Offline
      syr123
      wrote on last edited by
      #2

      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:

      QFontDatabase.addApplicationFont("resources/FuturaCondensedExtraBold.ttf")

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

      QFont("FuturaCondensedExtraBold")

      but I could simple do

      QFont("Futura")

      and the style it would find was ExtraBold

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved