engine/include/resources/font.h

35 lines
866 B
C
Raw Permalink Normal View History

2023-05-14 13:40:16 +00:00
#ifndef ENGINE_INCLUDE_RESOURCES_FONT_H_
#define ENGINE_INCLUDE_RESOURCES_FONT_H_
#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 {
public:
Font(const std::string& path);
~Font();
Font(const Font&) = delete;
Font& operator=(const Font&) = delete;
2023-05-14 21:05:22 +00:00
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
private:
2023-05-14 21:05:22 +00:00
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
};
} // namespace engine
#endif