34 Font(
const std::string &tf);
41 Font(
const std::string &tf,
int size);
64 bool tryLoadFont(
const std::string &fname,
int size);
71 void loadFont(
const std::string &fname,
int size);
77 std::optional<TTF_Font *>
handle()
const {
General-purpose exception class for the mx library.
RAII wrapper around a TTF_Font handle.
bool tryLoadFont(const std::string &fname, int size)
Attempt to load a font, returning false on failure.
Wrapper< TTF_Font * > wrapper() const
Return a Wrapper around the TTF_Font handle.
~Font()
Destructor — closes the TTF_Font if loaded.
Font & operator=(const Font &f)=delete
void loadFont(const std::string &fname, int size)
Load a font, throwing mx::Exception on failure.
Font()=default
Default constructor — font is not loaded.
Font(const Font &f)=delete
std::optional< TTF_Font * > handle() const
Return the underlying TTF_Font as an optional.
TTF_Font * unwrap() const
Unwrap the TTF_Font pointer, throwing on null.
TTF_Font * the_font
Underlying SDL_ttf font handle.
Text()=default
Default constructor.
void setRenderer(SDL_Renderer *renderer)
Set the SDL renderer used for all draw calls.
void printText_Blended(const Font &f, int x, int y, const std::string &text)
Render text with blended (anti-aliased) quality.
SDL_Color color_value
Current text colour.
void setColor(SDL_Color color)
Set the colour used when rendering text.
SDL_Renderer * renderer
Active renderer.
void printText_Solid(const Font &f, int x, int y, const std::string &text)
Render text with solid (no anti-aliasing) blending.
A nullable smart wrapper around a raw pointer.
Tee stream utilities that duplicate output to two sinks simultaneously.
Type-safe nullable pointer wrapper inspired by Rust's Option<T>.