engine/include/resources/font.h

29 lines
648 B
C
Raw Normal View History

2024-03-31 10:11:22 +00:00
#pragma once
2023-05-14 13:40:16 +00:00
#include <string>
2023-05-14 21:05:22 +00:00
#include <map>
#include <vector>
#include <memory>
#include <stb_truetype.h>
2023-05-14 13:40:16 +00:00
namespace engine {
class Font {
2024-03-31 10:11:22 +00:00
public:
Font(const std::string& path);
~Font();
Font(const Font&) = delete;
Font& operator=(const Font&) = delete;
std::unique_ptr<std::vector<uint8_t>> GetTextBitmap(const std::string& text, float height_px, int& width_out, int& height_out);
2023-05-14 13:40:16 +00:00
2024-03-31 10:11:22 +00:00
private:
std::unique_ptr<stbtt_fontinfo> font_info_{};
std::unique_ptr<std::vector<uint8_t>> font_buffer_{};
std::map<int, int> unicode_to_glyph_{};
int GetGlyphIndex(int unicode_codepoint);
};
2023-05-14 13:40:16 +00:00
2024-03-31 10:11:22 +00:00
} // namespace engine