30 FontFace(
void *buf,
size_t buf_size,
FontFaceDisposingFunction disp_fn, u32 font_sz,
void *font_class_ptr) : font(
nullptr), ptr(buf), ptr_sz(buf_size), dispose_fn(disp_fn)
32 this->font =
TTF_OpenFontRW(SDL_RWFromMem(this->ptr, this->ptr_sz), 1, font_sz);
38 inline bool IsSourceValid()
41 if(this->ptr !=
nullptr)
43 if(this->ptr_sz > 0)
return true;
50 if(this->font !=
nullptr)
60 if(this->IsSourceValid())
62 (this->dispose_fn)(this->ptr);
70 std::vector<std::pair<i32, std::unique_ptr<FontFace>>> font_faces;
92 return this->font_size;
Definition: ttf_Font.hpp:9
Definition: pu_String.hpp:21
Definition: ui_Types.hpp:24
DECLSPEC void SDLCALL TTF_CloseFont(TTF_Font *font)
i32 LoadFromMemory(void *ptr, size_t size, FontFaceDisposingFunction disp_fn)
SDL_Texture * RenderText(String str, ui::Color color)
Definition: ttf_Font.hpp:18
s32 i32
Definition: pu_Macros.hpp:17
void EmptyFontFaceDisposingFunction(void *)
Definition: ttf_Font.hpp:13
sdl2::Font FindValidFontFor(char16_t ch)
void Unload(i32 font_idx)
i32 LoadFromFile(String path)
std::function< void(void *)> FontFaceDisposingFunction
Definition: ttf_Font.hpp:11
static constexpr i32 InvalidFontFaceIndex
Definition: ttf_Font.hpp:75
u32 GetFontSize()
Definition: ttf_Font.hpp:90
NX_CONSTEXPR bool IsValidFontFaceIndex(i32 index)
Definition: ttf_Font.hpp:78
void TTF_CppWrap_SetCppPtrRef(TTF_Font *font, void *cpp_ptr_ref)
DECLSPEC TTF_Font *SDLCALL TTF_OpenFontRW(SDL_RWops *src, int freesrc, int ptsize)
std::pair< u32, u32 > GetTextDimensions(String str)
static constexpr u32 DefaultFontSize
Definition: ttf_Font.hpp:76
TTF_Font * Font
Definition: sdl2_Types.hpp:14