1 #ifndef INCLUDE_AL_FONT_HPP
2 #define INCLUDE_AL_FONT_HPP
49 #include "al/graphics/al_Graphics.hpp"
50 #include "al/graphics/al_Mesh.hpp"
51 #include "al/graphics/al_Texture.hpp"
64 float alignFactorX = 0.0f;
70 Font &operator=(
const Font &) =
delete;
74 Font &operator=(
Font &&other) noexcept;
83 bool load(
const char *filename,
int fontSize,
int bitmapSize);
102 void write(
Mesh &mesh,
const char *text,
float worldHeight);
128 void alignCenter() { alignFactorX = -0.5f; }
129 void alignRight() { alignFactorX = -1.0f; }
131 static std::string defaultFont();
141 void write(
const char *text,
float worldHeight = 1.0f) {
145 static void render(
Graphics &g,
const char *text,
Vec3d position,
146 float worldHeight = 1.0,
int fontSize = 24,
147 const char *filename = Font::defaultFont().c_str(),
148 int bitmapSize = 1024) {
149 static std::map<std::string, FontRenderer> renderers;
150 if (renderers.find(std::string(filename)) == renderers.end()) {
152 renderers[filename].load(filename, fontSize, bitmapSize);
157 renderer.write(text, worldHeight);
158 renderer.renderAt(g, position);
Interface for loading fonts and rendering text.
void blending(bool doBlend)
Turn blending on/off.
void blendTrans()
Set blend mode to transparent (asymmetric)
Stores buffers related to rendering graphical objects.
void translate(float x, float y, float z=0.)
Translate current matrix.
void popMatrix()
Pop current matrix stack.
void pushMatrix()
Push current matrix stack.
void unbind(int binding_point=0)
Unbind the texture (from a multitexture unit)
void bind(int binding_point=0)
Interface for loading fonts and rendering text.
void write(Mesh &mesh, const char *text, float worldHeight)
void alignLeft()
Returns the width of a text string, in pixels.
bool load(const char *filename, int fontSize, int bitmapSize)
Convenience class to simplify rendering text.