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

QFont incorrect letter spacing with small pointsize

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.8.0
    • GUI: Painting
    • None

    Description

      The letter spacing is incorrect when using small point sizes (<1.5 pt)
      In the attached image, all the letters are spacing in an weird manner, and the letter 'm' is completelly off.

      Diff:

      @@ -302,7 +302,7 @@ void XFormView::drawTextType(QPainter *painter)
           QPainterPath path;
           QFont f("times new roman,utopia");
           f.setStyleStrategy(QFont::ForceOutline);
      -    f.setPointSize(72);
      +    f.setPointSize(1);
           f.setStyleHint(QFont::Times);
           path.addText(0, 0, f, m_text);
       
      @@ -803,7 +803,7 @@ XFormWidget::XFormWidget(QWidget *parent)
           QGroupBox *scaleGroup = new QGroupBox(mainGroup);
           scaleGroup->setTitle(tr("Scale"));
           QSlider *scaleSlider = new QSlider(Qt::Horizontal, scaleGroup);
      -    scaleSlider->setRange(1, 4000);
      +    scaleSlider->setRange(1, 40000);
           scaleSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
       
           QGroupBox *shearGroup = new QGroupBox(mainGroup);
      

      Steps to reproduce using the examples/widgets/painting/affine:

      • Make the 2 line change presented in the diff (xform.cpp).
      • Compile and run affine example
      • Click on "Animate"
      • Click on "Reset Transform"
      • Change type to "Text"
      • Scale until text is readable

      Actually, this issue is present since 5.5. I've managed to workaround this by using:

      void GraphicsEdgeItem::setFontPointSize(qreal fontPointSize)
      {
          m_font.setPointSizeF(fontPointSize);
          if(fontPointSize < 1)
              m_font.setLetterSpacing(QFont::PercentageSpacing, 45);
          else
              m_font.setLetterSpacing(QFont().letterSpacingType(), QFont().letterSpacing());
      }
      

      Using Windows 7

      Attachments

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

        Activity

          People

            sletta Gunnar Sletta
            hrsantiago Henrique Santiago
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes