From 6533665f1573cf32fbfb2ecb845bc1e75b381d92 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Mon, 14 Mar 2016 14:40:10 +0100 Subject: [PATCH] Ignore carriage returns (\r) in print and friends (issue #1114) --HG-- branch : minor --- src/modules/graphics/opengl/Font.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/modules/graphics/opengl/Font.cpp b/src/modules/graphics/opengl/Font.cpp index 646bbe883..cf81efe71 100644 --- a/src/modules/graphics/opengl/Font.cpp +++ b/src/modules/graphics/opengl/Font.cpp @@ -444,6 +444,10 @@ std::vector Font::generateVertices(const ColoredCodepoints &c continue; } + // Ignore carriage returns + if (g == '\r') + continue; + uint32 cacheid = textureCacheID; const Glyph &glyph = findGlyph(g); @@ -521,7 +525,7 @@ std::vector Font::generateVertices(const ColoredCodepoints &c info->width = maxwidth - offset.x;; info->height = (int) dy + (dx > 0.0f ? floorf(getHeight() * getLineHeight() + 0.5f) : 0) - offset.y; } - + return commands; } @@ -534,7 +538,6 @@ std::vector Font::generateVertices(const std::string &text, s std::vector Font::generateVerticesFormatted(const ColoredCodepoints &text, float wrap, AlignMode align, std::vector &vertices, TextInfo *info) { - wrap = std::max(wrap, 0.0f); uint32 cacheid = textureCacheID; @@ -733,6 +736,10 @@ int Font::getWidth(const std::string &str) { uint32 c = *i++; + // Ignore carriage returns + if (c == '\r') + continue; + const Glyph &g = findGlyph(c); width += g.spacing + getKerning(prevglyph, c); @@ -813,6 +820,13 @@ void Font::getWrap(const ColoredCodepoints &codepoints, float wraplimit, std::ve continue; } + // Ignore carriage returns + if (c == '\r') + { + i++; + continue; + } + const Glyph &g = findGlyph(c); float charwidth = g.spacing + getKerning(prevglyph, c); float newwidth = width + charwidth;