openMSX
|
#include <TTFFont.hh>
Public Member Functions | |
TTFFont (const TTFFont &)=delete | |
TTFFont & | operator= (const TTFFont &)=delete |
TTFFont ()=default | |
Construct an empty font. More... | |
TTFFont (const std::string &filename, int ptSize) | |
Construct new TTFFont object. More... | |
TTFFont (TTFFont &&other) noexcept | |
Move construct. More... | |
TTFFont & | operator= (TTFFont &&other) noexcept |
Move assignment. More... | |
~TTFFont () | |
bool | empty () const |
Is this an empty font? (a default constructed object). More... | |
SDLSurfacePtr | render (std::string text, uint8_t r, uint8_t g, uint8_t b) const |
Render the given text to a new SDL_Surface. More... | |
int | getHeight () const |
Return the height of the font. More... | |
bool | isFixedWidth () const |
Returns true iff this is a fixed-with (=mono-spaced) font. More... | |
int | getWidth () const |
Return the width of the font. More... | |
gl::ivec2 | getSize (zstring_view text) const |
Return the size in pixels of the text if it would be rendered. More... | |
Definition at line 13 of file TTFFont.hh.
|
delete |
|
default |
Construct an empty font.
The only valid operations on empty font objects are:
openmsx::TTFFont::TTFFont | ( | const std::string & | filename, |
int | ptSize | ||
) |
Construct new TTFFont object.
filename | Filename of font (.fft file, possibly (g)zipped). |
ptSize | Point size (based on 72DPI) to load font as. post-condition: !empty() |
Definition at line 138 of file TTFFont.cc.
|
inlinenoexcept |
Move construct.
Definition at line 35 of file TTFFont.hh.
openmsx::TTFFont::~TTFFont | ( | ) |
Definition at line 143 of file TTFFont.cc.
References openmsx::TTFFontPool::instance(), and openmsx::TTFFontPool::release().
|
inline |
Is this an empty font? (a default constructed object).
Definition at line 51 of file TTFFont.hh.
int openmsx::TTFFont::getHeight | ( | ) | const |
Return the height of the font.
This is the recommended number of pixels between two text lines.
Definition at line 233 of file TTFFont.cc.
Referenced by render().
gl::ivec2 openmsx::TTFFont::getSize | ( | zstring_view | text | ) | const |
Return the size in pixels of the text if it would be rendered.
Definition at line 256 of file TTFFont.cc.
References zstring_view::c_str().
Referenced by render().
int openmsx::TTFFont::getWidth | ( | ) | const |
Return the width of the font.
This is the recommended number of pixels between two characters. This number only makes sense for fixed-width fonts.
Definition at line 243 of file TTFFont.cc.
References utf8::advance().
bool openmsx::TTFFont::isFixedWidth | ( | ) | const |
Returns true iff this is a fixed-with (=mono-spaced) font.
Definition at line 238 of file TTFFont.cc.
SDLSurfacePtr openmsx::TTFFont::render | ( | std::string | text, |
uint8_t | r, | ||
uint8_t | g, | ||
uint8_t | b | ||
) | const |
Render the given text to a new SDL_Surface.
The text must be UTF-8 encoded. The result is a 32bpp RGBA SDL_Surface.
Definition at line 149 of file TTFFont.cc.
References g, SDLSurfacePtr::get(), getHeight(), getSize(), gl::max(), StringOp::split_view(), and StringOp::trimRight().