From d8ac2c1011851ae63669bf1a59577aab94c87578 Mon Sep 17 00:00:00 2001 From: Charles Yin Date: Fri, 15 Jul 2011 16:31:06 +1000 Subject: [PATCH] add font support for context2d Change-Id: I77a7af006e1c0264365ae6d93bf78416f8b38a62 Reviewed-on: http://codereview.qt.nokia.com/1686 Reviewed-by: Qt Sanity Bot Reviewed-by: Charles Yin --- src/declarative/items/qsgcontext2d.cpp | 20 +++++++++++++------- src/declarative/items/qsgcontext2d_p_p.h | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/declarative/items/qsgcontext2d.cpp b/src/declarative/items/qsgcontext2d.cpp index 6f3b117..5dd796b 100644 --- a/src/declarative/items/qsgcontext2d.cpp +++ b/src/declarative/items/qsgcontext2d.cpp @@ -1153,8 +1153,9 @@ v8::Handle ctx2d_font(v8::Local, const v8::AccessorInfo & QV8Context2DResource *r = v8_resource_cast(info.This()); CHECK_CONTEXT(r) + QV8Engine *engine = V8ENGINE_ACCESSOR(); - return v8::Undefined(); + return engine->toString(r->context->font()); } static void ctx2d_font_set(v8::Local, v8::Local value, const v8::AccessorInfo &info) @@ -1162,24 +1163,27 @@ static void ctx2d_font_set(v8::Local, v8::Local value, co QV8Context2DResource *r = v8_resource_cast(info.This()); CHECK_CONTEXT_SETTER(r) - Q_UNUSED(value); + QV8Engine *engine = V8ENGINE_ACCESSOR(); + + r->context->setFont(engine->toString(value)); } v8::Handle ctx2d_textAlign(v8::Local, const v8::AccessorInfo &info) { QV8Context2DResource *r = v8_resource_cast(info.This()); CHECK_CONTEXT(r) + QV8Engine *engine = V8ENGINE_ACCESSOR(); - - return v8::Undefined(); + return engine->toString(r->context->textAlign()); } static void ctx2d_textAlign_set(v8::Local, v8::Local value, const v8::AccessorInfo &info) { QV8Context2DResource *r = v8_resource_cast(info.This()); CHECK_CONTEXT_SETTER(r) + QV8Engine *engine = V8ENGINE_ACCESSOR(); - Q_UNUSED(value); + r->context->setTextAlign(engine->toString(value)); } v8::Handle ctx2d_textBaseline(v8::Local, const v8::AccessorInfo &info) @@ -1187,16 +1191,18 @@ v8::Handle ctx2d_textBaseline(v8::Local, const v8::Access QV8Context2DResource *r = v8_resource_cast(info.This()); CHECK_CONTEXT(r) + QV8Engine *engine = V8ENGINE_ACCESSOR(); - return v8::Undefined(); + return engine->toString(r->context->textBaseline()); } static void ctx2d_textBaseline_set(v8::Local, v8::Local value, const v8::AccessorInfo &info) { QV8Context2DResource *r = v8_resource_cast(info.This()); CHECK_CONTEXT_SETTER(r) + QV8Engine *engine = V8ENGINE_ACCESSOR(); - Q_UNUSED(value); + r->context->setTextBaseline(engine->toString(value)); } static v8::Handle ctx2d_fillText(const v8::Arguments &args) diff --git a/src/declarative/items/qsgcontext2d_p_p.h b/src/declarative/items/qsgcontext2d_p_p.h index ed73b2f..d71a0bc 100644 --- a/src/declarative/items/qsgcontext2d_p_p.h +++ b/src/declarative/items/qsgcontext2d_p_p.h @@ -181,7 +181,7 @@ public: void clearCommands() { - qDebug() << "painting commands:" << commands.size(); + //qDebug() << "painting commands:" << commands.size(); commands.remove(0, commands.size()); variants.remove(0, variants.size()); pens.remove(0, pens.size()); -- 2.7.4