openMSX
|
#include <TTFFont.hh>
Public Member Functions | |
TTFFont (const TTFFont &)=delete | |
TTFFont & | operator= (const TTFFont &)=delete |
TTFFont ()=default | |
Construct an empty font. | |
TTFFont (const std::string &filename, int ptSize) | |
Construct new TTFFont object. | |
TTFFont (TTFFont &&other) noexcept | |
Move construct. | |
TTFFont & | operator= (TTFFont &&other) noexcept |
Move assignment. | |
~TTFFont () | |
bool | empty () const |
Is this an empty font? (a default constructed object). | |
SDLSurfacePtr | render (std::string text, uint8_t r, uint8_t g, uint8_t b) const |
Render the given text to a new SDL_Surface. | |
int | getHeight () const |
Return the height of the font. | |
bool | isFixedWidth () const |
Returns true iff this is a fixed-with (=mono-spaced) font. | |
int | getWidth () const |
Return the width of the font. | |
gl::ivec2 | getSize (zstring_view text) const |
Return the size in pixels of the text if it would be rendered. | |
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 142 of file TTFFont.cc.
|
inlinenoexcept |
Move construct.
Definition at line 35 of file TTFFont.hh.
openmsx::TTFFont::~TTFFont | ( | ) |
Definition at line 147 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 237 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 260 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 247 of file TTFFont.cc.
bool openmsx::TTFFont::isFixedWidth | ( | ) | const |
Returns true iff this is a fixed-with (=mono-spaced) font.
Definition at line 242 of file TTFFont.cc.
Move assignment.
Definition at line 42 of file TTFFont.hh.
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 153 of file TTFFont.cc.
References g, SDLSurfacePtr::get(), getHeight(), getSize(), StringOp::split_view(), and StringOp::trimRight().