~aleteoryx/muditaos

d783c5c89a8c8cddaa71bb16f23aa2e93b17bfa9 — Lukasz Mastalerz 2 years ago 35fb50f
[CP-1938] UI issues when uploading multiple copies of a specific file

Fixed problem with badly calculating characters to show which cause a
problem with displaying text on UI.
2 files changed, 6 insertions(+), 5 deletions(-)

M harmony_changelog.md
M module-gui/gui/core/RawFont.cpp
M harmony_changelog.md => harmony_changelog.md +1 -0
@@ 13,6 13,7 @@
* Fixed problem with long Relaxation loading when titles were too long
* Fixed backlight behavior after returning to the main window
* Fixed settings frontlight intensity in on demand mode
* Fixed problem that UI could be occasionally broken

### Added


M module-gui/gui/core/RawFont.cpp => module-gui/gui/core/RawFont.cpp +5 -5
@@ 114,17 114,17 @@ namespace gui
    std::uint32_t RawFont::getCharCountInSpace(const UTF8 &str, const std::uint32_t space) const
    {
        std::uint32_t availableSpace = space;
        std::uint32_t textSpace      = 0;
        std::uint32_t count          = 0;
        std::uint32_t current        = 0;
        std::uint32_t previous       = none_char_id;

        for (std::uint32_t i = 0; i < str.length(); ++i, ++count) {
            current               = str[i];
            const auto char_pixel_width = getCharPixelWidth(current, previous);
            if (availableSpace < char_pixel_width) {
                return count;
            current = str[i];
            textSpace += getCharPixelWidth(current, previous);
            if (availableSpace < textSpace) {
                return count - 1;
            }
            availableSpace -= char_pixel_width;
            previous = current;
        }
        return count;