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

Context2D's default font size should be 10px not pt

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.2.0
    • 5.1.0 Beta 1
    • None
    • 4cb1981907eabc62069a3a8330c370223632013c

    Description

      See http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-context2d.html#font-prop

      import QtQuick 2.0
      
      Item {
          width: 500
          height: 400
      
          Canvas {
              anchors.fill: parent
              anchors.margins: 100
      
              onPaint: {
                  var ctx = getContext("2d");
                  ctx.reset();
                  ctx.fillStyle = "#FF0000";
                  ctx.fillText(ctx.font, 0, 10);
              }
          }
      }
      

      Output:

      sans-serif,10,-1,5,50,0,0,0,0,0

      Where the font string is created with:

      QString QFont::toString() const
      {
          const QChar comma(QLatin1Char(','));
          return family() + comma +
              QString::number(     pointSizeF()) + comma +
              QString::number(      pixelSize()) + comma +
              QString::number((int) styleHint()) + comma +
              QString::number(         weight()) + comma +
              QString::number((int)     style()) + comma +
              QString::number((int) underline()) + comma +
              QString::number((int) strikeOut()) + comma +
              QString::number((int)fixedPitch()) + comma +
              QString::number((int)   rawMode());
      }
      

      Attachments

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

        Activity

          People

            mitch_curtis Mitch Curtis
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes