1 #ifndef RAYLIB_CPP_INCLUDE_FONT_HPP_
2 #define RAYLIB_CPP_INCLUDE_FONT_HPP_
6 #include "./raylib.hpp"
7 #include "./raylib-cpp-utils.hpp"
8 #include "./RaylibException.hpp"
21 ::GlyphInfo *glyphs =
nullptr) :
::Font{baseSize, glyphCount, glyphPadding, texture, recs, glyphs} {
26 set(::GetFontDefault());
29 Font(const ::Font& font) {
40 Font(
const std::string& fileName) {
41 if (!
Load(fileName)) {
55 Font(
const std::string& fileName,
int fontSize,
int* fontChars,
int charCount) {
56 if (!
Load(fileName, fontSize, fontChars, charCount)) {
70 Font(const ::Image& image, ::
Color key,
int firstChar) {
71 if (!
Load(image, key, firstChar)) {
83 Font(
const std::string& fileType,
const unsigned char* fileData,
int dataSize,
int fontSize,
84 int *fontChars,
int charsCount) {
85 if (!
Load(fileType, fileData, dataSize, fontSize, fontChars, charsCount)) {
97 other.glyphPadding = 0;
100 other.glyphs =
nullptr;
111 GETTERSETTER(
int, BaseSize, baseSize)
112 GETTERSETTER(
int, GlyphCount, glyphCount)
113 GETTERSETTER(
int, GlyphPadding, glyphPadding)
116 GETTERSETTER(::GlyphInfo*, Glyphs, glyphs)
118 Font& operator=(const ::
Font& font) {
123 Font& operator=(
const Font&) =
delete;
126 if (
this == &other) {
134 other.glyphCount = 0;
135 other.glyphPadding = 0;
137 other.recs =
nullptr;
138 other.glyphs =
nullptr;
152 bool Load(
const std::string& fileName) {
153 set(::LoadFont(fileName.c_str()));
167 bool Load(
const std::string& fileName,
int fontSize,
int* fontChars,
int charCount) {
168 set(::LoadFontEx(fileName.c_str(), fontSize, fontChars, charCount));
172 bool Load(const ::Image& image, ::
Color key,
int firstChar) {
173 set(::LoadFontFromImage(image, key, firstChar));
177 bool Load(
const std::string& fileType,
const unsigned char* fileData,
int dataSize,
int fontSize,
178 int *fontChars,
int charsCount) {
179 set(::LoadFontFromMemory(fileType.c_str(), fileData, dataSize, fontSize, fontChars,
188 float spacing, ::
Color tint = WHITE) {
189 ::DrawTextEx(*
this, text.c_str(), position, fontSize, spacing, tint);
194 const std::string& text,
200 ::
Color tint = WHITE) {
201 ::DrawTextPro(*
this, text.c_str(), position, origin, rotation, fontSize, spacing, tint);
211 ::
Color tint = { 255, 255, 255, 255 }) {
212 ::DrawTextCodepoint(*
this, codepoint, position, fontSize, tint);
220 return ::MeasureTextEx(*
this, text.c_str(), fontSize, spacing);
227 return ::GetGlyphIndex(*
this, character);
233 inline ::Image
ImageText(
const std::string& text,
float fontSize,
234 float spacing, ::
Color tint)
const {
235 return ::ImageTextEx(*
this, text.c_str(), fontSize, spacing, tint);
239 void set(const ::Font& font) {
240 baseSize = font.baseSize;
241 glyphCount = font.glyphCount;
242 glyphPadding = font.glyphPadding;
243 texture = font.texture;
245 glyphs = font.glyphs;
250 #endif // RAYLIB_CPP_INCLUDE_FONT_HPP_