Josh's Graphics Library
Font.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4#include <filesystem>
5#include <J3ML/LinearAlgebra.hpp>
6#include <filesystem>
7#include <iostream>
8
9
11extern "C" typedef struct FT_FaceRec_* FT_Face;
12extern "C" typedef struct FT_LibraryRec_* FT_Library;
13
14namespace JGL
15{
16
18 bool InitTextEngine();
19
22 class Font {
23 public:
25 Font() = default;
26 Font(const std::filesystem::path& path);
28 ~Font();
29 static Font LoadTTF(const std::filesystem::path& filepath);
30 static std::vector<Font> GetLoadedFonts();
35 Vector2 MeasureString(const std::string& text, unsigned int ptSize);
36 public:
37 int index = 0;
39 };
40}
struct FT_FaceRec_ * FT_Face
Defines external C references to FreeType Data Structures.
Definition: Font.h:11
struct FT_LibraryRec_ * FT_Library
Definition: Font.h:12
A Font class implementation.
Definition: Font.h:22
FT_Face face
Definition: Font.h:38
static std::vector< Font > GetLoadedFonts()
Definition: Font.cpp:90
Vector2 MeasureString(const std::string &text, unsigned int ptSize)
Returns the bounding-box the given string would occupy at the given point-size, assuming normal (1) s...
Definition: Font.cpp:100
static Font LoadTTF(const std::filesystem::path &filepath)
Definition: Font.cpp:95
int index
Definition: Font.h:37
~Font()
Destructor handles freeing of the underlying asset handle.
Definition: Font.cpp:85
Font()=default
Default constructor does not initialize any members.
OpenGL Wrapper for rendering 2D & 3D graphics in both a 2D and 3D context.
Definition: JGL.h:31
bool InitTextEngine()
Initializes FreeType engine. Remember to call this during program initialization.
Definition: Font.cpp:58