From e7dc7e957ebab5eb8db9c18b44e859b75ae5def1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Wed, 19 May 2021 14:27:44 +0800 Subject: [PATCH] add font style --- doric-Qt/example/doric/resources/text.qml | 13 +++++++++++++ doric-Qt/example/doric/shader/DoricTextNode.cpp | 2 ++ 2 files changed, 15 insertions(+) diff --git a/doric-Qt/example/doric/resources/text.qml b/doric-Qt/example/doric/resources/text.qml index 66db3748..d2d5c82d 100644 --- a/doric-Qt/example/doric/resources/text.qml +++ b/doric-Qt/example/doric/resources/text.qml @@ -20,6 +20,19 @@ TextArea { property int textAlignment: 0 + property var fontStyle: "" + + onFontStyleChanged: { + if (fontStyle === "bold") { + font.weight = Font.Bold + } else if (fontStyle === "italic") { + font.italic = true + } else if (fontStyle === "bold_italic") { + font.weight = Font.Bold + font.italic = true + } + } + background: Rectangle { id: bg color: 'transparent' diff --git a/doric-Qt/example/doric/shader/DoricTextNode.cpp b/doric-Qt/example/doric/shader/DoricTextNode.cpp index f578b33d..a44648e3 100644 --- a/doric-Qt/example/doric/shader/DoricTextNode.cpp +++ b/doric-Qt/example/doric/shader/DoricTextNode.cpp @@ -30,6 +30,8 @@ void DoricTextNode::blend(QQuickItem *view, QString name, QJsonValue prop) { view->setProperty("font", QVariant(font)); } else if (name == "textAlignment") { view->setProperty("textAlignment", prop.toInt()); + } else if (name == "fontStyle") { + view->setProperty("fontStyle", prop.toString()); } else { DoricViewNode::blend(view, name, prop); }