Set default font size to 10px as per spec, not 10pt.
authorMitch Curtis <mitch.curtis@digia.com>
Thu, 13 Jun 2013 08:50:31 +0000 (10:50 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 14 Jun 2013 13:52:01 +0000 (15:52 +0200)
See: http://www.w3.org/TR/2dcontext/#dom-context-2d-font

Also removes duplicated assignments that are done as part of the
default constructor.

Task-number: QTBUG-31716

Change-Id: I5bd131c14a5defd422d858f02974c215de7adae9
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
src/quick/items/context2d/qquickcontext2d.cpp
src/quick/items/context2d/qquickcontext2d_p.h
tests/auto/quick/qquickcanvasitem/data/tst_context.qml

index 35ea28b..111d02e 100644 (file)
@@ -3676,7 +3676,6 @@ void QQuickContext2D::pushState()
 void QQuickContext2D::reset()
 {
     QQuickContext2D::State newState;
-    newState.matrix = QTransform();
 
     m_path = QPainterPath();
 
@@ -3688,28 +3687,6 @@ void QQuickContext2D::reset()
     newState.clipPath = defaultClipPath;
     newState.clipPath.setFillRule(Qt::WindingFill);
 
-    newState.strokeStyle = QColor("#000000");
-    newState.fillStyle = QColor("#000000");
-    newState.fillPatternRepeatX = false;
-    newState.fillPatternRepeatY = false;
-    newState.strokePatternRepeatX = false;
-    newState.strokePatternRepeatY = false;
-    newState.invertibleCTM = true;
-    newState.fillRule = Qt::WindingFill;
-    newState.globalAlpha = 1.0;
-    newState.lineWidth = 1;
-    newState.lineCap = Qt::FlatCap;
-    newState.lineJoin = Qt::MiterJoin;
-    newState.miterLimit = 10;
-    newState.shadowOffsetX = 0;
-    newState.shadowOffsetY = 0;
-    newState.shadowBlur = 0;
-    newState.shadowColor = qRgba(0, 0, 0, 0);
-    newState.globalCompositeOperation = QPainter::CompositionMode_SourceOver;
-    newState.font = QFont(QLatin1String("sans-serif"), 10);
-    newState.textAlign = QQuickContext2D::Start;
-    newState.textBaseline = QQuickContext2D::Alphabetic;
-
     m_stateStack.clear();
     m_stateStack.push(newState);
     popState();
index 24f5c44..6256249 100644 (file)
@@ -130,10 +130,11 @@ public:
             , shadowBlur(0)
             , shadowColor(qRgba(0, 0, 0, 0))
             , globalCompositeOperation(QPainter::CompositionMode_SourceOver)
-            , font(QFont(QLatin1String("sans-serif"), 10))
+            , font(QFont(QLatin1String("sans-serif")))
             , textAlign(QQuickContext2D::Start)
             , textBaseline(QQuickContext2D::Alphabetic)
         {
+            font.setPixelSize(10);
         }
 
         QTransform matrix;
index 7350ed6..ad44f6d 100644 (file)
@@ -80,6 +80,8 @@ Canvas {
             compare(contextSpy.count, 1);
 
             var ctx = canvas.getContext("2d");
+            compare(ctx.font, "sans-serif,-1,10,5,50,0,0,0,0,0");
+
             ctx.font = "80.1px sans-serif";
             compare(ctx.font, "sans-serif,-1,80,5,50,0,0,0,0,0");
         }