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. QRawFont::fromFont not working correctly on Mac OS X
Forum Updated to NodeBB v4.3 + New Features

QRawFont::fromFont not working correctly on Mac OS X

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.1k 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.
  • M Offline
    M Offline
    manhntd
    wrote on 26 Sept 2012, 09:41 last edited by
    #1

    I found something wrong on Qt on Mac OS X 10.6.3:

    @QFont font = QFont("Wingdings"); //font.family() == "Wingdings"
    QRawFont rawFont = QRawFont::fromFont(font); //rawFont.familyName() == "Lucida Grande"@

    I think rawFont.familyName() should be "Wingdings". On Windows this code works correctly.

    I tried this method:

    @QRawFont ( const QString & fileName, qreal pixelSize, QFont::HintingPreference hintingPreference = QFont::PreferDefaultHinting )@

    on a font file and it works correctly.

    I really don't know how to correct this. Any help is appreciated.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      acethewd
      wrote on 6 Nov 2012, 17:08 last edited by
      #2

      I have also run into this issue on Mac OS X 10.7.5 using Qt 4.8.1 and 4.8.3.

      QGraphicsTextItem won't display (some?) symbol type fonts on this OS, even using the setHtml() method and specifying like Wingdings as the font to draw with.

      Even the provided example application "fontsampler" won't properly display webdings, wingdings, wingdings 2, or wingdings 3.

      I didn't know about the QRawFont class and did some research on it. The below sample code uses it with the QGlyphRun class to allow printing of some text on the screen using the Wingdings font, but it is definitely not the way I would like to go with symbol font support.

      @
      #include <QApplication>
      #include <QGraphicsScene>
      #include <QGraphicsView>
      #include <QRawFont>
      #include <QGlyphRun>

      int main(int argc, char *argv[])
      {
      QApplication a(argc, argv);

      QGlyphRun glyphs;
      QVector<quint32> glyphIndexes;
      QVector<QPointF> positions;

      glyphIndexes.append(43); //H
      glyphIndexes.append(72); //e
      glyphIndexes.append(79); //l
      glyphIndexes.append(79); //l
      glyphIndexes.append(82); //o

      positions.append(QPointF(100, 200));
      positions.append(QPointF(150, 200));
      positions.append(QPointF(230, 200));
      positions.append(QPointF(300, 200));
      positions.append(QPointF(375, 200));

      glyphs.setRawFont(QRawFont(QString("/Library/Fonts/Wingdings.ttf"), 72));
      glyphs.setGlyphIndexes(glyphIndexes);
      glyphs.setPositions(positions);

      QPixmap drawGlyphs(800, 800);
      drawGlyphs.fill(Qt::white);

      QPainter p(&drawGlyphs);
      p.setPen(Qt::black);
      p.drawGlyphRun(QPointF(10, 10), glyphs);

      QGraphicsScene *pScene = new QGraphicsScene(0, 0, 1000, 1000);
      QGraphicsView *pView = new QGraphicsView(pScene);

      pScene->addPixmap(drawGlyphs);
      pView->show();

      return a.exec();
      }
      @

      1 Reply Last reply
      0
      • C Offline
        C Offline
        chriskatze
        wrote on 23 Jan 2014, 19:01 last edited by
        #3

        see "here":http://stackoverflow.com/questions/15613466/qt-font-os-x-and-fontbookfor for a solution for drawing symbol fonts on mac: Use QChar(0xf0 | c) instead of QChar( c )

        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