From 7cd22a02b76a9df3d1e8f9a3d608bfca92a18506 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 27 May 2014 14:16:50 +0100 Subject: [PATCH] Add some text to demo app --- dpf | 2 +- examples/demo.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dpf b/dpf index 3bebc57..8d8af85 160000 --- a/dpf +++ b/dpf @@ -1 +1 @@ -Subproject commit 3bebc57983052ffc2ba578eeeb6d811f0b278da9 +Subproject commit 8d8af85953661c305c96610b7106bb87112357dd diff --git a/examples/demo.cpp b/examples/demo.cpp index 5c30fc4..55700f4 100644 --- a/examples/demo.cpp +++ b/examples/demo.cpp @@ -61,6 +61,9 @@ public: curPage(0), curHover(-1) { + // for text + font = nvg.createFont("sans", "./nanovg_res/Roboto-Regular.ttf"); + using namespace DemoArtwork; img1.loadFromMemory(ico1Data, ico1Width, ico1Height, GL_BGR); img2.loadFromMemory(ico2Data, ico2Width, ico2Height, GL_BGR); @@ -110,6 +113,19 @@ protected: img3.drawAt(pad, pad + 6 + iconSize*2); img4.drawAt(pad, pad + 9 + iconSize*3); img5.drawAt(pad, pad + 12 + iconSize*4); + + // draw some text + nvg.beginFrame(this); + + nvg.fontSize(23.0f); + nvg.textAlign(NanoVG::ALIGN_LEFT|NanoVG::ALIGN_TOP); + //nvg.textLineHeight(20.0f); + + nvg.fillColor(nvg.RGBA(220,220,220,220)); + nvg.textBox(10, 420, iconSize, "Haha,", nullptr); + nvg.textBox(15, 440, iconSize, "Look!", nullptr); + + nvg.endFrame(); } bool onMouse(const MouseEvent& ev) override @@ -194,6 +210,10 @@ private: Rectangle bgIcon; Line lineSep; Image img1, img2, img3, img4, img5; + + // for text + NanoVG nvg; + NanoVG::FontId font; }; #if 0