From aae7b583d7cfa5f7a1aba56e40fdff3a012977f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 12 Apr 2025 02:07:46 +0200 Subject: [PATCH] Text: this bool was just overcomplicating what was available elsewhere. --- src/Magnum/Text/Renderer.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Magnum/Text/Renderer.cpp b/src/Magnum/Text/Renderer.cpp index 1dad33a13..36685b698 100644 --- a/src/Magnum/Text/Renderer.cpp +++ b/src/Magnum/Text/Renderer.cpp @@ -544,11 +544,11 @@ RendererCore& RendererCore::add(AbstractShaper& shaper, const Float size, const Containers::StringView line = text.slice(begin, end); while(line) { + /* Find the next newline. The text to shape is until lineEnd.begin(), + the next line (if any) starts at lineEnd.end(). If lineEnd is empty, + we reached the end of the input text -- it's *not* an end of the + line, because the next add() call may continue with it. */ const Containers::StringView lineEnd = line.findOr('\n', line.end()); - /* Comparing like this to avoid an unnecessary memcmp(). If we reach - the end of the input text, it's *not* an end of the line, because - the next add() call may continue with it. */ - const bool isEndOfLine = lineEnd.size() == 1 && lineEnd[0] == '\n'; /* If the line is not empty and produced some glyphs, render them */ if(const UnsignedInt glyphCount = lineEnd.begin() != line.begin() ? shaper.shape(text, line.begin() - text.begin(), lineEnd.begin() - text.begin(), features) : 0) { @@ -619,7 +619,7 @@ RendererCore& RendererCore::add(AbstractShaper& shaper, const Float size, const ShapeDirection::Unspecified as well. In such case it likely returns ShapeDirection::Unspecified too. */ const ShapeDirection shapeDirection = shaper.direction(); - if(shapeDirection != ShapeDirection::Unspecified || isEndOfLine) + if(shapeDirection != ShapeDirection::Unspecified || lineEnd) state.resolvedAlignment = alignmentForDirection( state.alignment, state.layoutDirection, @@ -630,7 +630,7 @@ RendererCore& RendererCore::add(AbstractShaper& shaper, const Float size, const independently of whether any glyphs were processed in this iteration, as add() can be called with a string that starts with a \n, for example. */ - if(isEndOfLine) { + if(lineEnd) { /* If there are any glyphs on the current line, either added right above or being there from the previous add() call, align them. If alignment based on bounds is requested, calculate a special