diff --git a/src/Text/AbstractFont.h b/src/Text/AbstractFont.h index 30e57cafc..402273881 100644 --- a/src/Text/AbstractFont.h +++ b/src/Text/AbstractFont.h @@ -271,12 +271,11 @@ class MAGNUM_TEXT_EXPORT AbstractLayouter { /** * @brief Render glyph * @param i Glyph index - * @param cursorPosition Cursor position * * Returns quad position, texture coordinates and advance to next * glyph. */ - virtual std::tuple renderGlyph(const Vector2& cursorPosition, UnsignedInt i) = 0; + virtual std::tuple renderGlyph(UnsignedInt i) = 0; #ifdef DOXYGEN_GENERATING_OUTPUT private: diff --git a/src/Text/Test/TextRendererGLTest.cpp b/src/Text/Test/TextRendererGLTest.cpp index 9bae32ab7..22f32a8d4 100644 --- a/src/Text/Test/TextRendererGLTest.cpp +++ b/src/Text/Test/TextRendererGLTest.cpp @@ -51,10 +51,10 @@ class TestLayouter: public Text::AbstractLayouter { _glyphCount = glyphCount; } - std::tuple renderGlyph(const Vector2& cursorPosition, UnsignedInt i) override { + std::tuple renderGlyph(UnsignedInt i) override { return std::make_tuple( - Rectangle(cursorPosition, cursorPosition+Vector2(3.0f, 2.0f)*((i+1)*_size)), - Rectangle({i*6.0f, 0.0f}, {(i+1)*6.0f, 10.0f}), + Rectangle({}, Vector2(3.0f, 2.0f)*((i+1)*_size)), + Rectangle::fromSize({i*6.0f, 0.0f}, {6.0f, 10.0f}), (Vector2::xAxis((i+1)*3.0f)+Vector2(1.0f, -1.0f))*_size ); } diff --git a/src/Text/TextRenderer.cpp b/src/Text/TextRenderer.cpp index e12ebc252..19833c636 100644 --- a/src/Text/TextRenderer.cpp +++ b/src/Text/TextRenderer.cpp @@ -78,7 +78,11 @@ std::tuple, std::vector, std::vector, /* Position of the texture in the resulting glyph, texture coordinates */ Rectangle quadPosition, textureCoordinates; Vector2 advance; - std::tie(quadPosition, textureCoordinates, advance) = layouter->renderGlyph(cursorPosition, i); + std::tie(quadPosition, textureCoordinates, advance) = layouter->renderGlyph(i); + + /* Move the quad to cursor */ + quadPosition.bottomLeft() += cursorPosition; + quadPosition.topRight() += cursorPosition; /* 0---2 | | @@ -134,7 +138,11 @@ std::tuple AbstractTextRenderer::render(AbstractFont* const fon /* Position of the texture in the resulting glyph, texture coordinates */ Rectangle quadPosition, textureCoordinates; Vector2 advance; - std::tie(quadPosition, textureCoordinates, advance) = layouter->renderGlyph(cursorPosition, i); + std::tie(quadPosition, textureCoordinates, advance) = layouter->renderGlyph(i); + + /* Move the quad to cursor */ + quadPosition.bottomLeft() += cursorPosition; + quadPosition.topRight() += cursorPosition; vertices.insert(vertices.end(), { {quadPosition.topLeft(), textureCoordinates.topLeft()}, @@ -274,7 +282,11 @@ void AbstractTextRenderer::render(const std::string& text) { /* Position of the texture in the resulting glyph, texture coordinates */ Rectangle quadPosition, textureCoordinates; Vector2 advance; - std::tie(quadPosition, textureCoordinates, advance) = layouter->renderGlyph(cursorPosition, i); + std::tie(quadPosition, textureCoordinates, advance) = layouter->renderGlyph(i); + + /* Move the quad to cursor */ + quadPosition.bottomLeft() += cursorPosition; + quadPosition.topRight() += cursorPosition; /* Extend rectangle with current quad bounds */ _rectangle.bottomLeft() = Math::min(_rectangle.bottomLeft(), quadPosition.bottomLeft());