5 #include <rag/Platform.h>
7 #define STBTT_malloc(x,u) malloc(x)
8 #define STBTT_free(x,u) free(x)
10 #include "external/stb_truetype.h"
13 #include <glm/glm.hpp>
23 TTFFont(
const std::string& path,
float pixelHeight = 24);
26 static void addFontAlias(
const std::string& alias,
const std::string& fontPath);
28 virtual int getWidth(
const std::string& text);
29 virtual void print(
const std::string& text,
const glm::mat4& matrix);
36 void getBakedQuad(
int char_index,
float *xpos,
float *ypos, stbtt_aligned_quad *q);
39 int bakeFontBitmap(
int first_char,
bool uploadTexture =
true);
46 std::map<int, stbtt_bakedchar> chardata;
47 float pixelHeight, scale;
50 unsigned char* buffer;
51 int ascent, descent, lineGap;
60 static std::map<std::string, std::string> fontsAlias;
virtual int getWidth(const std::string &text)
Returns the width of a text.
Definition: TTFFont.cpp:78
virtual void setLetterSpacing(float value)
Sets the extra space between characters.
Definition: TTFFont.cpp:153
static void addFontAlias(const std::string &alias, const std::string &fontPath)
Allows to use a different name (or an 'alias') to refer to a font.
Definition: TTFFont.cpp:16
virtual void print(const std::string &text, const glm::mat4 &matrix)
Renders text. Asumes ortho projection 1:1 screen pixel.
Definition: TTFFont.cpp:96
virtual void reloadTexture()
On context loss, reload textures. ITextFont should inherit Resource. Reload should be part of resour...
Definition: TTFFont.cpp:264
TTFFont(const std::string &path, float pixelHeight=24)
Constructs a TTFFont using a path and a text size.
Definition: TTFFont.cpp:21
Interface for text fonts.
Definition: ITextFont.h:10
Implementation of ITextFint based on TrueType or OpenType Fonts.
Definition: TTFFont.h:18