~aleteoryx/muditaos

ref: sign_test muditaos/module-gui/gui/core/FontInfo.cpp -rw-r--r-- 2.1 KiB
a217eeb3 — Dawid Wojtas [BH-2024] Fix lack of alarm directory after updating software 1 year, 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "FontInfo.hpp"
#include "Common.hpp" // for Status, Status::GUI_SUCCESS
#include <cstring>    // for memcpy

namespace gui
{
    gui::Status FontInfo::load(uint8_t *data, uint32_t &offset)
    {

        // read up to 63 chars of the fonts name
        char name[64] = {0};
        memcpy(name, data + offset, 63);
        offset += 64;
        face = std::string(name);

        // size of the true type font
        memcpy(&size, data + offset, sizeof(uint16_t));
        offset += sizeof(uint16_t);
        // flag that informs if font is bold
        memcpy(&bold, data + offset, sizeof(uint16_t));
        offset += sizeof(uint16_t);
        // flag that informs if font is italic
        memcpy(&italic, data + offset, sizeof(uint16_t));
        offset += sizeof(uint16_t);
        // flag that informs if smoothing was turned on. 1 - smoothing was turned on.
        memcpy(&smooth, data + offset, sizeof(uint16_t));
        offset += sizeof(uint16_t);
        // TODO additional space between characters????
        memcpy(&char_spacing, data + offset, sizeof(int16_t));
        offset += sizeof(int16_t);
        // TODO additional space between lines
        memcpy(&line_spacing, data + offset, sizeof(int16_t));
        offset += sizeof(int16_t);
        // distance in pixels between each line of text
        memcpy(&line_height, data + offset, sizeof(uint16_t));
        offset += sizeof(uint16_t);
        // number of pixels from the absolute top of the line to the base of the characters
        memcpy(&base, data + offset, sizeof(uint16_t));
        offset += sizeof(uint16_t);
        // width of the texture, normally used to scale the x pos of the character image
        memcpy(&scale_w, data + offset, sizeof(uint16_t));
        offset += sizeof(uint16_t);
        // height of the texture, normally used to scale the y pos of the character image
        memcpy(&scale_h, data + offset, sizeof(uint16_t));
        offset += sizeof(uint16_t);

        return gui::Status::GUI_SUCCESS;
    }
} // namespace gui