SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL3pp_ttf.h
1#ifndef SDL3PP_TTF_H_
2#define SDL3PP_TTF_H_
3
4#include "SDL3pp_gpu.h"
5#include "SDL3pp_render.h"
6#include "SDL3pp_surface.h"
7#include "SDL3pp_version.h"
8#include "SDL3pp_video.h"
9
10#if defined(SDL3PP_ENABLE_TTF) || defined(SDL3PP_DOC)
11
12#include <SDL3_ttf/SDL_ttf.h>
13
14namespace SDL {
15
27// Forward decl
28struct Font;
29
31using FontRaw = TTF_Font*;
32
33// Forward decl
34struct FontRef;
35
38{
40
43 : value(value)
44 {
45 }
46
48 constexpr FontParam(std::nullptr_t = nullptr)
49 : value(nullptr)
50 {
51 }
52
54 constexpr explicit operator bool() const { return !!value; }
55
57 constexpr auto operator<=>(const FontParam& other) const = default;
58
60 constexpr operator FontRaw() const { return value; }
61};
62
63// Forward decl
64struct TextEngine;
65
67using TextEngineRaw = TTF_TextEngine*;
68
71{
73
76 : value(value)
77 {
78 }
79
81 constexpr TextEngineParam(std::nullptr_t = nullptr)
82 : value(nullptr)
83 {
84 }
85
87 constexpr explicit operator bool() const { return !!value; }
88
90 constexpr auto operator<=>(const TextEngineParam& other) const = default;
91
93 constexpr operator TextEngineRaw() const { return value; }
94};
95
96// Forward decl
97struct Text;
98
100using TextRaw = TTF_Text*;
101
102// Forward decl
103struct TextRef;
104
107{
109
112 : value(value)
113 {
114 }
115
117 constexpr TextParam(std::nullptr_t = nullptr)
118 : value(nullptr)
119 {
120 }
121
123 constexpr explicit operator bool() const { return !!value; }
124
126 constexpr auto operator<=>(const TextParam& other) const = default;
127
129 constexpr operator TextRaw() const { return value; }
130
132 constexpr auto operator->() { return value; }
133};
134
137{
139
141 constexpr TextConstParam(const TextRaw value)
142 : value(value)
143 {
144 }
145
148 : value(value.value)
149 {
150 }
151
153 constexpr TextConstParam(std::nullptr_t = nullptr)
154 : value(nullptr)
155 {
156 }
157
159 constexpr explicit operator bool() const { return !!value; }
160
162 constexpr auto operator<=>(const TextConstParam& other) const = default;
163
165 constexpr operator const TextRaw() const { return value; }
166
168 constexpr auto operator->() { return value; }
169};
170
171#ifdef SDL3PP_DOC
172
178#define SDL_TTF_MAJOR_VERSION
179
180#define SDL_TTF_MINOR_VERSION
181
182#define SDL_TTF_MICRO_VERSION
183
185
189#define SDL_TTF_VERSION \
190 SDL_VERSIONNUM( \
191 SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_MICRO_VERSION)
192
196#define SDL_TTF_VERSION_ATLEAST(X, Y, Z) \
197 ((SDL_TTF_MAJOR_VERSION >= X) && \
198 (SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION >= Y) && \
199 (SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION > Y || \
200 SDL_TTF_MICRO_VERSION >= Z))
201
202#endif // SDL3PP_DOC
203
204namespace TTF {
205
215inline int Version() { return TTF_Version(); }
216
232inline void Init() { CheckError(TTF_Init()); }
233
254inline void Quit() { TTF_Quit(); }
255
278inline int WasInit() { return TTF_WasInit(); }
279
280} // namespace TTF
281
297inline void GetFreeTypeVersion(int* major, int* minor, int* patch)
298{
299 TTF_GetFreeTypeVersion(major, minor, patch);
300}
301
315inline void GetHarfBuzzVersion(int* major, int* minor, int* patch)
316{
317 TTF_GetHarfBuzzVersion(major, minor, patch);
318}
319
333
334constexpr FontStyleFlags STYLE_NORMAL = TTF_STYLE_NORMAL;
335
336constexpr FontStyleFlags STYLE_BOLD = TTF_STYLE_BOLD;
337
338constexpr FontStyleFlags STYLE_ITALIC = TTF_STYLE_ITALIC;
339
341 TTF_STYLE_UNDERLINE;
342
344 TTF_STYLE_STRIKETHROUGH;
345
358using HintingFlags = TTF_HintingFlags;
359
360#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
361
362constexpr HintingFlags HINTING_INVALID = TTF_HINTING_INVALID;
363
364#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 2)
365
367 TTF_HINTING_NORMAL;
368
370constexpr HintingFlags HINTING_LIGHT = TTF_HINTING_LIGHT;
371
376constexpr HintingFlags HINTING_MONO = TTF_HINTING_MONO;
377
379constexpr HintingFlags HINTING_NONE = TTF_HINTING_NONE;
380
382constexpr HintingFlags HINTING_LIGHT_SUBPIXEL = TTF_HINTING_LIGHT_SUBPIXEL;
383
389using HorizontalAlignment = TTF_HorizontalAlignment;
390
392 TTF_HORIZONTAL_ALIGN_INVALID;
393
395 TTF_HORIZONTAL_ALIGN_LEFT;
396
398 TTF_HORIZONTAL_ALIGN_CENTER;
399
401 TTF_HORIZONTAL_ALIGN_RIGHT;
402
414using Direction = TTF_Direction;
415
416constexpr Direction DIRECTION_INVALID = TTF_DIRECTION_INVALID;
417
418constexpr Direction DIRECTION_LTR = TTF_DIRECTION_LTR;
419
420constexpr Direction DIRECTION_RTL = TTF_DIRECTION_RTL;
421
422constexpr Direction DIRECTION_TTB = TTF_DIRECTION_TTB;
423
424constexpr Direction DIRECTION_BTT = TTF_DIRECTION_BTT;
425
431using ImageType = TTF_ImageType;
432
433constexpr ImageType IMAGE_INVALID = TTF_IMAGE_INVALID;
434
436 TTF_IMAGE_ALPHA;
437
439 TTF_IMAGE_COLOR;
440
442constexpr ImageType IMAGE_SDF = TTF_IMAGE_SDF;
443
451class Font
452{
453 FontRaw m_resource = nullptr;
454
455public:
457 constexpr Font(std::nullptr_t = nullptr) noexcept
458 : m_resource(0)
459 {
460 }
461
469 constexpr explicit Font(const FontRaw resource) noexcept
470 : m_resource(resource)
471 {
472 }
473
474protected:
476 constexpr Font(const Font& other) noexcept = default;
477
478public:
480 constexpr Font(Font&& other) noexcept
481 : Font(other.release())
482 {
483 }
484
485 constexpr Font(const FontRef& other) = delete;
486
487 constexpr Font(FontRef&& other) = delete;
488
507 Font(StringParam file, float ptsize)
508 : m_resource(CheckError(TTF_OpenFont(file, ptsize)))
509 {
510 }
511
535 Font(IOStreamParam src, float ptsize, bool closeio = false)
536 : m_resource(CheckError(TTF_OpenFontIO(src, closeio, ptsize)))
537 {
538 }
539
584 : m_resource(CheckError(TTF_OpenFontWithProperties(props)))
585 {
586 }
587
589 ~Font() { TTF_CloseFont(m_resource); }
590
592 constexpr Font& operator=(Font&& other) noexcept
593 {
594 std::swap(m_resource, other.m_resource);
595 return *this;
596 }
597
598protected:
600 constexpr Font& operator=(const Font& other) noexcept = default;
601
602public:
604 constexpr FontRaw get() const noexcept { return m_resource; }
605
607 constexpr FontRaw release() noexcept
608 {
609 auto r = m_resource;
610 m_resource = nullptr;
611 return r;
612 }
613
615 constexpr auto operator<=>(const Font& other) const noexcept = default;
616
618 constexpr explicit operator bool() const noexcept { return !!m_resource; }
619
621 constexpr operator FontParam() const noexcept { return {m_resource}; }
622
642 void Close();
643
660 Font Copy() const;
661
682
697 Uint32 GetGeneration() const;
698
720 void AddFallback(FontParam fallback);
721
737 void RemoveFallback(FontParam fallback);
738
752 void ClearFallbacks();
753
770 void SetSize(float ptsize);
771
791 void SetSizeDPI(float ptsize, int hdpi, int vdpi);
792
807 float GetSize() const;
808
823 void GetDPI(int* hdpi, int* vdpi) const;
824
848 void SetStyle(FontStyleFlags style);
849
869 FontStyleFlags GetStyle() const;
870
891 void SetOutline(int outline);
892
904 int GetOutline() const;
905
929 void SetHinting(HintingFlags hinting);
930
940 int GetNumFaces() const;
941
962 HintingFlags GetHinting() const;
963
986 void SetSDF(bool enabled);
987
999 bool GetSDF() const;
1000
1001#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
1002
1013 int GetWeight() const;
1014
1015#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 2)
1016
1032
1045
1057 int GetHeight() const;
1058
1070 int GetAscent() const;
1071
1083 int GetDescent() const;
1084
1099 void SetLineSkip(int lineskip);
1100
1112 int GetLineSkip() const;
1113
1133 void SetKerning(bool enabled);
1134
1146 bool GetKerning() const;
1147
1163 bool IsFixedWidth() const;
1164
1178 bool IsScalable() const;
1179
1195 const char* GetFamilyName() const;
1196
1212 const char* GetStyleName() const;
1213
1230 void SetDirection(Direction direction);
1231
1244 Direction GetDirection() const;
1245
1264 void SetScript(Uint32 script);
1265
1280 Uint32 GetScript() const;
1281
1297 static Uint32 GetGlyphScript(Uint32 ch);
1298
1316 void SetLanguage(StringParam language_bcp47);
1317
1329 bool HasGlyph(Uint32 ch) const;
1330
1345 Surface GetGlyphImage(Uint32 ch, ImageType* image_type) const;
1346
1365 ImageType* image_type) const;
1366
1394 void GetGlyphMetrics(Uint32 ch,
1395 int* minx,
1396 int* maxx,
1397 int* miny,
1398 int* maxy,
1399 int* advance) const;
1400
1414 int GetGlyphKerning(Uint32 previous_ch, Uint32 ch) const;
1415
1431 Point GetStringSize(std::string_view text) const
1432 {
1433 Point p;
1434 GetStringSize(text, &p.x, &p.y);
1435 return p;
1436 }
1437
1454 void GetStringSize(std::string_view text, int* w, int* h) const;
1455
1477 Point GetStringSizeWrapped(std::string_view text, int wrap_width) const
1478 {
1479 Point p;
1480 GetStringSizeWrapped(text, wrap_width, &p.x, &p.y);
1481 return p;
1482 }
1483
1506 void GetStringSizeWrapped(std::string_view text,
1507 int wrap_width,
1508 int* w,
1509 int* h) const;
1510
1533 void MeasureString(std::string_view text,
1534 int max_width,
1535 int* measured_width,
1536 size_t* measured_length) const;
1537
1570 Surface RenderText_Solid(std::string_view text, Color fg) const;
1571
1603 Surface RenderText_Solid_Wrapped(std::string_view text,
1604 Color fg,
1605 int wrapLength) const;
1606
1634
1668 Surface RenderText_Shaded(std::string_view text, Color fg, Color bg) const;
1669
1703 Surface RenderText_Shaded_Wrapped(std::string_view text,
1704 Color fg,
1705 Color bg,
1706 int wrap_width) const;
1707
1737
1769 Surface RenderText_Blended(std::string_view text, Color fg) const;
1770
1802 Surface RenderText_Blended_Wrapped(std::string_view text,
1803 Color fg,
1804 int wrap_width) const;
1805
1833
1866 Surface RenderText_LCD(std::string_view text, Color fg, Color bg) const;
1867
1901 Surface RenderText_LCD_Wrapped(std::string_view text,
1902 Color fg,
1903 Color bg,
1904 int wrap_width) const;
1905
1935};
1936
1939{
1940 using Font::Font;
1941
1949 FontRef(FontParam resource) noexcept
1950 : Font(resource.value)
1951 {
1952 }
1953
1961 FontRef(FontRaw resource) noexcept
1962 : Font(resource)
1963 {
1964 }
1965
1967 constexpr FontRef(const FontRef& other) noexcept = default;
1968
1971};
1972
1993inline Font OpenFont(StringParam file, float ptsize)
1994{
1995 return Font(std::move(file), ptsize);
1996}
1997
2023inline Font OpenFont(IOStreamParam src, float ptsize, bool closeio = false)
2024{
2025 return Font(src, ptsize, closeio);
2026}
2027
2071{
2072 return Font(props);
2073}
2074
2075namespace prop::Font {
2076
2077constexpr auto CREATE_FILENAME_STRING = TTF_PROP_FONT_CREATE_FILENAME_STRING;
2078
2079constexpr auto CREATE_IOSTREAM_POINTER = TTF_PROP_FONT_CREATE_IOSTREAM_POINTER;
2080
2081constexpr auto CREATE_IOSTREAM_OFFSET_NUMBER =
2082 TTF_PROP_FONT_CREATE_IOSTREAM_OFFSET_NUMBER;
2083
2084constexpr auto CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN =
2085 TTF_PROP_FONT_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN;
2086
2087constexpr auto CREATE_SIZE_FLOAT = TTF_PROP_FONT_CREATE_SIZE_FLOAT;
2088
2089constexpr auto CREATE_FACE_NUMBER = TTF_PROP_FONT_CREATE_FACE_NUMBER;
2090
2091constexpr auto CREATE_HORIZONTAL_DPI_NUMBER =
2092 TTF_PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER;
2093
2094constexpr auto CREATE_VERTICAL_DPI_NUMBER =
2095 TTF_PROP_FONT_CREATE_VERTICAL_DPI_NUMBER;
2096
2097#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
2098
2099constexpr auto CREATE_EXISTING_FONT_POINTER =
2100 TTF_PROP_FONT_CREATE_EXISTING_FONT;
2101
2102#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 2)
2103
2104constexpr auto OUTLINE_LINE_CAP_NUMBER = TTF_PROP_FONT_OUTLINE_LINE_CAP_NUMBER;
2105
2106constexpr auto OUTLINE_LINE_JOIN_NUMBER =
2107 TTF_PROP_FONT_OUTLINE_LINE_JOIN_NUMBER;
2108
2109constexpr auto OUTLINE_MITER_LIMIT_NUMBER =
2110 TTF_PROP_FONT_OUTLINE_MITER_LIMIT_NUMBER;
2111
2112} // namespace prop::Font
2113
2133inline Font CopyFont(FontParam existing_font)
2134{
2135 return Font(CheckError(TTF_CopyFont(existing_font)));
2136}
2137
2138inline Font Font::Copy() const { return SDL::CopyFont(m_resource); }
2139
2161{
2162 return {CheckError(TTF_GetFontProperties(font))};
2163}
2164
2166{
2167 return SDL::GetFontProperties(m_resource);
2168}
2169
2186{
2187 return TTF_GetFontGeneration(font);
2188}
2189
2191{
2192 return SDL::GetFontGeneration(m_resource);
2193}
2194
2217inline void AddFallbackFont(FontParam font, FontParam fallback)
2218{
2219 CheckError(TTF_AddFallbackFont(font, fallback));
2220}
2221
2222inline void Font::AddFallback(FontParam fallback)
2223{
2224 SDL::AddFallbackFont(m_resource, fallback);
2225}
2226
2243inline void RemoveFallbackFont(FontParam font, FontParam fallback)
2244{
2245 TTF_RemoveFallbackFont(font, fallback);
2246}
2247
2248inline void Font::RemoveFallback(FontParam fallback)
2249{
2250 SDL::RemoveFallbackFont(m_resource, fallback);
2251}
2252
2268inline void ClearFallbackFonts(FontParam font) { TTF_ClearFallbackFonts(font); }
2269
2270inline void Font::ClearFallbacks() { SDL::ClearFallbackFonts(m_resource); }
2271
2289inline void SetFontSize(FontParam font, float ptsize)
2290{
2291 CheckError(TTF_SetFontSize(font, ptsize));
2292}
2293
2294inline void Font::SetSize(float ptsize)
2295{
2296 SDL::SetFontSize(m_resource, ptsize);
2297}
2298
2319inline void SetFontSizeDPI(FontParam font, float ptsize, int hdpi, int vdpi)
2320{
2321 CheckError(TTF_SetFontSizeDPI(font, ptsize, hdpi, vdpi));
2322}
2323
2324inline void Font::SetSizeDPI(float ptsize, int hdpi, int vdpi)
2325{
2326 SDL::SetFontSizeDPI(m_resource, ptsize, hdpi, vdpi);
2327}
2328
2344inline float GetFontSize(FontParam font) { return TTF_GetFontSize(font); }
2345
2346inline float Font::GetSize() const { return SDL::GetFontSize(m_resource); }
2347
2363inline void GetFontDPI(FontParam font, int* hdpi, int* vdpi)
2364{
2365 CheckError(TTF_GetFontDPI(font, hdpi, vdpi));
2366}
2367
2368inline void Font::GetDPI(int* hdpi, int* vdpi) const
2369{
2370 SDL::GetFontDPI(m_resource, hdpi, vdpi);
2371}
2372
2397inline void SetFontStyle(FontParam font, FontStyleFlags style)
2398{
2399 TTF_SetFontStyle(font, style);
2400}
2401
2403{
2404 SDL::SetFontStyle(m_resource, style);
2405}
2406
2428{
2429 return TTF_GetFontStyle(font);
2430}
2431
2433{
2434 return SDL::GetFontStyle(m_resource);
2435}
2436
2458inline void SetFontOutline(FontParam font, int outline)
2459{
2460 CheckError(TTF_SetFontOutline(font, outline));
2461}
2462
2463inline void Font::SetOutline(int outline)
2464{
2465 SDL::SetFontOutline(m_resource, outline);
2466}
2467
2480inline int GetFontOutline(FontParam font) { return TTF_GetFontOutline(font); }
2481
2482inline int Font::GetOutline() const { return SDL::GetFontOutline(m_resource); }
2483
2508inline void SetFontHinting(FontParam font, HintingFlags hinting)
2509{
2510 TTF_SetFontHinting(font, hinting);
2511}
2512
2513inline void Font::SetHinting(HintingFlags hinting)
2514{
2515 SDL::SetFontHinting(m_resource, hinting);
2516}
2517
2528inline int GetNumFontFaces(FontParam font) { return TTF_GetNumFontFaces(font); }
2529
2530inline int Font::GetNumFaces() const
2531{
2532 return SDL::GetNumFontFaces(m_resource);
2533}
2534
2557{
2558 return TTF_GetFontHinting(font);
2559}
2560
2562{
2563 return SDL::GetFontHinting(m_resource);
2564}
2565
2589inline void SetFontSDF(FontParam font, bool enabled)
2590{
2591 CheckError(TTF_SetFontSDF(font, enabled));
2592}
2593
2594inline void Font::SetSDF(bool enabled) { SDL::SetFontSDF(m_resource, enabled); }
2595
2608inline bool GetFontSDF(FontParam font) { return TTF_GetFontSDF(font); }
2609
2610inline bool Font::GetSDF() const { return SDL::GetFontSDF(m_resource); }
2611
2612#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
2613
2625inline int GetFontWeight(FontParam font) { return TTF_GetFontWeight(font); }
2626
2627inline int Font::GetWeight() const { return SDL::GetFontWeight(m_resource); }
2628
2629constexpr int FONT_WEIGHT_THIN =
2630 TTF_FONT_WEIGHT_THIN;
2631
2633 TTF_FONT_WEIGHT_EXTRA_LIGHT;
2634
2635constexpr int FONT_WEIGHT_LIGHT =
2636 TTF_FONT_WEIGHT_LIGHT;
2637
2638constexpr int FONT_WEIGHT_NORMAL =
2639 TTF_FONT_WEIGHT_NORMAL;
2640
2641constexpr int FONT_WEIGHT_MEDIUM =
2642 TTF_FONT_WEIGHT_MEDIUM;
2643
2645 TTF_FONT_WEIGHT_SEMI_BOLD;
2646
2647constexpr int FONT_WEIGHT_BOLD =
2648 TTF_FONT_WEIGHT_BOLD;
2649
2651 TTF_FONT_WEIGHT_EXTRA_BOLD;
2652
2653constexpr int FONT_WEIGHT_BLACK =
2654 TTF_FONT_WEIGHT_BLACK;
2655
2657 TTF_FONT_WEIGHT_EXTRA_BLACK;
2658
2659#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 2)
2660
2677{
2678 TTF_SetFontWrapAlignment(font, align);
2679}
2680
2682{
2683 SDL::SetFontWrapAlignment(m_resource, align);
2684}
2685
2699{
2700 return TTF_GetFontWrapAlignment(font);
2701}
2702
2704{
2705 return SDL::GetFontWrapAlignment(m_resource);
2706}
2707
2720inline int GetFontHeight(FontParam font) { return TTF_GetFontHeight(font); }
2721
2722inline int Font::GetHeight() const { return SDL::GetFontHeight(m_resource); }
2723
2736inline int GetFontAscent(FontParam font) { return TTF_GetFontAscent(font); }
2737
2738inline int Font::GetAscent() const { return SDL::GetFontAscent(m_resource); }
2739
2752inline int GetFontDescent(FontParam font) { return TTF_GetFontDescent(font); }
2753
2754inline int Font::GetDescent() const { return SDL::GetFontDescent(m_resource); }
2755
2771inline void SetFontLineSkip(FontParam font, int lineskip)
2772{
2773 TTF_SetFontLineSkip(font, lineskip);
2774}
2775
2776inline void Font::SetLineSkip(int lineskip)
2777{
2778 SDL::SetFontLineSkip(m_resource, lineskip);
2779}
2780
2793inline int GetFontLineSkip(FontParam font) { return TTF_GetFontLineSkip(font); }
2794
2795inline int Font::GetLineSkip() const
2796{
2797 return SDL::GetFontLineSkip(m_resource);
2798}
2799
2820inline void SetFontKerning(FontParam font, bool enabled)
2821{
2822 TTF_SetFontKerning(font, enabled);
2823}
2824
2825inline void Font::SetKerning(bool enabled)
2826{
2827 SDL::SetFontKerning(m_resource, enabled);
2828}
2829
2842inline bool GetFontKerning(FontParam font) { return TTF_GetFontKerning(font); }
2843
2844inline bool Font::GetKerning() const { return SDL::GetFontKerning(m_resource); }
2845
2863{
2864 return TTF_FontIsFixedWidth(font);
2865}
2866
2867inline bool Font::IsFixedWidth() const
2868{
2869 return SDL::FontIsFixedWidth(m_resource);
2870}
2871
2886inline bool FontIsScalable(FontParam font) { return TTF_FontIsScalable(font); }
2887
2888inline bool Font::IsScalable() const { return SDL::FontIsScalable(m_resource); }
2889
2906inline const char* GetFontFamilyName(FontParam font)
2907{
2908 return TTF_GetFontFamilyName(font);
2909}
2910
2911inline const char* Font::GetFamilyName() const
2912{
2913 return SDL::GetFontFamilyName(m_resource);
2914}
2915
2932inline const char* GetFontStyleName(FontParam font)
2933{
2934 return TTF_GetFontStyleName(font);
2935}
2936
2937inline const char* Font::GetStyleName() const
2938{
2939 return SDL::GetFontStyleName(m_resource);
2940}
2941
2959inline void SetFontDirection(FontParam font, Direction direction)
2960{
2961 CheckError(TTF_SetFontDirection(font, direction));
2962}
2963
2964inline void Font::SetDirection(Direction direction)
2965{
2966 SDL::SetFontDirection(m_resource, direction);
2967}
2968
2983{
2984 return TTF_GetFontDirection(font);
2985}
2986
2988{
2989 return SDL::GetFontDirection(m_resource);
2990}
2991
3005{
3006 return TTF_StringToTag(string);
3007}
3008
3024inline void TagToString(Uint32 tag, char* string, size_t size)
3025{
3026 TTF_TagToString(tag, string, size);
3027}
3028
3048inline void SetFontScript(FontParam font, Uint32 script)
3049{
3050 CheckError(TTF_SetFontScript(font, script));
3051}
3052
3053inline void Font::SetScript(Uint32 script)
3054{
3055 SDL::SetFontScript(m_resource, script);
3056}
3057
3073inline Uint32 GetFontScript(FontParam font) { return TTF_GetFontScript(font); }
3074
3075inline Uint32 Font::GetScript() const { return SDL::GetFontScript(m_resource); }
3076
3092{
3093 return CheckError(TTF_GetGlyphScript(ch));
3094}
3095
3097{
3098 return SDL::GetGlyphScript(ch);
3099}
3100
3118inline void SetFontLanguage(FontParam font, StringParam language_bcp47)
3119{
3120 CheckError(TTF_SetFontLanguage(font, language_bcp47));
3121}
3122
3123inline void Font::SetLanguage(StringParam language_bcp47)
3124{
3125 SDL::SetFontLanguage(m_resource, std::move(language_bcp47));
3126}
3127
3140inline bool FontHasGlyph(FontParam font, Uint32 ch)
3141{
3142 return TTF_FontHasGlyph(font, ch);
3143}
3144
3145inline bool Font::HasGlyph(Uint32 ch) const
3146{
3147 return SDL::FontHasGlyph(m_resource, ch);
3148}
3149
3165inline Surface GetGlyphImage(FontParam font, Uint32 ch, ImageType* image_type)
3166{
3167 return Surface{TTF_GetGlyphImage(font, ch, image_type)};
3168}
3169
3170inline Surface Font::GetGlyphImage(Uint32 ch, ImageType* image_type) const
3171{
3172 return SDL::GetGlyphImage(m_resource, ch, image_type);
3173}
3174
3194 Uint32 glyph_index,
3195 ImageType* image_type)
3196{
3197 return Surface(TTF_GetGlyphImageForIndex(font, glyph_index, image_type));
3198}
3199
3201 ImageType* image_type) const
3202{
3203 return SDL::GetGlyphImageForIndex(m_resource, glyph_index, image_type);
3204}
3205
3235 Uint32 ch,
3236 int* minx,
3237 int* maxx,
3238 int* miny,
3239 int* maxy,
3240 int* advance)
3241{
3242 CheckError(TTF_GetGlyphMetrics(font, ch, minx, maxx, miny, maxy, advance));
3243}
3244
3246 int* minx,
3247 int* maxx,
3248 int* miny,
3249 int* maxy,
3250 int* advance) const
3251{
3252 SDL::GetGlyphMetrics(m_resource, ch, minx, maxx, miny, maxy, advance);
3253}
3254
3269inline int GetGlyphKerning(FontParam font, Uint32 previous_ch, Uint32 ch)
3270{
3271 if (int r; TTF_GetGlyphKerning(font, previous_ch, ch, &r)) return r;
3272 throw Error();
3273}
3274
3275inline int Font::GetGlyphKerning(Uint32 previous_ch, Uint32 ch) const
3276{
3277 return SDL::GetGlyphKerning(m_resource, previous_ch, ch);
3278}
3279
3297inline void GetStringSize(FontParam font, std::string_view text, int* w, int* h)
3298{
3299 CheckError(TTF_GetStringSize(font, text.data(), text.size(), w, h));
3300}
3301
3302inline void Font::GetStringSize(std::string_view text, int* w, int* h) const
3303{
3304 SDL::GetStringSize(m_resource, text, w, h);
3305}
3306
3331 std::string_view text,
3332 int wrap_width,
3333 int* w,
3334 int* h)
3335{
3336 CheckError(
3337 TTF_GetStringSizeWrapped(font, text.data(), text.size(), wrap_width, w, h));
3338}
3339
3340inline void Font::GetStringSizeWrapped(std::string_view text,
3341 int wrap_width,
3342 int* w,
3343 int* h) const
3344{
3345 SDL::GetStringSizeWrapped(m_resource, text, wrap_width, w, h);
3346}
3347
3371inline void MeasureString(FontParam font,
3372 std::string_view text,
3373 int max_width,
3374 int* measured_width,
3375 size_t* measured_length)
3376{
3377 CheckError(TTF_MeasureString(font,
3378 text.data(),
3379 text.size(),
3380 max_width,
3381 measured_width,
3382 measured_length));
3383}
3384
3385inline void Font::MeasureString(std::string_view text,
3386 int max_width,
3387 int* measured_width,
3388 size_t* measured_length) const
3389{
3391 m_resource, text, max_width, measured_width, measured_length);
3392}
3393
3427inline Surface RenderText_Solid(FontParam font, std::string_view text, Color fg)
3428{
3429 return Surface{TTF_RenderText_Solid(font, text.data(), text.size(), fg)};
3430}
3431
3432inline Surface Font::RenderText_Solid(std::string_view text, Color fg) const
3433{
3434 return SDL::RenderText_Solid(m_resource, text, fg);
3435}
3436
3470 std::string_view text,
3471 Color fg,
3472 int wrapLength)
3473{
3474 return Surface(TTF_RenderText_Solid_Wrapped(
3475 font, text.data(), text.size(), fg, wrapLength));
3476}
3477
3478inline Surface Font::RenderText_Solid_Wrapped(std::string_view text,
3479 Color fg,
3480 int wrapLength) const
3481{
3482 return SDL::RenderText_Solid_Wrapped(m_resource, text, fg, wrapLength);
3483}
3484
3513{
3514 return Surface(TTF_RenderGlyph_Solid(font, ch, fg));
3515}
3516
3518{
3519 return SDL::RenderGlyph_Solid(m_resource, ch, fg);
3520}
3521
3557 std::string_view text,
3558 Color fg,
3559 Color bg)
3560{
3561 return Surface(TTF_RenderText_Shaded(font, text.data(), text.size(), fg, bg));
3562}
3563
3564inline Surface Font::RenderText_Shaded(std::string_view text,
3565 Color fg,
3566 Color bg) const
3567{
3568 return SDL::RenderText_Shaded(m_resource, text, fg, bg);
3569}
3570
3606 std::string_view text,
3607 Color fg,
3608 Color bg,
3609 int wrap_width)
3610{
3611 return Surface(TTF_RenderText_Shaded_Wrapped(
3612 font, text.data(), text.size(), fg, bg, wrap_width));
3613}
3614
3615inline Surface Font::RenderText_Shaded_Wrapped(std::string_view text,
3616 Color fg,
3617 Color bg,
3618 int wrap_width) const
3619{
3620 return SDL::RenderText_Shaded_Wrapped(m_resource, text, fg, bg, wrap_width);
3621}
3622
3653 Uint32 ch,
3654 ColorRaw fg,
3655 ColorRaw bg)
3656{
3657 return Surface(TTF_RenderGlyph_Shaded(font, ch, fg, bg));
3658}
3659
3661 ColorRaw fg,
3662 ColorRaw bg) const
3663{
3664 return SDL::RenderGlyph_Shaded(m_resource, ch, fg, bg);
3665}
3666
3700 std::string_view text,
3701 Color fg)
3702{
3703 return Surface(TTF_RenderText_Blended(font, text.data(), text.size(), fg));
3704}
3705
3706inline Surface Font::RenderText_Blended(std::string_view text, Color fg) const
3707{
3708 return SDL::RenderText_Blended(m_resource, text, fg);
3709}
3710
3744 std::string_view text,
3745 Color fg,
3746 int wrap_width)
3747{
3748 return Surface(TTF_RenderText_Blended_Wrapped(
3749 font, text.data(), text.size(), fg, wrap_width));
3750}
3751
3752inline Surface Font::RenderText_Blended_Wrapped(std::string_view text,
3753 Color fg,
3754 int wrap_width) const
3755{
3756 return SDL::RenderText_Blended_Wrapped(m_resource, text, fg, wrap_width);
3757}
3758
3787{
3788 return Surface(TTF_RenderGlyph_Blended(font, ch, fg));
3789}
3790
3792{
3793 return SDL::RenderGlyph_Blended(m_resource, ch, fg);
3794}
3795
3830 std::string_view text,
3831 Color fg,
3832 Color bg)
3833{
3834 return Surface(TTF_RenderText_LCD(font, text.data(), text.size(), fg, bg));
3835}
3836
3837inline Surface Font::RenderText_LCD(std::string_view text,
3838 Color fg,
3839 Color bg) const
3840{
3841 return SDL::RenderText_LCD(m_resource, text, fg, bg);
3842}
3843
3878 std::string_view text,
3879 Color fg,
3880 Color bg,
3881 int wrap_width)
3882{
3883 return Surface(TTF_RenderText_LCD_Wrapped(
3884 font, text.data(), text.size(), fg, bg, wrap_width));
3885}
3886
3887inline Surface Font::RenderText_LCD_Wrapped(std::string_view text,
3888 Color fg,
3889 Color bg,
3890 int wrap_width) const
3891{
3892 return SDL::RenderText_LCD_Wrapped(m_resource, text, fg, bg, wrap_width);
3893}
3894
3925 Uint32 ch,
3926 ColorRaw fg,
3927 ColorRaw bg)
3928{
3929 return Surface(TTF_RenderGlyph_LCD(font, ch, fg, bg));
3930}
3931
3933{
3934 return SDL::RenderGlyph_LCD(m_resource, ch, fg, bg);
3935}
3936
3945
3947 TTF_SUBSTRING_DIRECTION_MASK;
3949
3951 TTF_SUBSTRING_TEXT_START;
3953
3955constexpr SubStringFlags SUBSTRING_LINE_START = TTF_SUBSTRING_LINE_START;
3956
3958constexpr SubStringFlags SUBSTRING_LINE_END = TTF_SUBSTRING_LINE_END;
3959
3961 TTF_SUBSTRING_TEXT_END;
3962
3968using GPUTextEngineWinding = TTF_GPUTextEngineWinding;
3969
3971 TTF_GPU_TEXTENGINE_WINDING_INVALID;
3972
3974 TTF_GPU_TEXTENGINE_WINDING_CLOCKWISE;
3975
3977 TTF_GPU_TEXTENGINE_WINDING_COUNTER_CLOCKWISE;
3978
3998{
3999 TextEngineRaw m_resource = nullptr;
4000
4001public:
4003 constexpr TextEngine(std::nullptr_t = nullptr) noexcept
4004 : m_resource(0)
4005 {
4006 }
4007
4015 constexpr explicit TextEngine(const TextEngineRaw resource) noexcept
4016 : m_resource(resource)
4017 {
4018 }
4019
4020protected:
4022 constexpr TextEngine(const TextEngine& other) noexcept = default;
4023
4024public:
4026 constexpr TextEngine(TextEngine&& other) noexcept
4027 : TextEngine(other.release())
4028 {
4029 }
4030
4032 virtual ~TextEngine() = default;
4033
4035 constexpr TextEngine& operator=(TextEngine&& other) noexcept
4036 {
4037 std::swap(m_resource, other.m_resource);
4038 return *this;
4039 }
4040
4041protected:
4043 constexpr TextEngine& operator=(const TextEngine& other) noexcept = default;
4044
4045public:
4047 constexpr TextEngineRaw get() const noexcept { return m_resource; }
4048
4050 constexpr TextEngineRaw release() noexcept
4051 {
4052 auto r = m_resource;
4053 m_resource = nullptr;
4054 return r;
4055 }
4056
4058 constexpr auto operator<=>(const TextEngine& other) const noexcept = default;
4059
4061 constexpr explicit operator bool() const noexcept { return !!m_resource; }
4062
4064 constexpr operator TextEngineParam() const noexcept { return {m_resource}; }
4065
4067 virtual void Destroy() = 0;
4068
4084 Text CreateText(FontParam font, std::string_view text);
4085};
4086
4089{
4104 : TextEngine(TTF_CreateSurfaceTextEngine())
4105 {
4106 }
4107
4109
4123 void Destroy() final;
4124};
4125
4128{
4146 : TextEngine(TTF_CreateRendererTextEngine(renderer))
4147 {
4148 }
4149
4175 : TextEngine(TTF_CreateRendererTextEngineWithProperties(props))
4176 {
4177 }
4178
4180
4194 void Destroy() final;
4195};
4196
4199{
4217 : TextEngine(TTF_CreateGPUTextEngine(device))
4218 {
4219 }
4220
4246 : TextEngine(TTF_CreateGPUTextEngineWithProperties(props))
4247 {
4248 }
4249
4250 ~GPUTextEngine() { Destroy(); }
4251
4265 void SetGPUWinding(GPUTextEngineWinding winding);
4266
4281 GPUTextEngineWinding GetGPUWinding() const;
4282
4296 void Destroy() final;
4297};
4298
4306using GPUAtlasDrawSequence = TTF_GPUAtlasDrawSequence;
4307
4320using SubString = TTF_SubString;
4321
4322// Forward decl
4323struct SubStringIterator;
4324
4330using TextData = TTF_TextData;
4331
4343class Text
4344{
4345 TextRaw m_resource = nullptr;
4346
4347public:
4349 constexpr Text(std::nullptr_t = nullptr) noexcept
4350 : m_resource(0)
4351 {
4352 }
4353
4361 constexpr explicit Text(const TextRaw resource) noexcept
4362 : m_resource(resource)
4363 {
4364 }
4365
4366protected:
4368 constexpr Text(const Text& other) noexcept = default;
4369
4370public:
4372 constexpr Text(Text&& other) noexcept
4373 : Text(other.release())
4374 {
4375 }
4376
4377 constexpr Text(const TextRef& other) = delete;
4378
4379 constexpr Text(TextRef&& other) = delete;
4380
4398 Text(TextEngineParam engine, FontParam font, std::string_view text)
4399 : m_resource(TTF_CreateText(engine, font, text.data(), text.size()))
4400 {
4401 }
4402
4404 constexpr const TextRaw operator->() const noexcept { return m_resource; }
4405
4407 constexpr TextRaw operator->() noexcept { return m_resource; }
4408
4410 ~Text() { TTF_DestroyText(m_resource); }
4411
4413 constexpr Text& operator=(Text&& other) noexcept
4414 {
4415 std::swap(m_resource, other.m_resource);
4416 return *this;
4417 }
4418
4419protected:
4421 constexpr Text& operator=(const Text& other) noexcept = default;
4422
4423public:
4425 constexpr TextRaw get() const noexcept { return m_resource; }
4426
4428 constexpr TextRaw release() noexcept
4429 {
4430 auto r = m_resource;
4431 m_resource = nullptr;
4432 return r;
4433 }
4434
4436 constexpr auto operator<=>(const Text& other) const noexcept = default;
4437
4439 constexpr explicit operator bool() const noexcept { return !!m_resource; }
4440
4442 constexpr operator TextParam() const noexcept { return {m_resource}; }
4443
4454 void Destroy();
4455
4475 void DrawSurface(Point p, SurfaceParam surface) const;
4476
4496 void DrawRenderer(FPoint p) const;
4497
4524 GPUAtlasDrawSequence* GetGPUDrawData() const;
4525
4537 PropertiesRef GetProperties() const;
4538
4554 void SetEngine(TextEngineParam engine);
4555
4569 TextEngineParam GetEngine() const;
4570
4591 bool SetFont(FontParam font);
4592
4606 FontRef GetFont() const;
4607
4622 void SetDirection(Direction direction);
4623
4636 Direction GetDirection() const;
4637
4654 void SetScript(Uint32 script);
4655
4672 Uint32 GetScript() const;
4673
4690 void SetColor(Color c);
4691
4708 void SetColorFloat(FColor c);
4709
4731 void GetColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a) const;
4732
4747 Color GetColor() const;
4748
4770 void GetColorFloat(float* r, float* g, float* b, float* a) const;
4771
4786 FColor GetColorFloat() const;
4787
4806 void SetPosition(const PointRaw& p);
4807
4824 void GetPosition(int* x, int* y) const;
4825
4840 Point GetPosition() const;
4841
4858 void SetWrapWidth(int wrap_width);
4859
4874 int GetWrapWidth() const;
4875
4897 void SetWrapWhitespaceVisible(bool visible);
4898
4912 bool IsWrapWhitespaceVisible() const;
4913
4931 void SetString(std::string_view string);
4932
4954 void InsertString(int offset, std::string_view string);
4955
4973 void AppendString(std::string_view string);
4974
4997 void DeleteString(int offset, int length);
4998
5016 void GetSize(int* w, int* h) const;
5017
5034 Point GetSize() const;
5035
5055 void GetSubString(int offset, SubString* substring) const;
5056
5061
5066
5083
5102 void GetSubStringForLine(int line, SubString* substring) const;
5103
5116 {
5117 return GetSubStringsForRange(0);
5118 }
5119
5136 OwnArray<SubString*> GetSubStringsForRange(int offset, int length = -1) const;
5137
5154
5171 void GetSubStringForPoint(Point p, SubString* substring) const;
5172
5189 void GetPreviousSubString(const SubString& substring,
5190 SubString* previous) const;
5191
5207 void GetNextSubString(const SubString& substring, SubString* next) const;
5208
5223 void Update();
5224
5229 const char* GetText() const { return m_resource->text; }
5230
5232 int GetNumLines() const { return m_resource->num_lines; }
5233};
5234
5237{
5238 using Text::Text;
5239
5247 TextRef(TextParam resource = nullptr) noexcept
5248 : Text(resource.value)
5249 {
5250 }
5251
5259 TextRef(TextRaw resource) noexcept
5260 : Text(resource)
5261 {
5262 }
5263
5265 constexpr TextRef(const TextRef& other) noexcept = default;
5266
5268 ~TextRef() { release(); }
5269};
5270
5276{
5277 TextRef m_text;
5278
5279 SubString m_subString;
5280
5281 constexpr SubStringIterator(TextRef text)
5282 : m_text(text)
5283 , m_subString(0)
5284 {
5285 }
5286
5287public:
5291 {
5292 }
5293
5295 constexpr operator bool() const { return bool(m_text); }
5296
5298 constexpr const SubString& operator*() const { return m_subString; }
5299
5301 constexpr const SubString* operator->() const { return &m_subString; }
5302
5304 constexpr bool operator==(const SubStringIterator& other) const
5305 {
5306 return m_subString.offset == other.m_subString.offset;
5307 }
5308
5311 {
5312 m_text.GetNextSubString(m_subString, &m_subString);
5313 return *this;
5314 }
5315
5318 {
5319 auto curr = *this;
5320 m_text.GetNextSubString(m_subString, &m_subString);
5321 return curr;
5322 }
5323
5326 {
5327 m_text.GetPreviousSubString(m_subString, &m_subString);
5328 return *this;
5329 }
5330
5333 {
5334 auto curr = *this;
5335 m_text.GetPreviousSubString(m_subString, &m_subString);
5336 return curr;
5337 }
5338
5339 friend class Text;
5340};
5341
5356{
5357 return SurfaceTextEngine();
5358}
5359
5381{
5382 CheckError(TTF_DrawSurfaceText(text, p.x, p.y, surface));
5383}
5384
5385inline void Text::DrawSurface(Point p, SurfaceParam surface) const
5386{
5387 SDL::DrawSurfaceText(m_resource, p, surface);
5388}
5389
5407{
5408 TTF_DestroySurfaceTextEngine(engine);
5409}
5410
5412{
5414}
5415
5433{
5434 return RendererTextEngine(renderer);
5435}
5436
5462 PropertiesParam props)
5463{
5464 return RendererTextEngine(props);
5465}
5466
5467namespace prop::RendererTextEngine {
5468
5469#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
5470
5471constexpr auto RENDERER_POINTER = TTF_PROP_RENDERER_TEXT_ENGINE_RENDERER;
5472
5473constexpr auto ATLAS_TEXTURE_SIZE_NUMBER =
5474 TTF_PROP_RENDERER_TEXT_ENGINE_ATLAS_TEXTURE_SIZE;
5475
5476#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 2)
5477
5478} // namespace prop::RendererTextEngine
5479
5501{
5502 CheckError(TTF_DrawRendererText(text, p.x, p.y));
5503}
5504
5505inline void Text::DrawRenderer(FPoint p) const
5506{
5507 SDL::DrawRendererText(m_resource, p);
5508}
5509
5527{
5528 TTF_DestroyRendererTextEngine(engine);
5529}
5530
5532{
5534}
5535
5553{
5554 return GPUTextEngine(device);
5555}
5556
5582{
5583 return GPUTextEngine(props);
5584}
5585
5586namespace prop::GpuTextEngine {
5587
5588#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
5589
5590constexpr auto DEVICE_POINTER = TTF_PROP_GPU_TEXT_ENGINE_DEVICE;
5591
5592constexpr auto ATLAS_TEXTURE_SIZE_NUMBER =
5593 TTF_PROP_GPU_TEXT_ENGINE_ATLAS_TEXTURE_SIZE;
5594
5595#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 2)
5596
5597} // namespace prop::GpuTextEngine
5598
5626{
5627 return TTF_GetGPUTextDrawData(text);
5628}
5629
5631{
5632 return SDL::GetGPUTextDrawData(m_resource);
5633}
5634
5651{
5652 TTF_DestroyGPUTextEngine(engine);
5653}
5654
5656
5673 GPUTextEngineWinding winding)
5674{
5675 TTF_SetGPUTextEngineWinding(engine, winding);
5676}
5677
5679{
5681}
5682
5700{
5701 return TTF_GetGPUTextEngineWinding(engine);
5702}
5703
5705{
5707}
5708
5727 FontParam font,
5728 std::string_view text)
5729{
5730 return Text(engine, font, text);
5731}
5732
5733inline Text TextEngine::CreateText(FontParam font, std::string_view text)
5734{
5735 return Text(m_resource, font, text);
5736}
5737
5751{
5752 return {CheckError(TTF_GetTextProperties(text))};
5753}
5754
5756{
5757 return SDL::GetTextProperties(m_resource);
5758}
5759
5776inline void SetTextEngine(TextParam text, TextEngineParam engine)
5777{
5778 CheckError(TTF_SetTextEngine(text, engine));
5779}
5780
5782{
5783 SDL::SetTextEngine(m_resource, engine);
5784}
5785
5801{
5802 return CheckError(TTF_GetTextEngine(text));
5803}
5804
5806{
5807 return SDL::GetTextEngine(m_resource);
5808}
5809
5831inline bool SetTextFont(TextParam text, FontParam font)
5832{
5833 return TTF_SetTextFont(text, font);
5834}
5835
5836inline bool Text::SetFont(FontParam font)
5837{
5838 return SDL::SetTextFont(m_resource, font);
5839}
5840
5856{
5857 return {CheckError(TTF_GetTextFont(text))};
5858}
5859
5860inline FontRef Text::GetFont() const { return SDL::GetTextFont(m_resource); }
5861
5877inline void SetTextDirection(TextParam text, Direction direction)
5878{
5879 CheckError(TTF_SetTextDirection(text, direction));
5880}
5881
5882inline void Text::SetDirection(Direction direction)
5883{
5884 SDL::SetTextDirection(m_resource, direction);
5885}
5886
5901{
5902 return TTF_GetTextDirection(text);
5903}
5904
5906{
5907 return SDL::GetTextDirection(m_resource);
5908}
5909
5927inline void SetTextScript(TextParam text, Uint32 script)
5928{
5929 CheckError(TTF_SetTextScript(text, script));
5930}
5931
5932inline void Text::SetScript(Uint32 script)
5933{
5934 SDL::SetTextScript(m_resource, script);
5935}
5936
5955{
5956 return TTF_GetTextScript(text);
5957}
5958
5959inline Uint32 Text::GetScript() const { return SDL::GetTextScript(m_resource); }
5960
5978inline void SetTextColor(TextParam text, Color c)
5979{
5980 CheckError(TTF_SetTextColor(text, c.r, c.g, c.b, c.a));
5981}
5982
5983inline void Text::SetColor(Color c) { SDL::SetTextColor(m_resource, c); }
5984
6003{
6004 CheckError(TTF_SetTextColorFloat(text, c.r, c.g, c.b, c.a));
6005}
6006
6008{
6009 SDL::SetTextColorFloat(m_resource, c);
6010}
6011
6035 Uint8* r,
6036 Uint8* g,
6037 Uint8* b,
6038 Uint8* a)
6039{
6040 CheckError(TTF_GetTextColor(text, r, g, b, a));
6041}
6042
6059{
6060 Color c;
6061 GetTextColor(text, &c.r, &c.g, &c.b, &c.a);
6062 return c;
6063}
6064
6065inline void Text::GetColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a) const
6066{
6067 SDL::GetTextColor(m_resource, r, g, b, a);
6068}
6069
6070inline Color Text::GetColor() const { return SDL::GetTextColor(m_resource); }
6071
6095 float* r,
6096 float* g,
6097 float* b,
6098 float* a)
6099{
6100 CheckError(TTF_GetTextColorFloat(text, r, g, b, a));
6101}
6102
6119{
6120 FColor c;
6121 GetTextColorFloat(text, &c.r, &c.g, &c.b, &c.a);
6122 return c;
6123}
6124
6125inline void Text::GetColorFloat(float* r, float* g, float* b, float* a) const
6126{
6127 SDL::GetTextColorFloat(m_resource, r, g, b, a);
6128}
6129
6131{
6132 return SDL::GetTextColorFloat(m_resource);
6133}
6134
6154inline void SetTextPosition(TextParam text, const PointRaw& p)
6155{
6156 CheckError(TTF_SetTextPosition(text, p.x, p.y));
6157}
6158
6159inline void Text::SetPosition(const PointRaw& p)
6160{
6161 SDL::SetTextPosition(m_resource, p);
6162}
6163
6181inline void GetTextPosition(TextConstParam text, int* x, int* y)
6182{
6183 CheckError(TTF_GetTextPosition(text, x, y));
6184}
6185
6202{
6203 Point p;
6204 GetTextPosition(text, &p.x, &p.y);
6205 return p;
6206}
6207
6208inline void Text::GetPosition(int* x, int* y) const
6209{
6210 SDL::GetTextPosition(m_resource, x, y);
6211}
6212
6214{
6215 return SDL::GetTextPosition(m_resource);
6216}
6217
6235inline void SetTextWrapWidth(TextParam text, int wrap_width)
6236{
6237 CheckError(TTF_SetTextWrapWidth(text, wrap_width));
6238}
6239
6240inline void Text::SetWrapWidth(int wrap_width)
6241{
6242 SDL::SetTextWrapWidth(m_resource, wrap_width);
6243}
6244
6261{
6262 int w;
6263 CheckError(TTF_GetTextWrapWidth(text, &w));
6264 return w;
6265}
6266
6267inline int Text::GetWrapWidth() const
6268{
6269 return SDL::GetTextWrapWidth(m_resource);
6270}
6271
6292inline void SetTextWrapWhitespaceVisible(TextParam text, bool visible)
6293{
6294 CheckError(TTF_SetTextWrapWhitespaceVisible(text, visible));
6295}
6296
6297inline void Text::SetWrapWhitespaceVisible(bool visible)
6298{
6299 SDL::SetTextWrapWhitespaceVisible(m_resource, visible);
6300}
6301
6316{
6317 return TTF_TextWrapWhitespaceVisible(text);
6318}
6319
6321{
6322 return SDL::TextWrapWhitespaceVisible(m_resource);
6323}
6324
6343inline void SetTextString(TextParam text, std::string_view string)
6344{
6345 CheckError(TTF_SetTextString(text, string.data(), string.size()));
6346}
6347
6348inline void Text::SetString(std::string_view string)
6349{
6350 SDL::SetTextString(m_resource, string);
6351}
6352
6376 int offset,
6377 std::string_view string)
6378{
6379 CheckError(TTF_InsertTextString(text, offset, string.data(), string.size()));
6380}
6381
6382inline void Text::InsertString(int offset, std::string_view string)
6383{
6384 SDL::InsertTextString(m_resource, offset, string);
6385}
6386
6405inline void AppendTextString(TextParam text, std::string_view string)
6406{
6407 CheckError(TTF_AppendTextString(text, string.data(), string.size()));
6408}
6409
6410inline void Text::AppendString(std::string_view string)
6411{
6412 SDL::AppendTextString(m_resource, string);
6413}
6414
6438inline void DeleteTextString(TextParam text, int offset, int length)
6439{
6440 CheckError(TTF_DeleteTextString(text, offset, length));
6441}
6442
6443inline void Text::DeleteString(int offset, int length)
6444{
6445 SDL::DeleteTextString(m_resource, offset, length);
6446}
6447
6465inline void GetTextSize(TextConstParam text, int* w, int* h)
6466{
6467 CheckError(TTF_GetTextSize(text, w, h));
6468}
6469
6486{
6487 Point p;
6488 GetTextSize(text, &p.x, &p.y);
6489 return p;
6490}
6491
6492inline void Text::GetSize(int* w, int* h) const
6493{
6494 SDL::GetTextSize(m_resource, w, h);
6495}
6496
6497inline Point Text::GetSize() const { return SDL::GetTextSize(m_resource); }
6498
6520 int offset,
6521 SubString* substring)
6522{
6523 CheckError(TTF_GetTextSubString(text, offset, substring));
6524}
6525
6526inline void Text::GetSubString(int offset, SubString* substring) const
6527{
6528 SDL::GetTextSubString(m_resource, offset, substring);
6529}
6530
6551 int line,
6552 SubString* substring)
6553{
6554 CheckError(TTF_GetTextSubStringForLine(text, line, substring));
6555}
6556
6557inline void Text::GetSubStringForLine(int line, SubString* substring) const
6558{
6559 SDL::GetTextSubStringForLine(m_resource, line, substring);
6560}
6561
6578 int offset,
6579 int length)
6580{
6581 int count = 0;
6582 auto data = TTF_GetTextSubStringsForRange(text, offset, length, &count);
6583 return OwnArray<SubString*>{data, size_t(count)};
6584}
6585
6587 int length) const
6588{
6589 return SDL::GetTextSubStringsForRange(m_resource, offset, length);
6590}
6591
6610 Point p,
6611 SubString* substring)
6612{
6613 CheckError(TTF_GetTextSubStringForPoint(text, p.x, p.y, substring));
6614}
6615
6616inline void Text::GetSubStringForPoint(Point p, SubString* substring) const
6617{
6618 SDL::GetTextSubStringForPoint(m_resource, p, substring);
6619}
6620
6639 const SubString& substring,
6640 SubString* previous)
6641{
6642 CheckError(TTF_GetPreviousTextSubString(text, &substring, previous));
6643}
6644
6645inline void Text::GetPreviousSubString(const SubString& substring,
6646 SubString* previous) const
6647{
6648 SDL::GetPreviousTextSubString(m_resource, substring, previous);
6649}
6650
6668 const SubString& substring,
6669 SubString* next)
6670{
6671 CheckError(TTF_GetNextTextSubString(text, &substring, next));
6672}
6673
6674inline void Text::GetNextSubString(const SubString& substring,
6675 SubString* next) const
6676{
6677 SDL::GetNextTextSubString(m_resource, substring, next);
6678}
6679
6695inline void UpdateText(TextParam text) { CheckError(TTF_UpdateText(text)); }
6696
6697inline void Text::Update() { SDL::UpdateText(m_resource); }
6698
6711inline void DestroyText(TextRaw text) { TTF_DestroyText(text); }
6712
6713inline void Text::Destroy() { DestroyText(release()); }
6714
6737inline void CloseFont(FontRaw font) { TTF_CloseFont(font); }
6738
6739inline void Font::Close() { CloseFont(release()); }
6740
6742
6743} // namespace SDL
6744
6745#endif // defined(SDL3PP_ENABLE_TTF) || defined(SDL3PP_DOC)
6746
6747#endif /* SDL3PP_TTF_H_ */
An exception that returns GetError()
Definition: SDL3pp_error.h:164
The internal structure containing font information.
Definition: SDL3pp_ttf.h:452
constexpr Font(Font &&other) noexcept
Move constructor.
Definition: SDL3pp_ttf.h:480
~Font()
Destructor.
Definition: SDL3pp_ttf.h:589
constexpr Font & operator=(const Font &other) noexcept=default
Assignment operator.
Font(IOStreamParam src, float ptsize, bool closeio=false)
Create a font from an IOStream, using a specified point size.
Definition: SDL3pp_ttf.h:535
Font(PropertiesParam props)
Create a font with the specified properties.
Definition: SDL3pp_ttf.h:583
Point GetStringSize(std::string_view text) const
Calculate the dimensions of a rendered string of UTF-8 text.
Definition: SDL3pp_ttf.h:1431
Font(StringParam file, float ptsize)
Create a font from a file, using a specified point size.
Definition: SDL3pp_ttf.h:507
constexpr Font(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_ttf.h:457
constexpr auto operator<=>(const Font &other) const noexcept=default
Comparison.
constexpr Font(const FontRaw resource) noexcept
Constructs from FontParam.
Definition: SDL3pp_ttf.h:469
constexpr FontRaw get() const noexcept
Retrieves underlying FontRaw.
Definition: SDL3pp_ttf.h:604
constexpr Font(const Font &other) noexcept=default
Copy constructor.
constexpr Font & operator=(Font &&other) noexcept
Assignment operator.
Definition: SDL3pp_ttf.h:592
constexpr FontRaw release() noexcept
Retrieves underlying FontRaw and clear this.
Definition: SDL3pp_ttf.h:607
Point GetStringSizeWrapped(std::string_view text, int wrap_width) const
Calculate the dimensions of a rendered string of UTF-8 text.
Definition: SDL3pp_ttf.h:1477
Base class for SDL memory allocated array wrap.
Definition: SDL3pp_ownPtr.h:44
Helpers to use C++ strings parameters.
Definition: SDL3pp_strings.h:43
Iterator for substrings.
Definition: SDL3pp_ttf.h:5276
constexpr SubStringIterator()
Default constructor.
Definition: SDL3pp_ttf.h:5289
constexpr SubStringIterator & operator--()
Decrement operator.
Definition: SDL3pp_ttf.h:5325
constexpr const SubString & operator*() const
Retrieve SubString.
Definition: SDL3pp_ttf.h:5298
constexpr const SubString * operator->() const
Retrieve SubString.
Definition: SDL3pp_ttf.h:5301
constexpr bool operator==(const SubStringIterator &other) const
Comparison.
Definition: SDL3pp_ttf.h:5304
constexpr SubStringIterator operator--(int)
Decrement operator.
Definition: SDL3pp_ttf.h:5332
constexpr SubStringIterator operator++(int)
Increment operator.
Definition: SDL3pp_ttf.h:5317
constexpr SubStringIterator & operator++()
Increment operator.
Definition: SDL3pp_ttf.h:5310
A collection of pixels used in software blitting.
Definition: SDL3pp_surface.h:227
A text engine used to create text objects.
Definition: SDL3pp_ttf.h:3998
constexpr TextEngineRaw release() noexcept
Retrieves underlying TextEngineRaw and clear this.
Definition: SDL3pp_ttf.h:4050
virtual void Destroy()=0
frees up textEngine. Pure virtual
constexpr TextEngineRaw get() const noexcept
Retrieves underlying TextEngineRaw.
Definition: SDL3pp_ttf.h:4047
constexpr TextEngine(const TextEngine &other) noexcept=default
Copy constructor.
constexpr auto operator<=>(const TextEngine &other) const noexcept=default
Comparison.
constexpr TextEngine(const TextEngineRaw resource) noexcept
Constructs from TextEngineParam.
Definition: SDL3pp_ttf.h:4015
constexpr TextEngine & operator=(const TextEngine &other) noexcept=default
Assignment operator.
virtual ~TextEngine()=default
Destructor.
constexpr TextEngine & operator=(TextEngine &&other) noexcept
Assignment operator.
Definition: SDL3pp_ttf.h:4035
constexpr TextEngine(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_ttf.h:4003
constexpr TextEngine(TextEngine &&other) noexcept
Move constructor.
Definition: SDL3pp_ttf.h:4026
Text created with Text.Text()
Definition: SDL3pp_ttf.h:4344
const char * GetText() const
A copy of the UTF-8 string that this text object represents, useful for layout, debugging and retriev...
Definition: SDL3pp_ttf.h:5229
int GetNumLines() const
The number of lines in the text, 0 if it's empty.
Definition: SDL3pp_ttf.h:5232
constexpr Text(const Text &other) noexcept=default
Copy constructor.
SubStringIterator GetSubStringForPoint(Point p) const
Get the portion of a text string that is closest to a point.
constexpr TextRaw release() noexcept
Retrieves underlying TextRaw and clear this.
Definition: SDL3pp_ttf.h:4428
constexpr TextRaw get() const noexcept
Retrieves underlying TextRaw.
Definition: SDL3pp_ttf.h:4425
constexpr TextRaw operator->() noexcept
member access to underlying TextRaw.
Definition: SDL3pp_ttf.h:4407
SubStringIterator begin() const
Get iterator to first substring.
constexpr const TextRaw operator->() const noexcept
member access to underlying TextRaw.
Definition: SDL3pp_ttf.h:4404
constexpr auto operator<=>(const Text &other) const noexcept=default
Comparison.
SubStringIterator end() const
Get iterator to one past last substring.
~Text()
Destructor.
Definition: SDL3pp_ttf.h:4410
OwnArray< SubString * > GetSubStrings() const
Get all substrings of a text object.
Definition: SDL3pp_ttf.h:5115
Text(TextEngineParam engine, FontParam font, std::string_view text)
Create a text object from UTF-8 text and a text engine.
Definition: SDL3pp_ttf.h:4398
constexpr Text & operator=(Text &&other) noexcept
Assignment operator.
Definition: SDL3pp_ttf.h:4413
SubStringIterator GetSubStringForLine(int line) const
Get iterator to substring of a text object that contains the given line.
constexpr Text(Text &&other) noexcept
Move constructor.
Definition: SDL3pp_ttf.h:4372
constexpr Text(const TextRaw resource) noexcept
Constructs from TextParam.
Definition: SDL3pp_ttf.h:4361
constexpr Text & operator=(const Text &other) noexcept=default
Assignment operator.
constexpr Text(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_ttf.h:4349
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:197
Color GetColor(Uint32 pixel, const PixelFormatDetails &format, PaletteConstParam palette={})
Get RGBA values from a pixel in the specified format.
Definition: SDL3pp_pixels.h:3086
SDL_Color ColorRaw
Alias to raw representation for Color.
Definition: SDL3pp_pixels.h:83
SDL_Point PointRaw
Alias to raw representation for Point.
Definition: SDL3pp_rect.h:22
Point GetPosition() const
Get the position of a text object.
Definition: SDL3pp_ttf.h:6213
FontRef GetFont() const
Get the font used by a text object.
Definition: SDL3pp_ttf.h:5860
void SetFontLanguage(FontParam font, StringParam language_bcp47)
Set language to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:3118
const char * GetFontFamilyName(FontParam font)
Query a font's family name.
Definition: SDL3pp_ttf.h:2906
constexpr FontStyleFlags STYLE_NORMAL
No special style.
Definition: SDL3pp_ttf.h:334
Uint32 GetGlyphScript(Uint32 ch)
Get the script used by a 32-bit codepoint.
Definition: SDL3pp_ttf.h:3091
void SetFontLineSkip(FontParam font, int lineskip)
Set the spacing between lines of text for a font.
Definition: SDL3pp_ttf.h:2771
constexpr SubStringFlags SUBSTRING_LINE_END
This substring contains the end of line line_index
Definition: SDL3pp_ttf.h:3958
constexpr HintingFlags HINTING_LIGHT
Light hinting applies subtle adjustments to improve rendering.
Definition: SDL3pp_ttf.h:370
void DrawSurface(Point p, SurfaceParam surface) const
Draw text to an SDL surface.
Definition: SDL3pp_ttf.h:5385
constexpr HorizontalAlignment HORIZONTAL_ALIGN_CENTER
CENTER.
Definition: SDL3pp_ttf.h:397
PropertiesRef GetTextProperties(TextConstParam text)
Get the properties associated with a text object.
Definition: SDL3pp_ttf.h:5750
void GetTextSubString(TextConstParam text, int offset, SubString *substring)
Get the substring of a text object that surrounds a text offset.
Definition: SDL3pp_ttf.h:6519
void GetNextTextSubString(TextConstParam text, const SubString &substring, SubString *next)
Get the next substring in a text object.
Definition: SDL3pp_ttf.h:6667
void Destroy() final
Destroy a text engine created for drawing text on SDL surfaces.
Definition: SDL3pp_ttf.h:5411
void SetFontSDF(FontParam font, bool enabled)
Enable Signed Distance Field rendering for a font.
Definition: SDL3pp_ttf.h:2589
constexpr HorizontalAlignment HORIZONTAL_ALIGN_RIGHT
RIGHT.
Definition: SDL3pp_ttf.h:400
Surface RenderGlyph_Solid(FontParam font, Uint32 ch, ColorRaw fg)
Render a single 32-bit glyph at fast quality to a new 8-bit surface.
Definition: SDL3pp_ttf.h:3512
int GetFontHeight(FontParam font)
Query the total height of a font.
Definition: SDL3pp_ttf.h:2720
void Destroy() final
Destroy a text engine created for drawing text on an SDL renderer.
Definition: SDL3pp_ttf.h:5531
TTF_GPUAtlasDrawSequence GPUAtlasDrawSequence
Draw sequence returned by Text.GetGPUDrawData.
Definition: SDL3pp_ttf.h:4306
void GetPreviousSubString(const SubString &substring, SubString *previous) const
Get the previous substring in a text object.
Definition: SDL3pp_ttf.h:6645
constexpr GPUTextEngineWinding GPU_TEXTENGINE_WINDING_COUNTER_CLOCKWISE
COUNTER_CLOCKWISE.
Definition: SDL3pp_ttf.h:3976
void MeasureString(FontParam font, std::string_view text, int max_width, int *measured_width, size_t *measured_length)
Calculate how much of a UTF-8 string will fit in a given width.
Definition: SDL3pp_ttf.h:3371
bool IsFixedWidth() const
Query whether a font is fixed-width.
Definition: SDL3pp_ttf.h:2867
TTF_Font * FontRaw
Alias to raw representation for Font.
Definition: SDL3pp_ttf.h:31
RendererTextEngine CreateRendererTextEngine(RendererParam renderer)
Create a text engine for drawing text on an SDL renderer.
Definition: SDL3pp_ttf.h:5432
constexpr SubStringFlags SUBSTRING_TEXT_START
This substring contains the beginning of the text.
Definition: SDL3pp_ttf.h:3950
const char * GetStyleName() const
Query a font's style name.
Definition: SDL3pp_ttf.h:2937
static Uint32 GetGlyphScript(Uint32 ch)
Get the script used by a 32-bit codepoint.
Definition: SDL3pp_ttf.h:3096
Surface RenderText_Shaded(FontParam font, std::string_view text, Color fg, Color bg)
Render UTF-8 text at high quality to a new 8-bit surface.
Definition: SDL3pp_ttf.h:3556
Surface RenderText_LCD(std::string_view text, Color fg, Color bg) const
Render UTF-8 text at LCD subpixel quality to a new ARGB surface.
Definition: SDL3pp_ttf.h:3837
HintingFlags GetFontHinting(FontParam font)
Query a font's current FreeType hinter setting.
Definition: SDL3pp_ttf.h:2556
void SetFontScript(FontParam font, Uint32 script)
Set the script to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:3048
int GetFontWeight(FontParam font)
Query a font's weight, in terms of the lightness/heaviness of the strokes.
Definition: SDL3pp_ttf.h:2625
void SetSizeDPI(float ptsize, int hdpi, int vdpi)
Set font size dynamically with target resolutions, in dots per inch.
Definition: SDL3pp_ttf.h:2324
constexpr int FONT_WEIGHT_BLACK
Black (900) named font weight value.
Definition: SDL3pp_ttf.h:2653
void SetLanguage(StringParam language_bcp47)
Set language to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:3123
void RemoveFallback(FontParam fallback)
Remove a fallback font.
Definition: SDL3pp_ttf.h:2248
void SetTextScript(TextParam text, Uint32 script)
Set the script to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5927
void GetTextColorFloat(TextConstParam text, float *r, float *g, float *b, float *a)
Get the color of a text object.
Definition: SDL3pp_ttf.h:6094
int GetFontOutline(FontParam font)
Query a font's current outline.
Definition: SDL3pp_ttf.h:2480
void DestroyRendererTextEngine(TextEngineRaw engine)
Destroy a text engine created for drawing text on an SDL renderer.
Definition: SDL3pp_ttf.h:5526
void DrawRenderer(FPoint p) const
Draw text to an SDL renderer.
Definition: SDL3pp_ttf.h:5505
constexpr SubStringFlags SUBSTRING_LINE_START
This substring contains the beginning of line line_index
Definition: SDL3pp_ttf.h:3955
void DestroyText(TextRaw text)
Destroy a text object created by a text engine.
Definition: SDL3pp_ttf.h:6711
void GetStringSize(FontParam font, std::string_view text, int *w, int *h)
Calculate the dimensions of a rendered string of UTF-8 text.
Definition: SDL3pp_ttf.h:3297
constexpr Direction DIRECTION_LTR
Left to Right.
Definition: SDL3pp_ttf.h:418
constexpr ImageType IMAGE_COLOR
The color channels have image data.
Definition: SDL3pp_ttf.h:438
bool SetFont(FontParam font)
Set the font used by a text object.
Definition: SDL3pp_ttf.h:5836
Direction GetFontDirection(FontParam font)
Get the direction to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:2982
Text CreateText(FontParam font, std::string_view text)
Create a text object from UTF-8 text and a text engine.
Definition: SDL3pp_ttf.h:5733
void DeleteTextString(TextParam text, int offset, int length)
Delete UTF-8 text from a text object.
Definition: SDL3pp_ttf.h:6438
OwnArray< SubString * > GetTextSubStringsForRange(TextConstParam text, int offset, int length)
Get the substrings of a text object that contain a range of text.
Definition: SDL3pp_ttf.h:6577
Uint32 StringToTag(StringParam string)
Convert from a 4 character string to a 32-bit tag.
Definition: SDL3pp_ttf.h:3004
HintingFlags GetHinting() const
Query a font's current FreeType hinter setting.
Definition: SDL3pp_ttf.h:2561
void GetTextSubStringForPoint(TextConstParam text, Point p, SubString *substring)
Get the portion of a text string that is closest to a point.
Definition: SDL3pp_ttf.h:6609
Surface GetGlyphImage(Uint32 ch, ImageType *image_type) const
Get the pixel image for a UNICODE codepoint.
Definition: SDL3pp_ttf.h:3170
void SetFontSizeDPI(FontParam font, float ptsize, int hdpi, int vdpi)
Set font size dynamically with target resolutions, in dots per inch.
Definition: SDL3pp_ttf.h:2319
Uint32 SubStringFlags
Flags for SubString.
Definition: SDL3pp_ttf.h:3944
const char * GetFamilyName() const
Query a font's family name.
Definition: SDL3pp_ttf.h:2911
void ClearFallbacks()
Remove all fallback fonts.
Definition: SDL3pp_ttf.h:2270
void SetString(std::string_view string)
Set the UTF-8 text used by a text object.
Definition: SDL3pp_ttf.h:6348
Uint32 GetTextScript(TextConstParam text)
Get the script used for text shaping a text object.
Definition: SDL3pp_ttf.h:5954
Direction GetDirection() const
Get the direction to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5905
TTF_HintingFlags HintingFlags
Hinting flags for TTF (TrueType Fonts)
Definition: SDL3pp_ttf.h:358
int GetWrapWidth() const
Get whether wrapping is enabled on a text object.
Definition: SDL3pp_ttf.h:6267
Point GetSize() const
Get the size of a text object.
Definition: SDL3pp_ttf.h:6497
bool FontHasGlyph(FontParam font, Uint32 ch)
Check whether a glyph is provided by the font for a UNICODE codepoint.
Definition: SDL3pp_ttf.h:3140
void SetStyle(FontStyleFlags style)
Set a font's current style.
Definition: SDL3pp_ttf.h:2402
RendererTextEngine CreateRendererTextEngineWithProperties(PropertiesParam props)
Create a text engine for drawing text on an SDL renderer, with the specified properties.
Definition: SDL3pp_ttf.h:5461
Surface GetGlyphImageForIndex(Uint32 glyph_index, ImageType *image_type) const
Get the pixel image for a character index.
Definition: SDL3pp_ttf.h:3200
void SetWrapWhitespaceVisible(bool visible)
Set whether whitespace should be visible when wrapping a text object.
Definition: SDL3pp_ttf.h:6297
void SetDirection(Direction direction)
Set the direction to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5882
constexpr ImageType IMAGE_INVALID
INVALID.
Definition: SDL3pp_ttf.h:433
FontStyleFlags GetStyle() const
Query a font's current style.
Definition: SDL3pp_ttf.h:2432
Surface RenderText_Solid_Wrapped(std::string_view text, Color fg, int wrapLength) const
Render word-wrapped UTF-8 text at fast quality to a new 8-bit surface.
Definition: SDL3pp_ttf.h:3478
void GetHarfBuzzVersion(int *major, int *minor, int *patch)
Query the version of the HarfBuzz library in use.
Definition: SDL3pp_ttf.h:315
void SetOutline(int outline)
Set a font's current outline.
Definition: SDL3pp_ttf.h:2463
Surface RenderText_Blended_Wrapped(std::string_view text, Color fg, int wrap_width) const
Render word-wrapped UTF-8 text at high quality to a new ARGB surface.
Definition: SDL3pp_ttf.h:3752
constexpr HintingFlags HINTING_INVALID
INVALID.
Definition: SDL3pp_ttf.h:362
int GetHeight() const
Query the total height of a font.
Definition: SDL3pp_ttf.h:2722
void GetTextPosition(TextConstParam text, int *x, int *y)
Get the position of a text object.
Definition: SDL3pp_ttf.h:6181
bool GetKerning() const
Query whether or not kerning is enabled for a font.
Definition: SDL3pp_ttf.h:2844
Surface RenderText_Solid(std::string_view text, Color fg) const
Render UTF-8 text at fast quality to a new 8-bit surface.
Definition: SDL3pp_ttf.h:3432
GPUTextEngine CreateGPUTextEngineWithProperties(PropertiesParam props)
Create a text engine for drawing text with the SDL GPU API, with the specified properties.
Definition: SDL3pp_ttf.h:5581
void DestroySurfaceTextEngine(TextEngineRaw engine)
Destroy a text engine created for drawing text on SDL surfaces.
Definition: SDL3pp_ttf.h:5406
int GetTextWrapWidth(TextConstParam text)
Get whether wrapping is enabled on a text object.
Definition: SDL3pp_ttf.h:6260
int GetOutline() const
Query a font's current outline.
Definition: SDL3pp_ttf.h:2482
constexpr int FONT_WEIGHT_EXTRA_LIGHT
ExtraLight (200) named font weight value.
Definition: SDL3pp_ttf.h:2632
bool GetFontKerning(FontParam font)
Query whether or not kerning is enabled for a font.
Definition: SDL3pp_ttf.h:2842
void GetTextSubStringForLine(TextConstParam text, int line, SubString *substring)
Get the substring of a text object that contains the given line.
Definition: SDL3pp_ttf.h:6550
Uint32 FontStyleFlags
Font style flags for Font.
Definition: SDL3pp_ttf.h:332
void SetGPUWinding(GPUTextEngineWinding winding)
Sets the winding order of the vertices returned by Text.GetGPUDrawData for a particular GPU text engi...
Definition: SDL3pp_ttf.h:5678
void SetFontKerning(FontParam font, bool enabled)
Set if kerning is enabled for a font.
Definition: SDL3pp_ttf.h:2820
Font CopyFont(FontParam existing_font)
Create a copy of an existing font.
Definition: SDL3pp_ttf.h:2133
void GetGlyphMetrics(FontParam font, Uint32 ch, int *minx, int *maxx, int *miny, int *maxy, int *advance)
Query the metrics (dimensions) of a font's glyph for a UNICODE codepoint.
Definition: SDL3pp_ttf.h:3234
void SetColor(Color c)
Set the color of a text object.
Definition: SDL3pp_ttf.h:5983
bool IsWrapWhitespaceVisible() const
Return whether whitespace is shown when wrapping a text object.
Definition: SDL3pp_ttf.h:6320
float GetSize() const
Get the size of a font.
Definition: SDL3pp_ttf.h:2346
int GetGlyphKerning(Uint32 previous_ch, Uint32 ch) const
Query the kerning size between the glyphs of two UNICODE codepoints.
Definition: SDL3pp_ttf.h:3275
Surface RenderText_Blended(std::string_view text, Color fg) const
Render UTF-8 text at high quality to a new ARGB surface.
Definition: SDL3pp_ttf.h:3706
void InsertTextString(TextParam text, int offset, std::string_view string)
Insert UTF-8 text into a text object.
Definition: SDL3pp_ttf.h:6375
Surface RenderText_Solid(FontParam font, std::string_view text, Color fg)
Render UTF-8 text at fast quality to a new 8-bit surface.
Definition: SDL3pp_ttf.h:3427
bool TextWrapWhitespaceVisible(TextConstParam text)
Return whether whitespace is shown when wrapping a text object.
Definition: SDL3pp_ttf.h:6315
int GetFontLineSkip(FontParam font)
Query the spacing between lines of text for a font.
Definition: SDL3pp_ttf.h:2793
Surface RenderGlyph_Blended(Uint32 ch, ColorRaw fg) const
Render a single UNICODE codepoint at high quality to a new ARGB surface.
Definition: SDL3pp_ttf.h:3791
constexpr Direction DIRECTION_BTT
Bottom to Top.
Definition: SDL3pp_ttf.h:424
constexpr HintingFlags HINTING_MONO
Monochrome hinting adjusts the font for better rendering at lower resolutions.
Definition: SDL3pp_ttf.h:376
GPUTextEngine CreateGPUTextEngine(GPUDeviceParam device)
Create a text engine for drawing text with the SDL GPU API.
Definition: SDL3pp_ttf.h:5552
void SetSDF(bool enabled)
Enable Signed Distance Field rendering for a font.
Definition: SDL3pp_ttf.h:2594
Font OpenFontWithProperties(PropertiesParam props)
Create a font with the specified properties.
Definition: SDL3pp_ttf.h:2070
constexpr int FONT_WEIGHT_EXTRA_BOLD
ExtraBold (800) named font weight value.
Definition: SDL3pp_ttf.h:2650
void GetFontDPI(FontParam font, int *hdpi, int *vdpi)
Get font target resolutions, in dots per inch.
Definition: SDL3pp_ttf.h:2363
void SetScript(Uint32 script)
Set the script to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5932
void SetWrapWidth(int wrap_width)
Set whether wrapping is enabled on a text object.
Definition: SDL3pp_ttf.h:6240
constexpr FontStyleFlags STYLE_ITALIC
Italic style.
Definition: SDL3pp_ttf.h:338
Uint32 GetFontGeneration(FontParam font)
Get the font generation.
Definition: SDL3pp_ttf.h:2185
void SetLineSkip(int lineskip)
Set the spacing between lines of text for a font.
Definition: SDL3pp_ttf.h:2776
void AppendTextString(TextParam text, std::string_view string)
Append UTF-8 text to a text object.
Definition: SDL3pp_ttf.h:6405
bool GetSDF() const
Query whether Signed Distance Field rendering is enabled for a font.
Definition: SDL3pp_ttf.h:2610
void SetPosition(const PointRaw &p)
Set the position of a text object.
Definition: SDL3pp_ttf.h:6159
void SetKerning(bool enabled)
Set if kerning is enabled for a font.
Definition: SDL3pp_ttf.h:2825
float GetFontSize(FontParam font)
Get the size of a font.
Definition: SDL3pp_ttf.h:2344
bool IsScalable() const
Query whether a font is scalable or not.
Definition: SDL3pp_ttf.h:2888
void SetFontDirection(FontParam font, Direction direction)
Set the direction to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:2959
Uint32 GetFontScript(FontParam font)
Get the script used for text shaping a font.
Definition: SDL3pp_ttf.h:3073
Surface RenderText_LCD_Wrapped(std::string_view text, Color fg, Color bg, int wrap_width) const
Render word-wrapped UTF-8 text at LCD subpixel quality to a new ARGB surface.
Definition: SDL3pp_ttf.h:3887
void GetFreeTypeVersion(int *major, int *minor, int *patch)
Query the version of the FreeType library in use.
Definition: SDL3pp_ttf.h:297
void TagToString(Uint32 tag, char *string, size_t size)
Convert from a 32-bit tag to a 4 character string.
Definition: SDL3pp_ttf.h:3024
TTF_GPUTextEngineWinding GPUTextEngineWinding
The winding order of the vertices returned by Text.GetGPUDrawData.
Definition: SDL3pp_ttf.h:3968
constexpr FontStyleFlags STYLE_BOLD
Bold style.
Definition: SDL3pp_ttf.h:336
constexpr FontStyleFlags STYLE_STRIKETHROUGH
Strikethrough text.
Definition: SDL3pp_ttf.h:343
constexpr int FONT_WEIGHT_THIN
Thin (100) named font weight value.
Definition: SDL3pp_ttf.h:2629
void GetNextSubString(const SubString &substring, SubString *next) const
Get the next substring in a text object.
Definition: SDL3pp_ttf.h:6674
bool FontIsScalable(FontParam font)
Query whether a font is scalable or not.
Definition: SDL3pp_ttf.h:2886
void SetColorFloat(FColor c)
Set the color of a text object.
Definition: SDL3pp_ttf.h:6007
constexpr Direction DIRECTION_RTL
Right to Left.
Definition: SDL3pp_ttf.h:420
TTF_ImageType ImageType
The type of data in a glyph image.
Definition: SDL3pp_ttf.h:431
Direction GetDirection() const
Get the direction to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:2987
GPUTextEngineWinding GetGPUWinding() const
Get the winding order of the vertices returned by Text.GetGPUDrawData for a particular GPU text engin...
Definition: SDL3pp_ttf.h:5704
Uint32 GetGeneration() const
Get the font generation.
Definition: SDL3pp_ttf.h:2190
void SetFontSize(FontParam font, float ptsize)
Set a font's size dynamically.
Definition: SDL3pp_ttf.h:2289
int GetDescent() const
Query the offset from the baseline to the bottom of a font.
Definition: SDL3pp_ttf.h:2754
Surface RenderGlyph_Solid(Uint32 ch, ColorRaw fg) const
Render a single 32-bit glyph at fast quality to a new 8-bit surface.
Definition: SDL3pp_ttf.h:3517
TTF_TextEngine * TextEngineRaw
Alias to raw representation for TextEngine.
Definition: SDL3pp_ttf.h:67
int GetFontDescent(FontParam font)
Query the offset from the baseline to the bottom of a font.
Definition: SDL3pp_ttf.h:2752
void Update()
Update the layout of a text object.
Definition: SDL3pp_ttf.h:6697
void GetStringSizeWrapped(FontParam font, std::string_view text, int wrap_width, int *w, int *h)
Calculate the dimensions of a rendered string of UTF-8 text.
Definition: SDL3pp_ttf.h:3330
constexpr HintingFlags HINTING_NORMAL
Normal hinting applies standard grid-fitting.
Definition: SDL3pp_ttf.h:366
int GetGlyphKerning(FontParam font, Uint32 previous_ch, Uint32 ch)
Query the kerning size between the glyphs of two UNICODE codepoints.
Definition: SDL3pp_ttf.h:3269
void MeasureString(std::string_view text, int max_width, int *measured_width, size_t *measured_length) const
Calculate how much of a UTF-8 string will fit in a given width.
Definition: SDL3pp_ttf.h:3385
constexpr HorizontalAlignment HORIZONTAL_ALIGN_INVALID
INVALID.
Definition: SDL3pp_ttf.h:391
TextEngineParam GetEngine() const
Get the text engine used by a text object.
Definition: SDL3pp_ttf.h:5805
void SetTextString(TextParam text, std::string_view string)
Set the UTF-8 text used by a text object.
Definition: SDL3pp_ttf.h:6343
void SetTextDirection(TextParam text, Direction direction)
Set the direction to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5877
Surface RenderText_Shaded_Wrapped(FontParam font, std::string_view text, Color fg, Color bg, int wrap_width)
Render word-wrapped UTF-8 text at high quality to a new 8-bit surface.
Definition: SDL3pp_ttf.h:3605
bool HasGlyph(Uint32 ch) const
Check whether a glyph is provided by the font for a UNICODE codepoint.
Definition: SDL3pp_ttf.h:3145
constexpr Direction DIRECTION_INVALID
INVALID.
Definition: SDL3pp_ttf.h:416
FontStyleFlags GetFontStyle(FontParam font)
Query a font's current style.
Definition: SDL3pp_ttf.h:2427
const char * GetFontStyleName(FontParam font)
Query a font's style name.
Definition: SDL3pp_ttf.h:2932
constexpr HintingFlags HINTING_NONE
No hinting, the font is rendered without any grid-fitting.
Definition: SDL3pp_ttf.h:379
TTF_SubString SubString
The representation of a substring within text.
Definition: SDL3pp_ttf.h:4320
constexpr int FONT_WEIGHT_BOLD
Bold (700) named font weight value.
Definition: SDL3pp_ttf.h:2647
Surface RenderGlyph_Shaded(Uint32 ch, ColorRaw fg, ColorRaw bg) const
Render a single UNICODE codepoint at high quality to a new 8-bit surface.
Definition: SDL3pp_ttf.h:3660
constexpr ImageType IMAGE_ALPHA
The color channels are white.
Definition: SDL3pp_ttf.h:435
void SetWrapAlignment(HorizontalAlignment align)
Set a font's current wrap alignment option.
Definition: SDL3pp_ttf.h:2681
void GetTextSize(TextConstParam text, int *w, int *h)
Get the size of a text object.
Definition: SDL3pp_ttf.h:6465
void SetTextWrapWhitespaceVisible(TextParam text, bool visible)
Set whether whitespace should be visible when wrapping a text object.
Definition: SDL3pp_ttf.h:6292
constexpr int FONT_WEIGHT_MEDIUM
Medium (500) named font weight value.
Definition: SDL3pp_ttf.h:2641
void ClearFallbackFonts(FontParam font)
Remove all fallback fonts.
Definition: SDL3pp_ttf.h:2268
void UpdateText(TextParam text)
Update the layout of a text object.
Definition: SDL3pp_ttf.h:6695
FontRef GetTextFont(TextConstParam text)
Get the font used by a text object.
Definition: SDL3pp_ttf.h:5855
Surface RenderText_Shaded_Wrapped(std::string_view text, Color fg, Color bg, int wrap_width) const
Render word-wrapped UTF-8 text at high quality to a new 8-bit surface.
Definition: SDL3pp_ttf.h:3615
void SetFontStyle(FontParam font, FontStyleFlags style)
Set a font's current style.
Definition: SDL3pp_ttf.h:2397
Surface RenderText_Blended_Wrapped(FontParam font, std::string_view text, Color fg, int wrap_width)
Render word-wrapped UTF-8 text at high quality to a new ARGB surface.
Definition: SDL3pp_ttf.h:3743
void SetGPUTextEngineWinding(TextEngineParam engine, GPUTextEngineWinding winding)
Sets the winding order of the vertices returned by Text.GetGPUDrawData for a particular GPU text engi...
Definition: SDL3pp_ttf.h:5672
HorizontalAlignment GetFontWrapAlignment(FontParam font)
Query a font's current wrap alignment option.
Definition: SDL3pp_ttf.h:2698
int GetWeight() const
Query a font's weight, in terms of the lightness/heaviness of the strokes.
Definition: SDL3pp_ttf.h:2627
Surface RenderText_Shaded(std::string_view text, Color fg, Color bg) const
Render UTF-8 text at high quality to a new 8-bit surface.
Definition: SDL3pp_ttf.h:3564
constexpr GPUTextEngineWinding GPU_TEXTENGINE_WINDING_INVALID
INVALID.
Definition: SDL3pp_ttf.h:3970
void SetDirection(Direction direction)
Set the direction to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:2964
void SetScript(Uint32 script)
Set the script to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:3053
bool FontIsFixedWidth(FontParam font)
Query whether a font is fixed-width.
Definition: SDL3pp_ttf.h:2862
int GetLineSkip() const
Query the spacing between lines of text for a font.
Definition: SDL3pp_ttf.h:2795
void Close()
Dispose of a previously-created font.
Definition: SDL3pp_ttf.h:6739
bool GetFontSDF(FontParam font)
Query whether Signed Distance Field rendering is enabled for a font.
Definition: SDL3pp_ttf.h:2608
Surface RenderGlyph_LCD(Uint32 ch, ColorRaw fg, ColorRaw bg) const
Render a single UNICODE codepoint at LCD subpixel quality to a new ARGB surface.
Definition: SDL3pp_ttf.h:3932
void InsertString(int offset, std::string_view string)
Insert UTF-8 text into a text object.
Definition: SDL3pp_ttf.h:6382
HorizontalAlignment GetWrapAlignment() const
Query a font's current wrap alignment option.
Definition: SDL3pp_ttf.h:2703
void AddFallback(FontParam fallback)
Add a fallback font.
Definition: SDL3pp_ttf.h:2222
void DestroyGPUTextEngine(TextEngineRaw engine)
Destroy a text engine created for drawing text with the SDL GPU API.
Definition: SDL3pp_ttf.h:5650
Surface RenderText_Blended(FontParam font, std::string_view text, Color fg)
Render UTF-8 text at high quality to a new ARGB surface.
Definition: SDL3pp_ttf.h:3699
int GetFontAscent(FontParam font)
Query the offset from the baseline to the top of a font.
Definition: SDL3pp_ttf.h:2736
void SetTextPosition(TextParam text, const PointRaw &p)
Set the position of a text object.
Definition: SDL3pp_ttf.h:6154
void DrawSurfaceText(TextConstParam text, Point p, SurfaceParam surface)
Draw text to an SDL surface.
Definition: SDL3pp_ttf.h:5380
GPUTextEngineWinding GetGPUTextEngineWinding(TextEngineParam engine)
Get the winding order of the vertices returned by Text.GetGPUDrawData for a particular GPU text engin...
Definition: SDL3pp_ttf.h:5699
TTF_TextData TextData
Internal data for Text.
Definition: SDL3pp_ttf.h:4330
void AddFallbackFont(FontParam font, FontParam fallback)
Add a fallback font.
Definition: SDL3pp_ttf.h:2217
OwnArray< SubString * > GetSubStringsForRange(int offset, int length=-1) const
Get the substrings of a text object that contain a range of text.
Definition: SDL3pp_ttf.h:6586
void GetSubString(int offset, SubString *substring) const
Get the substring of a text object that surrounds a text offset.
Definition: SDL3pp_ttf.h:6526
void SetTextWrapWidth(TextParam text, int wrap_width)
Set whether wrapping is enabled on a text object.
Definition: SDL3pp_ttf.h:6235
constexpr FontStyleFlags STYLE_UNDERLINE
Underlined text.
Definition: SDL3pp_ttf.h:340
constexpr int FONT_WEIGHT_EXTRA_BLACK
ExtraBlack (950) named font weight value.
Definition: SDL3pp_ttf.h:2656
void AppendString(std::string_view string)
Append UTF-8 text to a text object.
Definition: SDL3pp_ttf.h:6410
Direction GetTextDirection(TextConstParam text)
Get the direction to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5900
constexpr SubStringFlags SUBSTRING_TEXT_END
This substring contains the end of the text.
Definition: SDL3pp_ttf.h:3960
Font Copy() const
Create a copy of an existing font.
Definition: SDL3pp_ttf.h:2138
constexpr SubStringFlags SUBSTRING_DIRECTION_MASK
The mask for the flow direction for this substring.
Definition: SDL3pp_ttf.h:3946
Surface RenderText_Solid_Wrapped(FontParam font, std::string_view text, Color fg, int wrapLength)
Render word-wrapped UTF-8 text at fast quality to a new 8-bit surface.
Definition: SDL3pp_ttf.h:3469
TTF_HorizontalAlignment HorizontalAlignment
The horizontal alignment used when rendering wrapped text.
Definition: SDL3pp_ttf.h:389
PropertiesRef GetProperties() const
Get the properties associated with a text object.
Definition: SDL3pp_ttf.h:5755
constexpr Direction DIRECTION_TTB
Top to Bottom.
Definition: SDL3pp_ttf.h:422
int GetNumFaces() const
Query the number of faces of a font.
Definition: SDL3pp_ttf.h:2530
void SetTextColor(TextParam text, Color c)
Set the color of a text object.
Definition: SDL3pp_ttf.h:5978
void RemoveFallbackFont(FontParam font, FontParam fallback)
Remove a fallback font.
Definition: SDL3pp_ttf.h:2243
void GetPreviousTextSubString(TextConstParam text, const SubString &substring, SubString *previous)
Get the previous substring in a text object.
Definition: SDL3pp_ttf.h:6638
Color GetColor() const
Get the color of a text object.
Definition: SDL3pp_ttf.h:6070
Surface RenderGlyph_LCD(FontParam font, Uint32 ch, ColorRaw fg, ColorRaw bg)
Render a single UNICODE codepoint at LCD subpixel quality to a new ARGB surface.
Definition: SDL3pp_ttf.h:3924
void SetEngine(TextEngineParam engine)
Set the text engine used by a text object.
Definition: SDL3pp_ttf.h:5781
TextEngineParam GetTextEngine(TextConstParam text)
Get the text engine used by a text object.
Definition: SDL3pp_ttf.h:5800
void SetSize(float ptsize)
Set a font's size dynamically.
Definition: SDL3pp_ttf.h:2294
constexpr HintingFlags HINTING_LIGHT_SUBPIXEL
Light hinting with subpixel rendering for more precise font edges.
Definition: SDL3pp_ttf.h:382
void DeleteString(int offset, int length)
Delete UTF-8 text from a text object.
Definition: SDL3pp_ttf.h:6443
void SetFontOutline(FontParam font, int outline)
Set a font's current outline.
Definition: SDL3pp_ttf.h:2458
SurfaceTextEngine CreateSurfaceTextEngine()
Create a text engine for drawing text on SDL surfaces.
Definition: SDL3pp_ttf.h:5355
void GetDPI(int *hdpi, int *vdpi) const
Get font target resolutions, in dots per inch.
Definition: SDL3pp_ttf.h:2368
Font OpenFont(StringParam file, float ptsize)
Create a font from a file, using a specified point size.
Definition: SDL3pp_ttf.h:1993
void Destroy()
Destroy a text object created by a text engine.
Definition: SDL3pp_ttf.h:6713
PropertiesRef GetFontProperties(FontParam font)
Get the properties associated with a font.
Definition: SDL3pp_ttf.h:2160
Surface GetGlyphImageForIndex(FontParam font, Uint32 glyph_index, ImageType *image_type)
Get the pixel image for a character index.
Definition: SDL3pp_ttf.h:3193
Surface RenderText_LCD(FontParam font, std::string_view text, Color fg, Color bg)
Render UTF-8 text at LCD subpixel quality to a new ARGB surface.
Definition: SDL3pp_ttf.h:3829
void SetFontWrapAlignment(FontParam font, HorizontalAlignment align)
Set a font's current wrap alignment option.
Definition: SDL3pp_ttf.h:2676
void SetHinting(HintingFlags hinting)
Set a font's current hinter setting.
Definition: SDL3pp_ttf.h:2513
GPUAtlasDrawSequence * GetGPUDrawData() const
Get the geometry data needed for drawing the text.
Definition: SDL3pp_ttf.h:5630
TTF_Text * TextRaw
Alias to raw representation for Text.
Definition: SDL3pp_ttf.h:100
void DrawRendererText(TextConstParam text, FPoint p)
Draw text to an SDL renderer.
Definition: SDL3pp_ttf.h:5500
FColor GetColorFloat() const
Get the color of a text object.
Definition: SDL3pp_ttf.h:6130
void GetGlyphMetrics(Uint32 ch, int *minx, int *maxx, int *miny, int *maxy, int *advance) const
Query the metrics (dimensions) of a font's glyph for a UNICODE codepoint.
Definition: SDL3pp_ttf.h:3245
Uint32 GetScript() const
Get the script used for text shaping a font.
Definition: SDL3pp_ttf.h:3075
void GetTextColor(TextConstParam text, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Get the color of a text object.
Definition: SDL3pp_ttf.h:6034
constexpr HorizontalAlignment HORIZONTAL_ALIGN_LEFT
LEFT.
Definition: SDL3pp_ttf.h:394
void SetTextEngine(TextParam text, TextEngineParam engine)
Set the text engine used by a text object.
Definition: SDL3pp_ttf.h:5776
constexpr int FONT_WEIGHT_SEMI_BOLD
SemiBold (600) named font weight value.
Definition: SDL3pp_ttf.h:2644
void CloseFont(FontRaw font)
Dispose of a previously-created font.
Definition: SDL3pp_ttf.h:6737
int GetAscent() const
Query the offset from the baseline to the top of a font.
Definition: SDL3pp_ttf.h:2738
PropertiesRef GetProperties()
Get the properties associated with a font.
Definition: SDL3pp_ttf.h:2165
Uint32 GetScript() const
Get the script used for text shaping a text object.
Definition: SDL3pp_ttf.h:5959
bool SetTextFont(TextParam text, FontParam font)
Set the font used by a text object.
Definition: SDL3pp_ttf.h:5831
Surface RenderText_LCD_Wrapped(FontParam font, std::string_view text, Color fg, Color bg, int wrap_width)
Render word-wrapped UTF-8 text at LCD subpixel quality to a new ARGB surface.
Definition: SDL3pp_ttf.h:3877
constexpr int FONT_WEIGHT_NORMAL
Normal (400) named font weight value.
Definition: SDL3pp_ttf.h:2638
int GetNumFontFaces(FontParam font)
Query the number of faces of a font.
Definition: SDL3pp_ttf.h:2528
Surface RenderGlyph_Shaded(FontParam font, Uint32 ch, ColorRaw fg, ColorRaw bg)
Render a single UNICODE codepoint at high quality to a new 8-bit surface.
Definition: SDL3pp_ttf.h:3652
Surface GetGlyphImage(FontParam font, Uint32 ch, ImageType *image_type)
Get the pixel image for a UNICODE codepoint.
Definition: SDL3pp_ttf.h:3165
TTF_Direction Direction
Direction flags.
Definition: SDL3pp_ttf.h:414
Surface RenderGlyph_Blended(FontParam font, Uint32 ch, ColorRaw fg)
Render a single UNICODE codepoint at high quality to a new ARGB surface.
Definition: SDL3pp_ttf.h:3786
constexpr ImageType IMAGE_SDF
The alpha channel has signed distance field information.
Definition: SDL3pp_ttf.h:442
constexpr int FONT_WEIGHT_LIGHT
Light (300) named font weight value.
Definition: SDL3pp_ttf.h:2635
void SetFontHinting(FontParam font, HintingFlags hinting)
Set a font's current hinter setting.
Definition: SDL3pp_ttf.h:2508
void Destroy() final
Destroy a text engine created for drawing text with the SDL GPU API.
Definition: SDL3pp_ttf.h:5655
GPUAtlasDrawSequence * GetGPUTextDrawData(TextConstParam text)
Get the geometry data needed for drawing the text.
Definition: SDL3pp_ttf.h:5625
constexpr GPUTextEngineWinding GPU_TEXTENGINE_WINDING_CLOCKWISE
CLOCKWISE.
Definition: SDL3pp_ttf.h:3973
void SetTextColorFloat(TextParam text, FColor c)
Set the color of a text object.
Definition: SDL3pp_ttf.h:6002
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:341
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:289
Main include header for the SDL3pp library.
A structure that represents a color as RGBA components.
Definition: SDL3pp_pixels.h:2192
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition: SDL3pp_pixels.h:2365
The structure that defines a point (using floating point values).
Definition: SDL3pp_rect.h:512
Safely wrap Font for non owning parameters.
Definition: SDL3pp_ttf.h:38
constexpr FontParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_ttf.h:48
constexpr FontParam(FontRaw value)
Constructs from FontRaw.
Definition: SDL3pp_ttf.h:42
FontRaw value
parameter's FontRaw
Definition: SDL3pp_ttf.h:39
constexpr auto operator<=>(const FontParam &other) const =default
Comparison.
Semi-safe reference for Font.
Definition: SDL3pp_ttf.h:1939
constexpr FontRef(const FontRef &other) noexcept=default
Copy constructor.
~FontRef()
Destructor.
Definition: SDL3pp_ttf.h:1970
FontRef(FontParam resource) noexcept
Constructs from FontParam.
Definition: SDL3pp_ttf.h:1949
FontRef(FontRaw resource) noexcept
Constructs from FontParam.
Definition: SDL3pp_ttf.h:1961
Safely wrap GPUDevice for non owning parameters.
Definition: SDL3pp_gpu.h:387
A GPU based text engine.
Definition: SDL3pp_ttf.h:4199
GPUTextEngine(PropertiesParam props)
Create a text engine for drawing text with the SDL GPU API, with the specified properties.
Definition: SDL3pp_ttf.h:4245
GPUTextEngine(GPUDeviceParam device)
Create a text engine for drawing text with the SDL GPU API.
Definition: SDL3pp_ttf.h:4216
Safely wrap IOStream for non owning parameters.
Definition: SDL3pp_iostream.h:34
The structure that defines a point (using integers).
Definition: SDL3pp_rect.h:83
Safely wrap Properties for non owning parameters.
Definition: SDL3pp_properties.h:53
Semi-safe reference for Properties.
Definition: SDL3pp_properties.h:716
Safely wrap Renderer for non owning parameters.
Definition: SDL3pp_render.h:54
A renderer based text engine.
Definition: SDL3pp_ttf.h:4128
RendererTextEngine(PropertiesParam props)
Create a text engine for drawing text on an SDL renderer, with the specified properties.
Definition: SDL3pp_ttf.h:4174
RendererTextEngine(RendererParam renderer)
Create a text engine for drawing text on an SDL renderer.
Definition: SDL3pp_ttf.h:4145
Safely wrap Surface for non owning parameters.
Definition: SDL3pp_surface.h:53
A surface based text engine.
Definition: SDL3pp_ttf.h:4089
SurfaceTextEngine()
Create a text engine for drawing text on SDL surfaces.
Definition: SDL3pp_ttf.h:4103
Safely wrap Text for non owning const parameters.
Definition: SDL3pp_ttf.h:137
constexpr auto operator<=>(const TextConstParam &other) const =default
Comparison.
const TextRaw value
parameter's const TextRaw
Definition: SDL3pp_ttf.h:138
constexpr TextConstParam(TextParam value)
Constructs from TextParam.
Definition: SDL3pp_ttf.h:147
constexpr TextConstParam(const TextRaw value)
Constructs from const TextRaw.
Definition: SDL3pp_ttf.h:141
constexpr TextConstParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_ttf.h:153
constexpr auto operator->()
member access to underlying TextRaw.
Definition: SDL3pp_ttf.h:168
Safely wrap TextEngine for non owning parameters.
Definition: SDL3pp_ttf.h:71
constexpr TextEngineParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_ttf.h:81
constexpr auto operator<=>(const TextEngineParam &other) const =default
Comparison.
constexpr TextEngineParam(TextEngineRaw value)
Constructs from TextEngineRaw.
Definition: SDL3pp_ttf.h:75
TextEngineRaw value
parameter's TextEngineRaw
Definition: SDL3pp_ttf.h:72
Safely wrap Text for non owning parameters.
Definition: SDL3pp_ttf.h:107
constexpr auto operator<=>(const TextParam &other) const =default
Comparison.
constexpr TextParam(TextRaw value)
Constructs from TextRaw.
Definition: SDL3pp_ttf.h:111
TextRaw value
parameter's TextRaw
Definition: SDL3pp_ttf.h:108
constexpr TextParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_ttf.h:117
constexpr auto operator->()
member access to underlying TextRaw.
Definition: SDL3pp_ttf.h:132
Semi-safe reference for Text.
Definition: SDL3pp_ttf.h:5237
TextRef(TextRaw resource) noexcept
Constructs from TextParam.
Definition: SDL3pp_ttf.h:5259
TextRef(TextParam resource=nullptr) noexcept
Constructs from TextParam.
Definition: SDL3pp_ttf.h:5247
~TextRef()
Destructor.
Definition: SDL3pp_ttf.h:5268
constexpr TextRef(const TextRef &other) noexcept=default
Copy constructor.