From 4cb1981907eabc62069a3a8330c370223632013c Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 13 Jun 2013 10:50:31 +0200 Subject: [PATCH] Set default font size to 10px as per spec, not 10pt. 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 --- src/quick/items/context2d/qquickcontext2d.cpp | 23 ---------------------- src/quick/items/context2d/qquickcontext2d_p.h | 3 ++- .../quick/qquickcanvasitem/data/tst_context.qml | 2 ++ 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 35ea28b..111d02e 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -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(); diff --git a/src/quick/items/context2d/qquickcontext2d_p.h b/src/quick/items/context2d/qquickcontext2d_p.h index 24f5c44..6256249 100644 --- a/src/quick/items/context2d/qquickcontext2d_p.h +++ b/src/quick/items/context2d/qquickcontext2d_p.h @@ -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; diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_context.qml b/tests/auto/quick/qquickcanvasitem/data/tst_context.qml index 7350ed6..ad44f6d 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_context.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_context.qml @@ -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"); } -- 2.7.4