| 1 |
#ifndef TTFFONT_HH |
| 2 |
#define TTFFONT_HH |
| 3 |
|
| 4 |
#include "SDLSurfacePtr.hh" |
| 5 |
#include "gl_vec.hh" |
| 6 |
#include "zstring_view.hh" |
| 7 |
#include <cstdint> |
| 8 |
#include <string> |
| 9 |
#include <utility> |
| 10 |
|
| 11 |
namespace openmsx { |
| 12 |
|
| 13 |
class TTFFont |
| 14 |
{ |
| 15 |
public: |
| 16 |
TTFFont(const TTFFont&) = delete; |
| 17 |
TTFFont& operator=(const TTFFont&) = delete; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
TTFFont() = default; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
TTFFont(const std::string& filename, int ptSize, int faceIndex); |
| 34 |
|
| 35 |
|
| 36 |
TTFFont(TTFFont&& other) noexcept |
| 37 |
: font(other.font) |
| 38 |
{ |
| 39 |
other.font = nullptr; |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
TTFFont& operator=(TTFFont&& other) noexcept |
| 44 |
{ |
| 45 |
std::swap(font, other.font); |
| 46 |
return *this; |
| 47 |
} |
| 48 |
|
| 49 |
~TTFFont(); |
| 50 |
|
| 51 |
|
| 52 |
[[nodiscard]] bool empty() const { return font == nullptr; } |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
[[nodiscard]] SDLSurfacePtr render(std::string text, uint8_t r, uint8_t g, uint8_t b) const; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
[[nodiscard]] int getHeight() const; |
| 64 |
|
| 65 |
|
| 66 |
[[nodiscard]] bool isFixedWidth() const; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
[[nodiscard]] int getWidth() const; |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
[[nodiscard]] gl::ivec2 getSize(zstring_view text) const; |
| 77 |
|
| 78 |
private: |
| 79 |
void* font = nullptr; |
| 80 |
}; |
| 81 |
|
| 82 |
} |
| 83 |
|
| 84 |
#endif |