BLT-With-Graphics-Template/include/blt/gfx/renderer/font_renderer.h

69 lines
2.0 KiB
C
Raw Normal View History

2024-11-11 02:29:28 -05:00
#pragma once
/*
* Copyright (C) 2024 Brett Terpstra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef BLT_WITH_GRAPHICS_FONT_RENDERER_H
#define BLT_WITH_GRAPHICS_FONT_RENDERER_H
#include <blt/gfx/font/font.h>
2024-11-11 16:47:25 -05:00
#include <blt/gfx/texture.h>
#include <blt/std/hashmap.h>
#include <blt/std/binary_tree.h>
2024-11-11 02:29:28 -05:00
namespace blt::gfx
{
2024-11-11 16:47:25 -05:00
class font_texture_atlas : public texture_gl2D
{
public:
struct bounded_t
{
font::glyph_t glyph;
blt::vec2ui min;
blt::vec2ui max;
};
explicit font_texture_atlas(blt::i32 dimensions);
blt::u64 add_font(const font::font_file_t& file);
blt::u64 add_font(const font::font_file_t& file, blt::u64 start);
bounded_t& get_glyph(blt::u64 c)
{ return glyphs.at(c); }
[[nodiscard]] const bounded_t& get_glyph(blt::u64 c) const
{ return glyphs.at(c); }
private:
blt::hashmap_t<blt::u64, bounded_t> glyphs;
blt::u32 used_width = 0;
blt::u32 used_height = 0;
};
2024-11-11 02:29:28 -05:00
class font_renderer_t
{
public:
2024-11-11 16:47:25 -05:00
explicit font_renderer_t(const std::vector<font::font_file_t>& files, blt::i32 dimensions = 4096);
2024-11-11 02:29:28 -05:00
private:
};
}
#endif //BLT_WITH_GRAPHICS_FONT_RENDERER_H