Half-baked Font class implementation
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m29s
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m29s
This commit is contained in:
@@ -13,6 +13,7 @@ extern "C" typedef struct FT_LibraryRec_* FT_Library;
|
||||
namespace JGL
|
||||
{
|
||||
|
||||
/// Initializes FreeType engine.
|
||||
bool InitTextEngine();
|
||||
|
||||
/// A Font class implementation.
|
||||
@@ -26,6 +27,10 @@ namespace JGL
|
||||
~Font();
|
||||
static Font LoadTTF(const std::filesystem::path& filepath);
|
||||
static std::vector<Font> GetLoadedFonts();
|
||||
/// Returns the bounding-box the given string would occupy at the given point-size, assuming normal (1) scaling.
|
||||
/// @param text The string to measure.
|
||||
/// @param ptSize The font size at which to measure.
|
||||
/// @return The size-in-pixels that would contain the entire text.
|
||||
Vector2 MeasureString(const std::string& text, float ptSize);
|
||||
public:
|
||||
int index = 0;
|
||||
|
@@ -5,12 +5,17 @@
|
||||
#include <vector>
|
||||
#include <glad/glad.h>
|
||||
|
||||
|
||||
/// TODO: FontCache mechanism works amazing, but makes no fucking sense
|
||||
/// Let's document and reorganize it to be a little nicer on the mental :)
|
||||
|
||||
namespace JGL {
|
||||
class CachedGlyph;
|
||||
class CachedFont;
|
||||
class FontCache;
|
||||
}
|
||||
|
||||
/// Represents a single font-character "glyph", that has been cached in-memory for fast retrieval.
|
||||
class JGL::CachedGlyph {
|
||||
private:
|
||||
char character;
|
||||
@@ -25,6 +30,7 @@ public:
|
||||
const std::array<GLfloat, 12> getTexCoords() const;
|
||||
};
|
||||
|
||||
/// Represents a Font object as it exists in the font-cache.
|
||||
class JGL::CachedFont {
|
||||
private:
|
||||
std::map<char, CachedGlyph*> glyphs;
|
||||
|
@@ -5,6 +5,8 @@
|
||||
#include <freetype2/ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_OUTLINE_H
|
||||
#include "jlog/jlog.hpp"
|
||||
|
||||
#endif
|
||||
#if _WIN32
|
||||
#include <ft2build.h>
|
||||
@@ -41,6 +43,7 @@ namespace JGL {
|
||||
|
||||
//If the font doesn't exist in the cache yet.
|
||||
if (!cachedFont) {
|
||||
DEBUG("Caching font data...");
|
||||
GLuint texture_id;
|
||||
glGenTextures(1, &texture_id);
|
||||
glBindTexture(GL_TEXTURE_2D, texture_id);
|
||||
|
Reference in New Issue
Block a user