diff --git a/lib/EpdFont/EpdFont.cpp b/lib/EpdFont/EpdFont.cpp index 6d777a3e..0b89806a 100644 --- a/lib/EpdFont/EpdFont.cpp +++ b/lib/EpdFont/EpdFont.cpp @@ -25,11 +25,6 @@ void EpdFont::getTextBounds(const char* string, const int startX, const int star uint32_t cp; while ((cp = utf8NextCodepoint(reinterpret_cast(&string)))) { const EpdGlyph* glyph = getGlyph(cp); - - if (!glyph) { - glyph = getGlyph(REPLACEMENT_GLYPH); - } - if (!glyph) { // TODO: Better handle this? continue; @@ -95,6 +90,8 @@ const EpdGlyph* EpdFont::getGlyph(const uint32_t cp) const { return &data->glyph[interval->offset + (cp - interval->first)]; } } - + if (cp != REPLACEMENT_GLYPH) { + return getGlyph(REPLACEMENT_GLYPH); + } return nullptr; } diff --git a/lib/GfxRenderer/GfxRenderer.cpp b/lib/GfxRenderer/GfxRenderer.cpp index 02ce8362..7c03faf3 100644 --- a/lib/GfxRenderer/GfxRenderer.cpp +++ b/lib/GfxRenderer/GfxRenderer.cpp @@ -68,10 +68,6 @@ static void renderCharImpl(const GfxRenderer& renderer, GfxRenderer::RenderMode const EpdFontFamily& fontFamily, const uint32_t cp, int* cursorX, int* cursorY, const bool pixelState, const EpdFontFamily::Style style) { const EpdGlyph* glyph = fontFamily.getGlyph(cp, style); - if (!glyph) { - glyph = fontFamily.getGlyph(REPLACEMENT_GLYPH, style); - } - if (!glyph) { LOG_ERR("GFX", "No glyph for codepoint %d", cp); return; @@ -237,10 +233,6 @@ void GfxRenderer::drawText(const int fontId, const int x, const int y, const cha while ((cp = utf8NextCodepoint(reinterpret_cast(&text)))) { if (utf8IsCombiningMark(cp) && hasBaseGlyph) { const EpdGlyph* combiningGlyph = font.getGlyph(cp, style); - if (!combiningGlyph) { - combiningGlyph = font.getGlyph(REPLACEMENT_GLYPH, style); - } - int raiseBy = 0; if (combiningGlyph) { const int currentGap = combiningGlyph->top - combiningGlyph->height - lastBaseTop; @@ -256,10 +248,6 @@ void GfxRenderer::drawText(const int fontId, const int x, const int y, const cha } const EpdGlyph* glyph = font.getGlyph(cp, style); - if (!glyph) { - glyph = font.getGlyph(REPLACEMENT_GLYPH, style); - } - if (!utf8IsCombiningMark(cp)) { lastBaseX = xpos; lastBaseY = yPos; @@ -909,7 +897,6 @@ int GfxRenderer::getTextAdvanceX(const int fontId, const char* text, const EpdFo continue; } const EpdGlyph* glyph = font.getGlyph(cp, style); - if (!glyph) glyph = font.getGlyph(REPLACEMENT_GLYPH, style); if (glyph) width += glyph->advanceX; } return width; @@ -972,10 +959,6 @@ void GfxRenderer::drawTextRotated90CW(const int fontId, const int x, const int y while ((cp = utf8NextCodepoint(reinterpret_cast(&text)))) { if (utf8IsCombiningMark(cp) && hasBaseGlyph) { const EpdGlyph* combiningGlyph = font.getGlyph(cp, style); - if (!combiningGlyph) { - combiningGlyph = font.getGlyph(REPLACEMENT_GLYPH, style); - } - int raiseBy = 0; if (combiningGlyph) { const int currentGap = combiningGlyph->top - combiningGlyph->height - lastBaseTop; @@ -991,10 +974,6 @@ void GfxRenderer::drawTextRotated90CW(const int fontId, const int x, const int y } const EpdGlyph* glyph = font.getGlyph(cp, style); - if (!glyph) { - glyph = font.getGlyph(REPLACEMENT_GLYPH, style); - } - if (!utf8IsCombiningMark(cp)) { lastBaseX = xPos; lastBaseY = yPos;