Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-78

Incorrect glyphs with the Graecall font

    XMLWordPrintable

Details

    Description

      The QPainter::drawText() does not display correctly some characters using the font "GraecaII".

      ALL characters higher than 128 are replaced with other characters. Enclosed there are two images: the first one shows the correct layout of GraecaII font, the second one shows a QT Window that uses the following code to
      display all the characters with negative advances and the complete map.

      /////////////////////////////////////////////////////
      void TextArea::paintEvent(QPaintEvent *)

      { QRect rect1(0, 0, size.width(), 30); QRect rect2(0, 30, size.width(), 30); int acc1[] = {74,47,59,62,63,39,91,92,93,95,96,106,118,123,124,125}

      ;
      uchar acc2[] =

      {138,145,149,154,159,161,164,173,177,179,192,208,209,214,216,230,243,249}

      ;
      QString str1;
      QString str2;
      char tmp[64];

      for(int n = 0; n < sizeof(acc1) / sizeof(int); n++)

      { str1.append(QChar('a')); str1.append(QChar::fromLatin1((char)acc1[n])); }

      for(int n = 0; n < sizeof(acc2) / sizeof(uchar); n++)

      { str2.append(QChar('a')); str2.append(QChar(acc2[n])); }

      QPainter painter(this);
      painter.setRenderHint(QPainter::Antialiasing);

      QFont font(tr("GraecaII"), 16);
      QFont font2(tr("Arial"), 8);

      QTextOption option(Qt::AlignLeft);
      option.setWrapMode(QTextOption::WordWrap);
      option.setFlags(0);

      painter.setFont(font);
      painter.drawText(5, 20, str1);
      painter.drawText(5, 50, str2);

      int _w = 40;
      int _h = 40;
      int _x, _y;
      for(int x = 0; x < 16; x++)
      {
      for(int y = 0; y < 16; y++)

      { uchar uc = x * 16 + y; QChar c(uc); QString s(c); painter.setFont(font); QFontMetrics fm = painter.fontMetrics(); QString t = QString("%1").arg(uc); _x = x * _w; _y = 80 + y * _h; painter.drawRect(_x, _y, _w, _h); painter.setFont(font2); painter.drawText(_x + 2, _y + 10, t); painter.setFont(font); int lb = fm.leftBearing(c); if(lb < 0) painter.drawText(_x + 12 - lb + 2, _y + 30, s); else painter.drawText(_x + 12, _y + 30, s); }

      }
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            shausman Simon Hausmann
            sanonymous Nokia Qt Support (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes