From 8d81607e28c524c52e2db1263a60398724f304a0 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 2 Feb 2015 09:26:09 -0800 Subject: [PATCH] Tweaking the example text renderer --- libraries/render-utils/src/TextRenderer.cpp | 4 ++-- tests/render-utils/CMakeLists.txt | 1 + tests/render-utils/src/main.cpp | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/render-utils/src/TextRenderer.cpp b/libraries/render-utils/src/TextRenderer.cpp index 8b6a3e2964..0345a2d0f2 100644 --- a/libraries/render-utils/src/TextRenderer.cpp +++ b/libraries/render-utils/src/TextRenderer.cpp @@ -380,7 +380,7 @@ glm::vec2 Font::drawString( //} // Stores how far we've moved from the start of the string, in DTP units - static const float SPACE_ADVANCE = getGlyph(' ').d; + static const float SPACE_ADVANCE = getGlyph('J').d; glm::vec2 advance(0, -_ascent); MatrixStack::withGlMatrices([&] { // Fetch the matrices out of GL @@ -397,7 +397,7 @@ glm::vec2 Font::drawString( MatrixStack & pr = MatrixStack::projection(); // scale the modelview into font units mv.translate(glm::vec2(x, y)).scale(glm::vec3(scale, -scale, scale)); - + //mv.translate(glm::vec3(0, _ascent, 0)); foreach(QString token, str.split(" ")) { // float tokenWidth = measureWidth(token, fontSize); // if (wrap && 0 != advance.x && (advance.x + tokenWidth) > maxWidth) { diff --git a/tests/render-utils/CMakeLists.txt b/tests/render-utils/CMakeLists.txt index 5f4cae6bec..3a542734f1 100644 --- a/tests/render-utils/CMakeLists.txt +++ b/tests/render-utils/CMakeLists.txt @@ -3,6 +3,7 @@ set(TARGET_NAME render-utils-tests) setup_hifi_project(Quick) include_glm() + #include_oglplus() # link in the shared libraries diff --git a/tests/render-utils/src/main.cpp b/tests/render-utils/src/main.cpp index 9c71dd50ea..18fe2f158d 100644 --- a/tests/render-utils/src/main.cpp +++ b/tests/render-utils/src/main.cpp @@ -139,7 +139,7 @@ void QTestWindow::makeCurrent() { m_context->makeCurrent(this); } -static const char * EXAMPLE_TEXT = "Hello 1.0\nline 2"; +static const wchar_t * EXAMPLE_TEXT = L"Hello 1.0\nline 2\ndescent ggg\nascent มมม"; static const glm::uvec2 QUAD_OFFSET(10, 20); static const glm::vec3 COLORS[4] = { { 1, 1, 1 }, @@ -181,8 +181,9 @@ void QTestWindow::draw() { glVertex2f(size.x, _size.height()); glEnd(); } + QString str = QString::fromWCharArray(EXAMPLE_TEXT); for (int i = 0; i < 4; ++i) { - _textRenderer[i]->draw(offsets[i].x, offsets[i].y, EXAMPLE_TEXT, glm::vec4(COLORS[i], 1.0f)); + _textRenderer[i]->drawString(offsets[i].x, offsets[i].y, str, glm::vec4(COLORS[i], 1.0f)); } m_context->swapBuffers(this); }