-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
104bdf0
commit 32522d0
Showing
8 changed files
with
312 additions
and
655 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
|
||
#include <Utily/Utily.hpp> | ||
|
||
#include "Media/Image.hpp" | ||
#include "Model/Static.hpp" | ||
#include <array> | ||
#include <glm/vec2.hpp> | ||
#include <limits> | ||
#include <ranges> | ||
#include <utility> | ||
|
||
namespace Media { | ||
|
||
class FontAtlas | ||
{ | ||
public: | ||
/// @brief Load .ttf font from disk. Generate a font-atlas image. Can fail. | ||
[[nodiscard]] static auto create(std::filesystem::path path, uint32_t char_height_px) noexcept -> Utily::Result<FontAtlas, Utily::Error>; | ||
|
||
FontAtlas(FontAtlas&& other) | ||
: _m(std::move(other._m)) { } | ||
|
||
struct UvCoord { | ||
float min_x; | ||
float max_x; | ||
float min_y; | ||
float max_y; | ||
}; | ||
[[nodiscard]] auto uv_for(char a) const noexcept -> FontAtlas::UvCoord; | ||
|
||
[[nodiscard]] auto atlas_image() const noexcept -> const Media::Image& { return _m.atlas_image; } | ||
[[nodiscard]] auto atlas_layout() const noexcept { return _m.atlas_layout; } | ||
[[nodiscard]] auto glyph_dimensions() const noexcept { return _m.glyph_dimensions; } | ||
|
||
private: | ||
struct M { | ||
Media::Image atlas_image; | ||
glm::vec2 atlas_layout; | ||
glm::vec2 glyph_dimensions; | ||
} _m; | ||
|
||
explicit FontAtlas(M&& m) | ||
: _m(std::move(m)) { } | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#pragma once | ||
|
||
#include "Media/Image.hpp" | ||
#include "Media/Font.hpp" | ||
#include "Media/FontAtlas.hpp" | ||
#include "Media/Sound.hpp" |
Oops, something went wrong.