diff --git a/cpp/src/monoformat_fontreader.hpp b/cpp/src/monoformat_fontreader.hpp index 5418e0e..020d8be 100644 --- a/cpp/src/monoformat_fontreader.hpp +++ b/cpp/src/monoformat_fontreader.hpp @@ -527,9 +527,10 @@ public: continue; } - // FIXME: newline support if (cp == '\n') { - cp = ' '; + advance.x = 0; + advance.y += m_font.lineHeight(); + continue; } auto dims = renderGlyph(cp, position + advance, m_font, display, fontColor, bgColor); @@ -557,10 +558,11 @@ public: continue; } - // FIXME: newline support - // also FIXME: call ensureAdvance when handling newline if (cp == '\n') { - cp = ' '; + ensureAdvance(boundingBox, advance); + advance.x = 0; + advance.y += m_font.lineHeight(); + continue; } auto dims = computeGlyphDimensions(cp, position + advance, m_font); @@ -627,15 +629,14 @@ private: return std::nullopt; } - // FIXME: once we support multi-line also handle y component - auto bottomRight = a->getBottomRight(); if ((bottomRight.x + 1) < advance.x) { bottomRight.x = advance.x - 1; - return Rectangle::fromCorners(a->topLeft, bottomRight); - } else { - return a; } + if ((bottomRight.y + 1) < advance.y) { + bottomRight.y = advance.y - 1; + } + return Rectangle::fromCorners(a->topLeft, bottomRight); } template