mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-12 07:03:34 +00:00
begenning the refactor
This commit is contained in:
53
runtime/Includes/Renderer/Texts/Font.h
git.filemode.normal_file
53
runtime/Includes/Renderer/Texts/Font.h
git.filemode.normal_file
@@ -0,0 +1,53 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* font.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/11 21:17:04 by kbz_8 #+# #+# */
|
||||
/* Updated: 2024/03/25 19:08:21 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef __MLX_FONT__
|
||||
#define __MLX_FONT__
|
||||
|
||||
#include <renderer/images/texture_atlas.h>
|
||||
#include <utils/combine_hash.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class Font
|
||||
{
|
||||
friend class FontLibrary;
|
||||
public:
|
||||
Font() = delete;
|
||||
Font(class Renderer& renderer, const std::filesystem::path& path, float scale);
|
||||
Font(class Renderer& renderer, const std::string& name, const std::vector<std::uint8_t>& ttf_data, float scale);
|
||||
|
||||
inline const std::string& getName() const { return _name; }
|
||||
inline float getScale() const noexcept { return _scale; }
|
||||
inline const std::array<stbtt_packedchar, 96>& getCharData() const { return _cdata; }
|
||||
inline const TextureAtlas& getAtlas() const noexcept { return _atlas; }
|
||||
inline bool operator==(const Font& rhs) const { return rhs._name == _name && rhs._scale == _scale; }
|
||||
inline bool operator!=(const Font& rhs) const { return rhs._name != _name || rhs._scale != _scale; }
|
||||
void destroy();
|
||||
|
||||
~Font();
|
||||
|
||||
private:
|
||||
void buildFont();
|
||||
|
||||
private:
|
||||
std::array<stbtt_packedchar, 96> _cdata;
|
||||
TextureAtlas _atlas;
|
||||
std::variant<std::filesystem::path, std::vector<std::uint8_t>> _build_data;
|
||||
std::string _name;
|
||||
class Renderer& _renderer;
|
||||
float _scale = 0;
|
||||
bool _is_init = false;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user