From 009faa1e37c91d4c4a4378379554563d51dddae5 Mon Sep 17 00:00:00 2001 From: Ruben Dashyan Date: Wed, 29 Jan 2020 14:43:35 +0100 Subject: [PATCH] [kandinsky/font] Factor indexForCodePoint default return value --- kandinsky/src/font.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kandinsky/src/font.cpp b/kandinsky/src/font.cpp index 80d3b9896..ee4bae624 100644 --- a/kandinsky/src/font.cpp +++ b/kandinsky/src/font.cpp @@ -136,16 +136,16 @@ KDFont::GlyphIndex KDFont::indexForCodePoint(CodePoint c) const { } #else const CodePointIndexPair * currentPair = m_table; - if (c < currentPair->codePoint()) { - return defaultIndex; - } const CodePointIndexPair * endPair = m_table + m_tableLength - 1; + if (c < currentPair->codePoint()) { + goto NoMatchingGlyph; + } while (currentPair < endPair) { const CodePointIndexPair * nextPair = currentPair + 1; if (c < nextPair->codePoint()) { CodePoint lastCodePointOfCurrentPair = currentPair->codePoint() + (nextPair->glyphIndex() - currentPair->glyphIndex() - 1); if (c > lastCodePointOfCurrentPair) { - return defaultIndex; + goto NoMatchingGlyph; } return currentPair->glyphIndex() + (c - currentPair->codePoint()); } @@ -154,6 +154,7 @@ KDFont::GlyphIndex KDFont::indexForCodePoint(CodePoint c) const { if (endPair->codePoint() == c) { return endPair->glyphIndex(); } + NoMatchingGlyph: return defaultIndex; #endif }