engine/include/resources/font.hpp

41 lines
615 B
C++
Raw Normal View History

2022-09-02 11:06:59 +00:00
#pragma once
2022-09-07 09:02:01 +00:00
#include "engine_api.h"
2022-09-02 23:02:09 +00:00
2022-09-02 11:06:59 +00:00
#include "resource.hpp"
2022-11-23 16:20:08 +00:00
#include "gfx.hpp"
2022-09-02 11:06:59 +00:00
#include <glm/vec2.hpp>
#include <map>
2022-10-06 10:30:44 +00:00
namespace engine::resources {
2022-09-02 11:06:59 +00:00
2022-09-03 04:56:51 +00:00
class ENGINE_API Font : public Resource {
2022-09-02 11:06:59 +00:00
public:
Font(const std::filesystem::path& resPath);
~Font() override;
2022-11-28 09:39:00 +00:00
struct CharData {
glm::vec2 atlas_top_left{};
glm::vec2 atlas_bottom_right{};
2022-11-28 15:02:08 +00:00
glm::vec2 char_top_left{};
glm::vec2 char_bottom_right{};
2022-11-28 09:39:00 +00:00
float xAdvance{};
};
2022-11-27 14:35:41 +00:00
const gfx::Texture* getAtlasTexture();
2022-11-28 09:39:00 +00:00
CharData getCharData(uint32_t charCode);
2022-11-27 14:35:41 +00:00
private:
const gfx::Texture* m_atlas;
2022-11-28 09:39:00 +00:00
std::map<uint32_t, CharData> m_charData;
2022-09-02 11:06:59 +00:00
};
}