From 1d4667b3472e6e5b802270db40703ac38c17c8d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Wed, 26 May 2021 15:47:44 +0800 Subject: [PATCH] add icon font support (except for res) --- doric-Qt/example/app/qml.qrc | 4 ++++ .../example/app/resources/assets_iconfont.ttf | Bin 0 -> 2108 bytes doric-Qt/example/doric/resources/text.qml | 9 ++++++++ .../example/doric/shader/DoricTextNode.cpp | 20 ++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 doric-Qt/example/app/resources/assets_iconfont.ttf diff --git a/doric-Qt/example/app/qml.qrc b/doric-Qt/example/app/qml.qrc index 8347b124..e83c096e 100644 --- a/doric-Qt/example/app/qml.qrc +++ b/doric-Qt/example/app/qml.qrc @@ -3,6 +3,10 @@ main.qml test-layout.qml qtquickcontrols2.conf + ../../../doric-demo/bundle/iconfont.ttf + + + ./resources/assets_iconfont.ttf ../../../doric-demo/bundle/src/Counter.js diff --git a/doric-Qt/example/app/resources/assets_iconfont.ttf b/doric-Qt/example/app/resources/assets_iconfont.ttf new file mode 100644 index 0000000000000000000000000000000000000000..6ea00a93968c042413b0fded35f6c6d7e1b29ecb GIT binary patch literal 2108 zcmd^APiP!f9RA+S?##|c+N9~m9@;XSq&aBVY&L(?nrcinQ7F2!Yd{cmx|!Wg+1*(t z)6zhM1@Yji5j+IVAvZw;BZ8-bIeJjYp&*E@Jw-(dUc5-V@q2IHVod~lcXr?JeZTL0 zzu)`4w{PD-0O&y*Ch`lHUZ30Ue0dKLPm`T{?b29b=98C)=&#XVEH}K?&u@Hnj{c8q zt!jO>^5;*tJ_XDYV9eBfZ|TGf-*60f*`{kG>^tVW#5dW7YmMl7ih!}VXj1i{?1|IT zH!sjw4exqO4B%IepP=tHy@vl>sq+qyTxb49D_Ds(Ha_zhDubQ@Yd72bZM>O~K4|4? z9)1kPkiBUPzw*}6nLp4IYk&A)?iVSH`~7wT#tphD7&=^LGH@Gd|In<20Vcg2p}QM<{QCgu|F8@Ses3z4%;X14r<+#wPjiG)@rT);Ng)+|$@X zuP`-EV^Q>L+=CIZoIW4=UgR&imsj28a?q><%_!Xk7yathx)*lcZolYZWfGOLSmsetProperty("lineCount", prop.toInt()); } else if (name == "fontStyle") { view->setProperty("fontStyle", prop.toString()); + } else if (name == "font") { + QString font = prop.toString(); + QString fontPath = ""; + QString fontName = font; + + if (font.contains("/")) { + int separatorIndex = font.lastIndexOf("/"); + fontPath = QStringRef(&font, 0, separatorIndex + 1).toString(); + fontName = QStringRef(&font, separatorIndex + 1, + font.length() - separatorIndex - 1) + .toString(); + } + + if (fontName.endsWith(".ttf")) { + fontName = fontName.replace(".ttf", ""); + } + + QString path = "qrc:/" + fontPath + fontName + ".ttf"; + + view->setProperty("fontSource", path); } else if (name == "shadow") { view->setProperty("shadowColor", QVariant::fromValue(DoricUtils::doricColor( prop["color"].toInt())));