~aleteoryx/muditaos

muditaos/module-gui/gui/core/FontGlyph.hpp -rw-r--r-- 1.3 KiB
a405cad6Aleteoryx trim readme 6 days 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
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#pragma once

#include "Common.hpp"
#include <cstdint>

using ucode32 = std::uint32_t;

namespace gui
{
    class FontGlyph
    {
      public:
        FontGlyph() = default;
        explicit FontGlyph(const FontGlyph *from);

        virtual ~FontGlyph();

        gui::Status load(std::uint8_t *data, std::uint32_t &offset);
        gui::Status loadImage(std::uint8_t *data, std::uint32_t offset);

        // Character id
        ucode32 id = 0;
        // Offset in glyph data field
        std::uint32_t glyph_offset = 0;
        // Width of the character image in the texture
        std::uint16_t width = 0;
        // Height of the character image in the texture
        std::uint16_t height = 0;
        // How much the current position should be offset when copying the image from the texture to the screen
        std::int16_t xoffset = 0;
        // How much the current position should be offset when copying the image from the texture to the screen
        std::int16_t yoffset = 0;
        // How much the current position should be advanced after drawing the character
        std::uint16_t xadvance = 0;
        // Image data of the glyph
        std::uint8_t *data = nullptr;
    };
} // namespace gui