~aleteoryx/muditaos

eef08b0d7cf21355773740e0689e4e6c90a11b3e — Lefucjusz 3 years ago 8d796d8
[MOS-828] Fix 'j' glyph issue in Contacts app

Fix of the issue that email, first name and last
name fields were not able to display strings that
started with 'j'. Nothing was shown in such case.
2 files changed, 12 insertions(+), 33 deletions(-)

M module-gui/gui/core/DrawCommand.cpp
M pure_changelog.md
M module-gui/gui/core/DrawCommand.cpp => module-gui/gui/core/DrawCommand.cpp +11 -33
@@ 1,4 1,4 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "DrawCommand.hpp"


@@ 20,7 20,6 @@
// utils
#include <log/log.hpp>
// module-utils
#include <cmath>
#include <cassert>

#if DEBUG_FONT == 1


@@ 138,22 137,8 @@ namespace gui
            return;
        }

        // get copy of original context using x,y of draw coordinates and original size of the widget
        Context ctxCopy;
        bool copyContext   = false;
        Point widgetOrigin = {0, 0};

        // check if there is a need of making copy of context to use it as background
        if ((areaW == width) && (areaH == height)) {
            widgetOrigin = origin;
        }
        else {
            copyContext = true;
            ctxCopy     = ctx->get(origin.x, origin.y, areaW, areaH);
        }

        // retrieve font used to draw text
        RawFont *font = FontManager::getInstance().getFont(fontID);
        const auto font = FontManager::getInstance().getFont(fontID);

        // draw every sign
        uint32_t idLast = 0, idCurrent = 0;


@@ 161,17 146,18 @@ namespace gui

        for (uint32_t i = 0; i < str.length(); ++i) {
            idCurrent        = str[i]; // id stands for glued together utf-16 with no order bytes (0xFF 0xFE)
            FontGlyph *glyph = font->getGlyph(idCurrent);
            const auto glyph = font->getGlyph(idCurrent);

            const auto xDrawingPosition = origin.x + position.x + glyph->xoffset;
            const auto yDrawingPosition = origin.y + position.y;

            // do not start drawing outside of draw context.
            Context *drawCtx = copyContext ? &ctxCopy : ctx;
            if ((widgetOrigin.x + position.x + glyph->xoffset >= drawCtx->getW()) ||
                (widgetOrigin.x + position.x + glyph->xoffset < 0)) {
                LOG_FATAL("Drawing outside context's X boundary for glyph: %" PRIu32, glyph->id);
            if ((xDrawingPosition >= ctx->getW()) || (xDrawingPosition < 0)) {
                LOG_ERROR("Drawing outside context's X boundary for glyph: %" PRIu32, glyph->id);
                return;
            }
            if ((widgetOrigin.y + position.y >= drawCtx->getH()) || (widgetOrigin.y + position.y < 0)) {
                LOG_FATAL("Drawing outside context's Y boundary for glyph: %" PRIu32, glyph->id);
            if ((yDrawingPosition >= ctx->getH()) || (yDrawingPosition < 0)) {
                LOG_ERROR("Drawing outside context's Y boundary for glyph: %" PRIu32, glyph->id);
                return;
            }



@@ 180,19 166,11 @@ namespace gui
                kernValue = font->getKerning(idLast, idCurrent);
            }

            drawChar(drawCtx,
                     {widgetOrigin.x + position.x + glyph->xoffset + kernValue, widgetOrigin.y + position.y},
                     glyph);
            drawChar(ctx, {xDrawingPosition + kernValue, yDrawingPosition}, glyph);
            position.x += glyph->xadvance + kernValue;

            idLast = idCurrent;
        }

        // if drawing was performed in temporary context
        // reinsert drawCtx into base context
        if (copyContext) {
            ctx->insert(origin.x, origin.y, ctxCopy);
        }
    }

    inline void DrawImage::checkImageSize(Context *ctx, ImageMap *image) const

M pure_changelog.md => pure_changelog.md +1 -0
@@ 13,6 13,7 @@
* Fixed French translation for SIM cards texts
* Fixed crash on music file with invalid tags
* Fixed backspace behavior in text edit
* Fixed text not showing when adding/editing contact if text began with 'j' glyph

### Added