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_DISABLE_TTF) && !defined(SDL3PP_ENABLE_TTF) && \
11 __has_include(<SDL3_ttf/SDL_ttf.h>)
12#define SDL3PP_ENABLE_TTF
13#endif
14
15#if defined(SDL3PP_ENABLE_TTF) || defined(SDL3PP_DOC)
16
17#include <SDL3_ttf/SDL_ttf.h>
18
19namespace SDL {
20
32// Forward decl
33struct Font;
34
36using FontRaw = TTF_Font*;
37
38// Forward decl
39struct FontRef;
40
43{
45
48 : value(value)
49 {
50 }
51
53 constexpr FontParam(std::nullptr_t _ = nullptr)
54 : value(nullptr)
55 {
56 }
57
59 constexpr explicit operator bool() const { return !!value; }
60
62 constexpr auto operator<=>(const FontParam& other) const = default;
63
65 constexpr operator FontRaw() const { return value; }
66};
67
68// Forward decl
69struct TextEngine;
70
72using TextEngineRaw = TTF_TextEngine*;
73
76{
78
81 : value(value)
82 {
83 }
84
86 constexpr TextEngineParam(std::nullptr_t _ = nullptr)
87 : value(nullptr)
88 {
89 }
90
92 constexpr explicit operator bool() const { return !!value; }
93
95 constexpr auto operator<=>(const TextEngineParam& other) const = default;
96
98 constexpr operator TextEngineRaw() const { return value; }
99};
100
101// Forward decl
102struct Text;
103
105using TextRaw = TTF_Text*;
106
107// Forward decl
108struct TextRef;
109
112{
114
117 : value(value)
118 {
119 }
120
122 constexpr TextParam(std::nullptr_t _ = nullptr)
123 : value(nullptr)
124 {
125 }
126
128 constexpr explicit operator bool() const { return !!value; }
129
131 constexpr auto operator<=>(const TextParam& other) const = default;
132
134 constexpr operator TextRaw() const { return value; }
135
137 constexpr auto operator->() { return value; }
138};
139
142{
144
146 constexpr TextConstParam(const TextRaw value)
147 : value(value)
148 {
149 }
150
153 : value(value.value)
154 {
155 }
156
158 constexpr TextConstParam(std::nullptr_t _ = nullptr)
159 : value(nullptr)
160 {
161 }
162
164 constexpr explicit operator bool() const { return !!value; }
165
167 constexpr auto operator<=>(const TextConstParam& other) const = default;
168
170 constexpr operator const TextRaw() const { return value; }
171
173 constexpr auto operator->() { return value; }
174};
175
176#ifdef SDL3PP_DOC
177
183#define SDL_TTF_MAJOR_VERSION
184
185#define SDL_TTF_MINOR_VERSION
186
187#define SDL_TTF_MICRO_VERSION
188
190
194#define SDL_TTF_VERSION \
195 SDL_VERSIONNUM( \
196 SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_MICRO_VERSION)
197
201#define SDL_TTF_VERSION_ATLEAST(X, Y, Z) \
202 ((SDL_TTF_MAJOR_VERSION >= X) && \
203 (SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION >= Y) && \
204 (SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION > Y || \
205 SDL_TTF_MICRO_VERSION >= Z))
206
207#endif // SDL3PP_DOC
208
209namespace TTF {
210
220inline int Version() { return TTF_Version(); }
221
237inline void Init() { CheckError(TTF_Init()); }
238
259inline void Quit() { TTF_Quit(); }
260
283inline int WasInit() { return TTF_WasInit(); }
284
285} // namespace TTF
286
302inline void GetFreeTypeVersion(int* major, int* minor, int* patch)
303{
304 TTF_GetFreeTypeVersion(major, minor, patch);
305}
306
320inline void GetHarfBuzzVersion(int* major, int* minor, int* patch)
321{
322 TTF_GetHarfBuzzVersion(major, minor, patch);
323}
324
338
339constexpr FontStyleFlags STYLE_NORMAL = TTF_STYLE_NORMAL;
340
341constexpr FontStyleFlags STYLE_BOLD = TTF_STYLE_BOLD;
342
343constexpr FontStyleFlags STYLE_ITALIC = TTF_STYLE_ITALIC;
344
346 TTF_STYLE_UNDERLINE;
347
349 TTF_STYLE_STRIKETHROUGH;
350
363using HintingFlags = TTF_HintingFlags;
364
365constexpr HintingFlags HINTING_INVALID = TTF_HINTING_INVALID;
366
368 TTF_HINTING_NORMAL;
369
371constexpr HintingFlags HINTING_LIGHT = TTF_HINTING_LIGHT;
372
377constexpr HintingFlags HINTING_MONO = TTF_HINTING_MONO;
378
380constexpr HintingFlags HINTING_NONE = TTF_HINTING_NONE;
381
383constexpr HintingFlags HINTING_LIGHT_SUBPIXEL = TTF_HINTING_LIGHT_SUBPIXEL;
384
390using HorizontalAlignment = TTF_HorizontalAlignment;
391
393 TTF_HORIZONTAL_ALIGN_INVALID;
394
396 TTF_HORIZONTAL_ALIGN_LEFT;
397
399 TTF_HORIZONTAL_ALIGN_CENTER;
400
402 TTF_HORIZONTAL_ALIGN_RIGHT;
403
415using Direction = TTF_Direction;
416
417constexpr Direction DIRECTION_INVALID = TTF_DIRECTION_INVALID;
418
419constexpr Direction DIRECTION_LTR = TTF_DIRECTION_LTR;
420
421constexpr Direction DIRECTION_RTL = TTF_DIRECTION_RTL;
422
423constexpr Direction DIRECTION_TTB = TTF_DIRECTION_TTB;
424
425constexpr Direction DIRECTION_BTT = TTF_DIRECTION_BTT;
426
432using ImageType = TTF_ImageType;
433
434constexpr ImageType IMAGE_INVALID = TTF_IMAGE_INVALID;
435
437 TTF_IMAGE_ALPHA;
438
440 TTF_IMAGE_COLOR;
441
443constexpr ImageType IMAGE_SDF = TTF_IMAGE_SDF;
444
452class Font
453{
454 FontRaw m_resource = nullptr;
455
456public:
458 constexpr Font(std::nullptr_t = nullptr) noexcept
459 : m_resource(0)
460 {
461 }
462
470 constexpr explicit Font(const FontRaw resource) noexcept
471 : m_resource(resource)
472 {
473 }
474
476 constexpr Font(const Font& other) = delete;
477
479 constexpr Font(Font&& other) noexcept
480 : Font(other.release())
481 {
482 }
483
484 constexpr Font(const FontRef& other) = delete;
485
486 constexpr Font(FontRef&& other) = delete;
487
506 Font(StringParam file, float ptsize)
507 : m_resource(CheckError(TTF_OpenFont(file, ptsize)))
508 {
509 }
510
534 Font(IOStreamParam src, float ptsize, bool closeio = false)
535 : m_resource(CheckError(TTF_OpenFontIO(src, closeio, ptsize)))
536 {
537 }
538
583 : m_resource(CheckError(TTF_OpenFontWithProperties(props)))
584 {
585 }
586
588 ~Font() { TTF_CloseFont(m_resource); }
589
591 constexpr Font& operator=(Font&& other) noexcept
592 {
593 std::swap(m_resource, other.m_resource);
594 return *this;
595 }
596
597protected:
599 constexpr Font& operator=(const Font& other) noexcept = default;
600
601public:
603 constexpr FontRaw get() const noexcept { return m_resource; }
604
606 constexpr FontRaw release() noexcept
607 {
608 auto r = m_resource;
609 m_resource = nullptr;
610 return r;
611 }
612
614 constexpr auto operator<=>(const Font& other) const noexcept = default;
615
617 constexpr explicit operator bool() const noexcept { return !!m_resource; }
618
620 constexpr operator FontParam() const noexcept { return {m_resource}; }
621
641 void Close();
642
659 Font Copy() const;
660
681
696 Uint32 GetGeneration() const;
697
719 void AddFallback(FontParam fallback);
720
736 void RemoveFallback(FontParam fallback);
737
751 void ClearFallbacks();
752
769 void SetSize(float ptsize);
770
790 void SetSizeDPI(float ptsize, int hdpi, int vdpi);
791
806 float GetSize() const;
807
822 void GetDPI(int* hdpi, int* vdpi) const;
823
847 void SetStyle(FontStyleFlags style);
848
868 FontStyleFlags GetStyle() const;
869
890 void SetOutline(int outline);
891
903 int GetOutline() const;
904
928 void SetHinting(HintingFlags hinting);
929
939 int GetNumFaces() const;
940
961 HintingFlags GetHinting() const;
962
985 void SetSDF(bool enabled);
986
998 bool GetSDF() const;
999
1000#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
1001
1012 int GetWeight() const;
1013
1014#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 2)
1015
1031
1044
1056 int GetHeight() const;
1057
1069 int GetAscent() const;
1070
1082 int GetDescent() const;
1083
1098 void SetLineSkip(int lineskip);
1099
1111 int GetLineSkip() const;
1112
1132 void SetKerning(bool enabled);
1133
1145 bool GetKerning() const;
1146
1162 bool IsFixedWidth() const;
1163
1177 bool IsScalable() const;
1178
1194 const char* GetFamilyName() const;
1195
1211 const char* GetStyleName() const;
1212
1229 void SetDirection(Direction direction);
1230
1243 Direction GetDirection() const;
1244
1263 void SetScript(Uint32 script);
1264
1279 Uint32 GetScript() const;
1280
1296 static Uint32 GetGlyphScript(Uint32 ch);
1297
1315 void SetLanguage(StringParam language_bcp47);
1316
1328 bool HasGlyph(Uint32 ch) const;
1329
1344 Surface GetGlyphImage(Uint32 ch, ImageType* image_type) const;
1345
1364 ImageType* image_type) const;
1365
1393 void GetGlyphMetrics(Uint32 ch,
1394 int* minx,
1395 int* maxx,
1396 int* miny,
1397 int* maxy,
1398 int* advance) const;
1399
1413 int GetGlyphKerning(Uint32 previous_ch, Uint32 ch) const;
1414
1430 Point GetStringSize(std::string_view text) const
1431 {
1432 Point p;
1433 GetStringSize(text, &p.x, &p.y);
1434 return p;
1435 }
1436
1453 void GetStringSize(std::string_view text, int* w, int* h) const;
1454
1476 Point GetStringSizeWrapped(std::string_view text, int wrap_width) const
1477 {
1478 Point p;
1479 GetStringSizeWrapped(text, wrap_width, &p.x, &p.y);
1480 return p;
1481 }
1482
1505 void GetStringSizeWrapped(std::string_view text,
1506 int wrap_width,
1507 int* w,
1508 int* h) const;
1509
1532 void MeasureString(std::string_view text,
1533 int max_width,
1534 int* measured_width,
1535 size_t* measured_length) const;
1536
1569 Surface RenderText_Solid(std::string_view text, Color fg) const;
1570
1602 Surface RenderText_Solid_Wrapped(std::string_view text,
1603 Color fg,
1604 int wrapLength) const;
1605
1633
1667 Surface RenderText_Shaded(std::string_view text, Color fg, Color bg) const;
1668
1702 Surface RenderText_Shaded_Wrapped(std::string_view text,
1703 Color fg,
1704 Color bg,
1705 int wrap_width) const;
1706
1736
1768 Surface RenderText_Blended(std::string_view text, Color fg) const;
1769
1801 Surface RenderText_Blended_Wrapped(std::string_view text,
1802 Color fg,
1803 int wrap_width) const;
1804
1832
1865 Surface RenderText_LCD(std::string_view text, Color fg, Color bg) const;
1866
1900 Surface RenderText_LCD_Wrapped(std::string_view text,
1901 Color fg,
1902 Color bg,
1903 int wrap_width) const;
1904
1934};
1935
1938{
1939 using Font::Font;
1940
1948 FontRef(FontParam resource) noexcept
1949 : Font(resource.value)
1950 {
1951 }
1952
1960 FontRef(FontRaw resource) noexcept
1961 : Font(resource)
1962 {
1963 }
1964
1966 FontRef(const FontRef& other) noexcept
1967 : Font(other.get())
1968 {
1969 }
1970
1973};
1974
1995inline Font OpenFont(StringParam file, float ptsize)
1996{
1997 return Font(std::move(file), ptsize);
1998}
1999
2025inline Font OpenFont(IOStreamParam src, float ptsize, bool closeio = false)
2026{
2027 return Font(src, ptsize, closeio);
2028}
2029
2073{
2074 return Font(props);
2075}
2076
2077namespace prop::Font {
2078
2079constexpr auto CREATE_FILENAME_STRING = TTF_PROP_FONT_CREATE_FILENAME_STRING;
2080
2081constexpr auto CREATE_IOSTREAM_POINTER = TTF_PROP_FONT_CREATE_IOSTREAM_POINTER;
2082
2083constexpr auto CREATE_IOSTREAM_OFFSET_NUMBER =
2084 TTF_PROP_FONT_CREATE_IOSTREAM_OFFSET_NUMBER;
2085
2086constexpr auto CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN =
2087 TTF_PROP_FONT_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN;
2088
2089constexpr auto CREATE_SIZE_FLOAT = TTF_PROP_FONT_CREATE_SIZE_FLOAT;
2090
2091constexpr auto CREATE_FACE_NUMBER = TTF_PROP_FONT_CREATE_FACE_NUMBER;
2092
2093constexpr auto CREATE_HORIZONTAL_DPI_NUMBER =
2094 TTF_PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER;
2095
2096constexpr auto CREATE_VERTICAL_DPI_NUMBER =
2097 TTF_PROP_FONT_CREATE_VERTICAL_DPI_NUMBER;
2098
2099#if SDL_TTF_VERSION_ATLEAST(3, 2, 3)
2100
2101constexpr auto CREATE_EXISTING_FONT_POINTER =
2102 TTF_PROP_FONT_CREATE_EXISTING_FONT_POINTER;
2103
2104#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 3)
2105
2106constexpr auto OUTLINE_LINE_CAP_NUMBER = TTF_PROP_FONT_OUTLINE_LINE_CAP_NUMBER;
2107
2108constexpr auto OUTLINE_LINE_JOIN_NUMBER =
2109 TTF_PROP_FONT_OUTLINE_LINE_JOIN_NUMBER;
2110
2111constexpr auto OUTLINE_MITER_LIMIT_NUMBER =
2112 TTF_PROP_FONT_OUTLINE_MITER_LIMIT_NUMBER;
2113
2114} // namespace prop::Font
2115
2135inline Font CopyFont(FontParam existing_font)
2136{
2137 return Font(CheckError(TTF_CopyFont(existing_font)));
2138}
2139
2140inline Font Font::Copy() const { return SDL::CopyFont(m_resource); }
2141
2163{
2164 return {CheckError(TTF_GetFontProperties(font))};
2165}
2166
2168{
2169 return SDL::GetFontProperties(m_resource);
2170}
2171
2188{
2189 return TTF_GetFontGeneration(font);
2190}
2191
2193{
2194 return SDL::GetFontGeneration(m_resource);
2195}
2196
2219inline void AddFallbackFont(FontParam font, FontParam fallback)
2220{
2221 CheckError(TTF_AddFallbackFont(font, fallback));
2222}
2223
2224inline void Font::AddFallback(FontParam fallback)
2225{
2226 SDL::AddFallbackFont(m_resource, fallback);
2227}
2228
2245inline void RemoveFallbackFont(FontParam font, FontParam fallback)
2246{
2247 TTF_RemoveFallbackFont(font, fallback);
2248}
2249
2250inline void Font::RemoveFallback(FontParam fallback)
2251{
2252 SDL::RemoveFallbackFont(m_resource, fallback);
2253}
2254
2270inline void ClearFallbackFonts(FontParam font) { TTF_ClearFallbackFonts(font); }
2271
2272inline void Font::ClearFallbacks() { SDL::ClearFallbackFonts(m_resource); }
2273
2291inline void SetFontSize(FontParam font, float ptsize)
2292{
2293 CheckError(TTF_SetFontSize(font, ptsize));
2294}
2295
2296inline void Font::SetSize(float ptsize)
2297{
2298 SDL::SetFontSize(m_resource, ptsize);
2299}
2300
2321inline void SetFontSizeDPI(FontParam font, float ptsize, int hdpi, int vdpi)
2322{
2323 CheckError(TTF_SetFontSizeDPI(font, ptsize, hdpi, vdpi));
2324}
2325
2326inline void Font::SetSizeDPI(float ptsize, int hdpi, int vdpi)
2327{
2328 SDL::SetFontSizeDPI(m_resource, ptsize, hdpi, vdpi);
2329}
2330
2346inline float GetFontSize(FontParam font) { return TTF_GetFontSize(font); }
2347
2348inline float Font::GetSize() const { return SDL::GetFontSize(m_resource); }
2349
2365inline void GetFontDPI(FontParam font, int* hdpi, int* vdpi)
2366{
2367 CheckError(TTF_GetFontDPI(font, hdpi, vdpi));
2368}
2369
2370inline void Font::GetDPI(int* hdpi, int* vdpi) const
2371{
2372 SDL::GetFontDPI(m_resource, hdpi, vdpi);
2373}
2374
2399inline void SetFontStyle(FontParam font, FontStyleFlags style)
2400{
2401 TTF_SetFontStyle(font, style);
2402}
2403
2405{
2406 SDL::SetFontStyle(m_resource, style);
2407}
2408
2430{
2431 return TTF_GetFontStyle(font);
2432}
2433
2435{
2436 return SDL::GetFontStyle(m_resource);
2437}
2438
2460inline void SetFontOutline(FontParam font, int outline)
2461{
2462 CheckError(TTF_SetFontOutline(font, outline));
2463}
2464
2465inline void Font::SetOutline(int outline)
2466{
2467 SDL::SetFontOutline(m_resource, outline);
2468}
2469
2482inline int GetFontOutline(FontParam font) { return TTF_GetFontOutline(font); }
2483
2484inline int Font::GetOutline() const { return SDL::GetFontOutline(m_resource); }
2485
2510inline void SetFontHinting(FontParam font, HintingFlags hinting)
2511{
2512 TTF_SetFontHinting(font, hinting);
2513}
2514
2515inline void Font::SetHinting(HintingFlags hinting)
2516{
2517 SDL::SetFontHinting(m_resource, hinting);
2518}
2519
2530inline int GetNumFontFaces(FontParam font) { return TTF_GetNumFontFaces(font); }
2531
2532inline int Font::GetNumFaces() const
2533{
2534 return SDL::GetNumFontFaces(m_resource);
2535}
2536
2559{
2560 return TTF_GetFontHinting(font);
2561}
2562
2564{
2565 return SDL::GetFontHinting(m_resource);
2566}
2567
2591inline void SetFontSDF(FontParam font, bool enabled)
2592{
2593 CheckError(TTF_SetFontSDF(font, enabled));
2594}
2595
2596inline void Font::SetSDF(bool enabled) { SDL::SetFontSDF(m_resource, enabled); }
2597
2610inline bool GetFontSDF(FontParam font) { return TTF_GetFontSDF(font); }
2611
2612inline bool Font::GetSDF() const { return SDL::GetFontSDF(m_resource); }
2613
2614#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
2615
2627inline int GetFontWeight(FontParam font) { return TTF_GetFontWeight(font); }
2628
2629inline int Font::GetWeight() const { return SDL::GetFontWeight(m_resource); }
2630
2631constexpr int FONT_WEIGHT_THIN =
2632 TTF_FONT_WEIGHT_THIN;
2633
2635 TTF_FONT_WEIGHT_EXTRA_LIGHT;
2636
2637constexpr int FONT_WEIGHT_LIGHT =
2638 TTF_FONT_WEIGHT_LIGHT;
2639
2640constexpr int FONT_WEIGHT_NORMAL =
2641 TTF_FONT_WEIGHT_NORMAL;
2642
2643constexpr int FONT_WEIGHT_MEDIUM =
2644 TTF_FONT_WEIGHT_MEDIUM;
2645
2647 TTF_FONT_WEIGHT_SEMI_BOLD;
2648
2649constexpr int FONT_WEIGHT_BOLD =
2650 TTF_FONT_WEIGHT_BOLD;
2651
2653 TTF_FONT_WEIGHT_EXTRA_BOLD;
2654
2655constexpr int FONT_WEIGHT_BLACK =
2656 TTF_FONT_WEIGHT_BLACK;
2657
2659 TTF_FONT_WEIGHT_EXTRA_BLACK;
2660
2661#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 2)
2662
2679{
2680 TTF_SetFontWrapAlignment(font, align);
2681}
2682
2684{
2685 SDL::SetFontWrapAlignment(m_resource, align);
2686}
2687
2701{
2702 return TTF_GetFontWrapAlignment(font);
2703}
2704
2706{
2707 return SDL::GetFontWrapAlignment(m_resource);
2708}
2709
2722inline int GetFontHeight(FontParam font) { return TTF_GetFontHeight(font); }
2723
2724inline int Font::GetHeight() const { return SDL::GetFontHeight(m_resource); }
2725
2738inline int GetFontAscent(FontParam font) { return TTF_GetFontAscent(font); }
2739
2740inline int Font::GetAscent() const { return SDL::GetFontAscent(m_resource); }
2741
2754inline int GetFontDescent(FontParam font) { return TTF_GetFontDescent(font); }
2755
2756inline int Font::GetDescent() const { return SDL::GetFontDescent(m_resource); }
2757
2773inline void SetFontLineSkip(FontParam font, int lineskip)
2774{
2775 TTF_SetFontLineSkip(font, lineskip);
2776}
2777
2778inline void Font::SetLineSkip(int lineskip)
2779{
2780 SDL::SetFontLineSkip(m_resource, lineskip);
2781}
2782
2795inline int GetFontLineSkip(FontParam font) { return TTF_GetFontLineSkip(font); }
2796
2797inline int Font::GetLineSkip() const
2798{
2799 return SDL::GetFontLineSkip(m_resource);
2800}
2801
2822inline void SetFontKerning(FontParam font, bool enabled)
2823{
2824 TTF_SetFontKerning(font, enabled);
2825}
2826
2827inline void Font::SetKerning(bool enabled)
2828{
2829 SDL::SetFontKerning(m_resource, enabled);
2830}
2831
2844inline bool GetFontKerning(FontParam font) { return TTF_GetFontKerning(font); }
2845
2846inline bool Font::GetKerning() const { return SDL::GetFontKerning(m_resource); }
2847
2865{
2866 return TTF_FontIsFixedWidth(font);
2867}
2868
2869inline bool Font::IsFixedWidth() const
2870{
2871 return SDL::FontIsFixedWidth(m_resource);
2872}
2873
2888inline bool FontIsScalable(FontParam font) { return TTF_FontIsScalable(font); }
2889
2890inline bool Font::IsScalable() const { return SDL::FontIsScalable(m_resource); }
2891
2908inline const char* GetFontFamilyName(FontParam font)
2909{
2910 return TTF_GetFontFamilyName(font);
2911}
2912
2913inline const char* Font::GetFamilyName() const
2914{
2915 return SDL::GetFontFamilyName(m_resource);
2916}
2917
2934inline const char* GetFontStyleName(FontParam font)
2935{
2936 return TTF_GetFontStyleName(font);
2937}
2938
2939inline const char* Font::GetStyleName() const
2940{
2941 return SDL::GetFontStyleName(m_resource);
2942}
2943
2961inline void SetFontDirection(FontParam font, Direction direction)
2962{
2963 CheckError(TTF_SetFontDirection(font, direction));
2964}
2965
2966inline void Font::SetDirection(Direction direction)
2967{
2968 SDL::SetFontDirection(m_resource, direction);
2969}
2970
2985{
2986 return TTF_GetFontDirection(font);
2987}
2988
2990{
2991 return SDL::GetFontDirection(m_resource);
2992}
2993
3007{
3008 return TTF_StringToTag(string);
3009}
3010
3026inline void TagToString(Uint32 tag, char* string, size_t size)
3027{
3028 TTF_TagToString(tag, string, size);
3029}
3030
3050inline void SetFontScript(FontParam font, Uint32 script)
3051{
3052 CheckError(TTF_SetFontScript(font, script));
3053}
3054
3055inline void Font::SetScript(Uint32 script)
3056{
3057 SDL::SetFontScript(m_resource, script);
3058}
3059
3075inline Uint32 GetFontScript(FontParam font) { return TTF_GetFontScript(font); }
3076
3077inline Uint32 Font::GetScript() const { return SDL::GetFontScript(m_resource); }
3078
3094{
3095 return CheckError(TTF_GetGlyphScript(ch));
3096}
3097
3099{
3100 return SDL::GetGlyphScript(ch);
3101}
3102
3120inline void SetFontLanguage(FontParam font, StringParam language_bcp47)
3121{
3122 CheckError(TTF_SetFontLanguage(font, language_bcp47));
3123}
3124
3125inline void Font::SetLanguage(StringParam language_bcp47)
3126{
3127 SDL::SetFontLanguage(m_resource, std::move(language_bcp47));
3128}
3129
3142inline bool FontHasGlyph(FontParam font, Uint32 ch)
3143{
3144 return TTF_FontHasGlyph(font, ch);
3145}
3146
3147inline bool Font::HasGlyph(Uint32 ch) const
3148{
3149 return SDL::FontHasGlyph(m_resource, ch);
3150}
3151
3167inline Surface GetGlyphImage(FontParam font, Uint32 ch, ImageType* image_type)
3168{
3169 return Surface{TTF_GetGlyphImage(font, ch, image_type)};
3170}
3171
3172inline Surface Font::GetGlyphImage(Uint32 ch, ImageType* image_type) const
3173{
3174 return SDL::GetGlyphImage(m_resource, ch, image_type);
3175}
3176
3196 Uint32 glyph_index,
3197 ImageType* image_type)
3198{
3199 return Surface(TTF_GetGlyphImageForIndex(font, glyph_index, image_type));
3200}
3201
3203 ImageType* image_type) const
3204{
3205 return SDL::GetGlyphImageForIndex(m_resource, glyph_index, image_type);
3206}
3207
3237 Uint32 ch,
3238 int* minx,
3239 int* maxx,
3240 int* miny,
3241 int* maxy,
3242 int* advance)
3243{
3244 CheckError(TTF_GetGlyphMetrics(font, ch, minx, maxx, miny, maxy, advance));
3245}
3246
3248 int* minx,
3249 int* maxx,
3250 int* miny,
3251 int* maxy,
3252 int* advance) const
3253{
3254 SDL::GetGlyphMetrics(m_resource, ch, minx, maxx, miny, maxy, advance);
3255}
3256
3271inline int GetGlyphKerning(FontParam font, Uint32 previous_ch, Uint32 ch)
3272{
3273 if (int r; TTF_GetGlyphKerning(font, previous_ch, ch, &r)) return r;
3274 throw Error();
3275}
3276
3277inline int Font::GetGlyphKerning(Uint32 previous_ch, Uint32 ch) const
3278{
3279 return SDL::GetGlyphKerning(m_resource, previous_ch, ch);
3280}
3281
3299inline void GetStringSize(FontParam font, std::string_view text, int* w, int* h)
3300{
3301 CheckError(TTF_GetStringSize(font, text.data(), text.size(), w, h));
3302}
3303
3304inline void Font::GetStringSize(std::string_view text, int* w, int* h) const
3305{
3306 SDL::GetStringSize(m_resource, text, w, h);
3307}
3308
3333 std::string_view text,
3334 int wrap_width,
3335 int* w,
3336 int* h)
3337{
3338 CheckError(
3339 TTF_GetStringSizeWrapped(font, text.data(), text.size(), wrap_width, w, h));
3340}
3341
3342inline void Font::GetStringSizeWrapped(std::string_view text,
3343 int wrap_width,
3344 int* w,
3345 int* h) const
3346{
3347 SDL::GetStringSizeWrapped(m_resource, text, wrap_width, w, h);
3348}
3349
3373inline void MeasureString(FontParam font,
3374 std::string_view text,
3375 int max_width,
3376 int* measured_width,
3377 size_t* measured_length)
3378{
3379 CheckError(TTF_MeasureString(font,
3380 text.data(),
3381 text.size(),
3382 max_width,
3383 measured_width,
3384 measured_length));
3385}
3386
3387inline void Font::MeasureString(std::string_view text,
3388 int max_width,
3389 int* measured_width,
3390 size_t* measured_length) const
3391{
3393 m_resource, text, max_width, measured_width, measured_length);
3394}
3395
3429inline Surface RenderText_Solid(FontParam font, std::string_view text, Color fg)
3430{
3431 return Surface{TTF_RenderText_Solid(font, text.data(), text.size(), fg)};
3432}
3433
3434inline Surface Font::RenderText_Solid(std::string_view text, Color fg) const
3435{
3436 return SDL::RenderText_Solid(m_resource, text, fg);
3437}
3438
3472 std::string_view text,
3473 Color fg,
3474 int wrapLength)
3475{
3476 return Surface(TTF_RenderText_Solid_Wrapped(
3477 font, text.data(), text.size(), fg, wrapLength));
3478}
3479
3480inline Surface Font::RenderText_Solid_Wrapped(std::string_view text,
3481 Color fg,
3482 int wrapLength) const
3483{
3484 return SDL::RenderText_Solid_Wrapped(m_resource, text, fg, wrapLength);
3485}
3486
3515{
3516 return Surface(TTF_RenderGlyph_Solid(font, ch, fg));
3517}
3518
3520{
3521 return SDL::RenderGlyph_Solid(m_resource, ch, fg);
3522}
3523
3559 std::string_view text,
3560 Color fg,
3561 Color bg)
3562{
3563 return Surface(TTF_RenderText_Shaded(font, text.data(), text.size(), fg, bg));
3564}
3565
3566inline Surface Font::RenderText_Shaded(std::string_view text,
3567 Color fg,
3568 Color bg) const
3569{
3570 return SDL::RenderText_Shaded(m_resource, text, fg, bg);
3571}
3572
3608 std::string_view text,
3609 Color fg,
3610 Color bg,
3611 int wrap_width)
3612{
3613 return Surface(TTF_RenderText_Shaded_Wrapped(
3614 font, text.data(), text.size(), fg, bg, wrap_width));
3615}
3616
3617inline Surface Font::RenderText_Shaded_Wrapped(std::string_view text,
3618 Color fg,
3619 Color bg,
3620 int wrap_width) const
3621{
3622 return SDL::RenderText_Shaded_Wrapped(m_resource, text, fg, bg, wrap_width);
3623}
3624
3655 Uint32 ch,
3656 ColorRaw fg,
3657 ColorRaw bg)
3658{
3659 return Surface(TTF_RenderGlyph_Shaded(font, ch, fg, bg));
3660}
3661
3663 ColorRaw fg,
3664 ColorRaw bg) const
3665{
3666 return SDL::RenderGlyph_Shaded(m_resource, ch, fg, bg);
3667}
3668
3702 std::string_view text,
3703 Color fg)
3704{
3705 return Surface(TTF_RenderText_Blended(font, text.data(), text.size(), fg));
3706}
3707
3708inline Surface Font::RenderText_Blended(std::string_view text, Color fg) const
3709{
3710 return SDL::RenderText_Blended(m_resource, text, fg);
3711}
3712
3746 std::string_view text,
3747 Color fg,
3748 int wrap_width)
3749{
3750 return Surface(TTF_RenderText_Blended_Wrapped(
3751 font, text.data(), text.size(), fg, wrap_width));
3752}
3753
3754inline Surface Font::RenderText_Blended_Wrapped(std::string_view text,
3755 Color fg,
3756 int wrap_width) const
3757{
3758 return SDL::RenderText_Blended_Wrapped(m_resource, text, fg, wrap_width);
3759}
3760
3789{
3790 return Surface(TTF_RenderGlyph_Blended(font, ch, fg));
3791}
3792
3794{
3795 return SDL::RenderGlyph_Blended(m_resource, ch, fg);
3796}
3797
3832 std::string_view text,
3833 Color fg,
3834 Color bg)
3835{
3836 return Surface(TTF_RenderText_LCD(font, text.data(), text.size(), fg, bg));
3837}
3838
3839inline Surface Font::RenderText_LCD(std::string_view text,
3840 Color fg,
3841 Color bg) const
3842{
3843 return SDL::RenderText_LCD(m_resource, text, fg, bg);
3844}
3845
3880 std::string_view text,
3881 Color fg,
3882 Color bg,
3883 int wrap_width)
3884{
3885 return Surface(TTF_RenderText_LCD_Wrapped(
3886 font, text.data(), text.size(), fg, bg, wrap_width));
3887}
3888
3889inline Surface Font::RenderText_LCD_Wrapped(std::string_view text,
3890 Color fg,
3891 Color bg,
3892 int wrap_width) const
3893{
3894 return SDL::RenderText_LCD_Wrapped(m_resource, text, fg, bg, wrap_width);
3895}
3896
3927 Uint32 ch,
3928 ColorRaw fg,
3929 ColorRaw bg)
3930{
3931 return Surface(TTF_RenderGlyph_LCD(font, ch, fg, bg));
3932}
3933
3935{
3936 return SDL::RenderGlyph_LCD(m_resource, ch, fg, bg);
3937}
3938
3947
3949 TTF_SUBSTRING_DIRECTION_MASK;
3951
3953 TTF_SUBSTRING_TEXT_START;
3955
3957constexpr SubStringFlags SUBSTRING_LINE_START = TTF_SUBSTRING_LINE_START;
3958
3960constexpr SubStringFlags SUBSTRING_LINE_END = TTF_SUBSTRING_LINE_END;
3961
3963 TTF_SUBSTRING_TEXT_END;
3964
3970using GPUTextEngineWinding = TTF_GPUTextEngineWinding;
3971
3973 TTF_GPU_TEXTENGINE_WINDING_INVALID;
3974
3976 TTF_GPU_TEXTENGINE_WINDING_CLOCKWISE;
3977
3979 TTF_GPU_TEXTENGINE_WINDING_COUNTER_CLOCKWISE;
3980
4000{
4001 TextEngineRaw m_resource = nullptr;
4002
4003public:
4005 constexpr TextEngine(std::nullptr_t = nullptr) noexcept
4006 : m_resource(0)
4007 {
4008 }
4009
4017 constexpr explicit TextEngine(const TextEngineRaw resource) noexcept
4018 : m_resource(resource)
4019 {
4020 }
4021
4023 constexpr TextEngine(const TextEngine& other) = delete;
4024
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
4367 constexpr Text(const Text& other) = delete;
4368
4370 constexpr Text(Text&& other) noexcept
4371 : Text(other.release())
4372 {
4373 }
4374
4375 constexpr Text(const TextRef& other) = delete;
4376
4377 constexpr Text(TextRef&& other) = delete;
4378
4396 Text(TextEngineParam engine, FontParam font, std::string_view text)
4397 : m_resource(TTF_CreateText(engine, font, text.data(), text.size()))
4398 {
4399 }
4400
4402 constexpr const TextRaw operator->() const noexcept { return m_resource; }
4403
4405 constexpr TextRaw operator->() noexcept { return m_resource; }
4406
4408 ~Text() { TTF_DestroyText(m_resource); }
4409
4411 constexpr Text& operator=(Text&& other) noexcept
4412 {
4413 std::swap(m_resource, other.m_resource);
4414 return *this;
4415 }
4416
4417protected:
4419 constexpr Text& operator=(const Text& other) noexcept = default;
4420
4421public:
4423 constexpr TextRaw get() const noexcept { return m_resource; }
4424
4426 constexpr TextRaw release() noexcept
4427 {
4428 auto r = m_resource;
4429 m_resource = nullptr;
4430 return r;
4431 }
4432
4434 constexpr auto operator<=>(const Text& other) const noexcept = default;
4435
4437 constexpr explicit operator bool() const noexcept { return !!m_resource; }
4438
4440 constexpr operator TextParam() const noexcept { return {m_resource}; }
4441
4452 void Destroy();
4453
4473 void DrawSurface(Point p, SurfaceParam surface) const;
4474
4494 void DrawRenderer(FPoint p) const;
4495
4522 GPUAtlasDrawSequence* GetGPUDrawData() const;
4523
4535 PropertiesRef GetProperties() const;
4536
4552 void SetEngine(TextEngineParam engine);
4553
4567 TextEngineParam GetEngine() const;
4568
4589 bool SetFont(FontParam font);
4590
4604 FontRef GetFont() const;
4605
4620 void SetDirection(Direction direction);
4621
4634 Direction GetDirection() const;
4635
4652 void SetScript(Uint32 script);
4653
4670 Uint32 GetScript() const;
4671
4688 void SetColor(Color c);
4689
4706 void SetColorFloat(FColor c);
4707
4729 void GetColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a) const;
4730
4745 Color GetColor() const;
4746
4768 void GetColorFloat(float* r, float* g, float* b, float* a) const;
4769
4784 FColor GetColorFloat() const;
4785
4804 void SetPosition(Point p);
4805
4822 void GetPosition(int* x, int* y) const;
4823
4839 Point GetPosition() const;
4840
4857 void SetWrapWidth(int wrap_width);
4858
4873 int GetWrapWidth() const;
4874
4896 void SetWrapWhitespaceVisible(bool visible);
4897
4911 bool IsWrapWhitespaceVisible() const;
4912
4930 void SetString(std::string_view string);
4931
4953 void InsertString(int offset, std::string_view string);
4954
4972 void AppendString(std::string_view string);
4973
4996 void DeleteString(int offset, int length);
4997
5015 void GetSize(int* w, int* h) const;
5016
5033 Point GetSize() const;
5034
5054 void GetSubString(int offset, SubString* substring) const;
5055
5060
5065
5082
5101 void GetSubStringForLine(int line, SubString* substring) const;
5102
5115 {
5116 return GetSubStringsForRange(0);
5117 }
5118
5135 OwnArray<SubString*> GetSubStringsForRange(int offset, int length = -1) const;
5136
5153
5170 void GetSubStringForPoint(Point p, SubString* substring) const;
5171
5188 void GetPreviousSubString(const SubString& substring,
5189 SubString* previous) const;
5190
5206 void GetNextSubString(const SubString& substring, SubString* next) const;
5207
5222 void Update();
5223
5228 const char* GetText() const { return m_resource->text; }
5229
5231 int GetNumLines() const { return m_resource->num_lines; }
5232};
5233
5236{
5237 using Text::Text;
5238
5246 TextRef(TextParam resource = nullptr) noexcept
5247 : Text(resource.value)
5248 {
5249 }
5250
5258 TextRef(TextRaw resource) noexcept
5259 : Text(resource)
5260 {
5261 }
5262
5264 TextRef(const TextRef& other) noexcept
5265 : Text(other.get())
5266 {
5267 }
5268
5270 ~TextRef() { release(); }
5271};
5272
5278{
5279 TextRef m_text;
5280
5281 SubString m_subString;
5282
5283 constexpr SubStringIterator(TextRef text)
5284 : m_text(text)
5285 , m_subString(0)
5286 {
5287 }
5288
5289public:
5293 {
5294 }
5295
5297 constexpr operator bool() const { return bool(m_text); }
5298
5300 constexpr const SubString& operator*() const { return m_subString; }
5301
5303 constexpr const SubString* operator->() const { return &m_subString; }
5304
5306 constexpr bool operator==(const SubStringIterator& other) const
5307 {
5308 return m_subString.offset == other.m_subString.offset;
5309 }
5310
5313 {
5314 m_text.GetNextSubString(m_subString, &m_subString);
5315 return *this;
5316 }
5317
5320 {
5321 auto curr = *this;
5322 m_text.GetNextSubString(m_subString, &m_subString);
5323 return curr;
5324 }
5325
5328 {
5329 m_text.GetPreviousSubString(m_subString, &m_subString);
5330 return *this;
5331 }
5332
5335 {
5336 auto curr = *this;
5337 m_text.GetPreviousSubString(m_subString, &m_subString);
5338 return curr;
5339 }
5340
5341 friend class Text;
5342};
5343
5358{
5359 return SurfaceTextEngine();
5360}
5361
5383{
5384 CheckError(TTF_DrawSurfaceText(text, p.x, p.y, surface));
5385}
5386
5387inline void Text::DrawSurface(Point p, SurfaceParam surface) const
5388{
5389 SDL::DrawSurfaceText(m_resource, p, surface);
5390}
5391
5409{
5410 TTF_DestroySurfaceTextEngine(engine);
5411}
5412
5414{
5416}
5417
5435{
5436 return RendererTextEngine(renderer);
5437}
5438
5464 PropertiesParam props)
5465{
5466 return RendererTextEngine(props);
5467}
5468
5469namespace prop::RendererTextEngine {
5470
5471#if SDL_TTF_VERSION_ATLEAST(3, 2, 3)
5472
5473constexpr auto RENDERER_POINTER =
5474 TTF_PROP_RENDERER_TEXT_ENGINE_RENDERER_POINTER;
5475
5476constexpr auto ATLAS_TEXTURE_SIZE_NUMBER =
5477 TTF_PROP_RENDERER_TEXT_ENGINE_ATLAS_TEXTURE_SIZE_NUMBER;
5478
5479#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 3)
5480
5481} // namespace prop::RendererTextEngine
5482
5504{
5505 CheckError(TTF_DrawRendererText(text, p.x, p.y));
5506}
5507
5508inline void Text::DrawRenderer(FPoint p) const
5509{
5510 SDL::DrawRendererText(m_resource, p);
5511}
5512
5530{
5531 TTF_DestroyRendererTextEngine(engine);
5532}
5533
5535{
5537}
5538
5556{
5557 return GPUTextEngine(device);
5558}
5559
5585{
5586 return GPUTextEngine(props);
5587}
5588
5589namespace prop::GpuTextEngine {
5590
5591#if SDL_TTF_VERSION_ATLEAST(3, 2, 3)
5592
5593constexpr auto DEVICE_POINTER = TTF_PROP_GPU_TEXT_ENGINE_DEVICE_POINTER;
5594
5595constexpr auto ATLAS_TEXTURE_SIZE_NUMBER =
5596 TTF_PROP_GPU_TEXT_ENGINE_ATLAS_TEXTURE_SIZE_NUMBER;
5597
5598#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 3)
5599
5600} // namespace prop::GpuTextEngine
5601
5629{
5630 return TTF_GetGPUTextDrawData(text);
5631}
5632
5634{
5635 return SDL::GetGPUTextDrawData(m_resource);
5636}
5637
5654{
5655 TTF_DestroyGPUTextEngine(engine);
5656}
5657
5659
5676 GPUTextEngineWinding winding)
5677{
5678 TTF_SetGPUTextEngineWinding(engine, winding);
5679}
5680
5682{
5684}
5685
5703{
5704 return TTF_GetGPUTextEngineWinding(engine);
5705}
5706
5708{
5710}
5711
5730 FontParam font,
5731 std::string_view text)
5732{
5733 return Text(engine, font, text);
5734}
5735
5736inline Text TextEngine::CreateText(FontParam font, std::string_view text)
5737{
5738 return Text(m_resource, font, text);
5739}
5740
5754{
5755 return {CheckError(TTF_GetTextProperties(text))};
5756}
5757
5759{
5760 return SDL::GetTextProperties(m_resource);
5761}
5762
5779inline void SetTextEngine(TextParam text, TextEngineParam engine)
5780{
5781 CheckError(TTF_SetTextEngine(text, engine));
5782}
5783
5785{
5786 SDL::SetTextEngine(m_resource, engine);
5787}
5788
5804{
5805 return CheckError(TTF_GetTextEngine(text));
5806}
5807
5809{
5810 return SDL::GetTextEngine(m_resource);
5811}
5812
5834inline bool SetTextFont(TextParam text, FontParam font)
5835{
5836 return TTF_SetTextFont(text, font);
5837}
5838
5839inline bool Text::SetFont(FontParam font)
5840{
5841 return SDL::SetTextFont(m_resource, font);
5842}
5843
5859{
5860 return {CheckError(TTF_GetTextFont(text))};
5861}
5862
5863inline FontRef Text::GetFont() const { return SDL::GetTextFont(m_resource); }
5864
5880inline void SetTextDirection(TextParam text, Direction direction)
5881{
5882 CheckError(TTF_SetTextDirection(text, direction));
5883}
5884
5885inline void Text::SetDirection(Direction direction)
5886{
5887 SDL::SetTextDirection(m_resource, direction);
5888}
5889
5904{
5905 return TTF_GetTextDirection(text);
5906}
5907
5909{
5910 return SDL::GetTextDirection(m_resource);
5911}
5912
5930inline void SetTextScript(TextParam text, Uint32 script)
5931{
5932 CheckError(TTF_SetTextScript(text, script));
5933}
5934
5935inline void Text::SetScript(Uint32 script)
5936{
5937 SDL::SetTextScript(m_resource, script);
5938}
5939
5958{
5959 return TTF_GetTextScript(text);
5960}
5961
5962inline Uint32 Text::GetScript() const { return SDL::GetTextScript(m_resource); }
5963
5981inline void SetTextColor(TextParam text, Color c)
5982{
5983 CheckError(TTF_SetTextColor(text, c.r, c.g, c.b, c.a));
5984}
5985
5986inline void Text::SetColor(Color c) { SDL::SetTextColor(m_resource, c); }
5987
6006{
6007 CheckError(TTF_SetTextColorFloat(text, c.r, c.g, c.b, c.a));
6008}
6009
6011{
6012 SDL::SetTextColorFloat(m_resource, c);
6013}
6014
6038 Uint8* r,
6039 Uint8* g,
6040 Uint8* b,
6041 Uint8* a)
6042{
6043 CheckError(TTF_GetTextColor(text, r, g, b, a));
6044}
6045
6062{
6063 Color c;
6064 GetTextColor(text, &c.r, &c.g, &c.b, &c.a);
6065 return c;
6066}
6067
6068inline void Text::GetColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a) const
6069{
6070 SDL::GetTextColor(m_resource, r, g, b, a);
6071}
6072
6073inline Color Text::GetColor() const { return SDL::GetTextColor(m_resource); }
6074
6098 float* r,
6099 float* g,
6100 float* b,
6101 float* a)
6102{
6103 CheckError(TTF_GetTextColorFloat(text, r, g, b, a));
6104}
6105
6122{
6123 FColor c;
6124 GetTextColorFloat(text, &c.r, &c.g, &c.b, &c.a);
6125 return c;
6126}
6127
6128inline void Text::GetColorFloat(float* r, float* g, float* b, float* a) const
6129{
6130 SDL::GetTextColorFloat(m_resource, r, g, b, a);
6131}
6132
6134{
6135 return SDL::GetTextColorFloat(m_resource);
6136}
6137
6157inline void SetTextPosition(TextParam text, Point p)
6158{
6159 CheckError(TTF_SetTextPosition(text, p.x, p.y));
6160}
6161
6162inline void Text::SetPosition(Point p) { SDL::SetTextPosition(m_resource, p); }
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:453
constexpr Font(Font &&other) noexcept
Move constructor.
Definition: SDL3pp_ttf.h:479
~Font()
Destructor.
Definition: SDL3pp_ttf.h:588
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:534
Font(PropertiesParam props)
Create a font with the specified properties.
Definition: SDL3pp_ttf.h:582
Point GetStringSize(std::string_view text) const
Calculate the dimensions of a rendered string of UTF-8 text.
Definition: SDL3pp_ttf.h:1430
Font(StringParam file, float ptsize)
Create a font from a file, using a specified point size.
Definition: SDL3pp_ttf.h:506
constexpr Font(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_ttf.h:458
constexpr auto operator<=>(const Font &other) const noexcept=default
Comparison.
constexpr Font(const FontRaw resource) noexcept
Constructs from FontParam.
Definition: SDL3pp_ttf.h:470
constexpr FontRaw get() const noexcept
Retrieves underlying FontRaw.
Definition: SDL3pp_ttf.h:603
constexpr Font & operator=(Font &&other) noexcept
Assignment operator.
Definition: SDL3pp_ttf.h:591
constexpr Font(const Font &other)=delete
Copy constructor.
constexpr FontRaw release() noexcept
Retrieves underlying FontRaw and clear this.
Definition: SDL3pp_ttf.h:606
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:1476
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:5278
constexpr SubStringIterator()
Default constructor.
Definition: SDL3pp_ttf.h:5291
constexpr SubStringIterator & operator--()
Decrement operator.
Definition: SDL3pp_ttf.h:5327
constexpr const SubString & operator*() const
Retrieve SubString.
Definition: SDL3pp_ttf.h:5300
constexpr const SubString * operator->() const
Retrieve SubString.
Definition: SDL3pp_ttf.h:5303
constexpr bool operator==(const SubStringIterator &other) const
Comparison.
Definition: SDL3pp_ttf.h:5306
constexpr SubStringIterator operator--(int)
Decrement operator.
Definition: SDL3pp_ttf.h:5334
constexpr SubStringIterator operator++(int)
Increment operator.
Definition: SDL3pp_ttf.h:5319
constexpr SubStringIterator & operator++()
Increment operator.
Definition: SDL3pp_ttf.h:5312
A collection of pixels used in software blitting.
Definition: SDL3pp_surface.h:201
A text engine used to create text objects.
Definition: SDL3pp_ttf.h:4000
constexpr TextEngineRaw release() noexcept
Retrieves underlying TextEngineRaw and clear this.
Definition: SDL3pp_ttf.h:4050
constexpr TextEngine(const TextEngine &other)=delete
Copy constructor.
virtual void Destroy()=0
frees up textEngine. Pure virtual
constexpr TextEngineRaw get() const noexcept
Retrieves underlying TextEngineRaw.
Definition: SDL3pp_ttf.h:4047
constexpr auto operator<=>(const TextEngine &other) const noexcept=default
Comparison.
constexpr TextEngine(const TextEngineRaw resource) noexcept
Constructs from TextEngineParam.
Definition: SDL3pp_ttf.h:4017
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:4005
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:5228
int GetNumLines() const
The number of lines in the text, 0 if it's empty.
Definition: SDL3pp_ttf.h:5231
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:4426
constexpr TextRaw get() const noexcept
Retrieves underlying TextRaw.
Definition: SDL3pp_ttf.h:4423
constexpr TextRaw operator->() noexcept
member access to underlying TextRaw.
Definition: SDL3pp_ttf.h:4405
SubStringIterator begin() const
Get iterator to first substring.
constexpr const TextRaw operator->() const noexcept
member access to underlying TextRaw.
Definition: SDL3pp_ttf.h:4402
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:4408
OwnArray< SubString * > GetSubStrings() const
Get all substrings of a text object.
Definition: SDL3pp_ttf.h:5114
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:4396
constexpr Text & operator=(Text &&other) noexcept
Assignment operator.
Definition: SDL3pp_ttf.h:4411
constexpr Text(const Text &other)=delete
Copy constructor.
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:4370
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:3055
SDL_Color ColorRaw
Alias to raw representation for Color.
Definition: SDL3pp_pixels.h:83
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:5863
void SetFontLanguage(FontParam font, StringParam language_bcp47)
Set language to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:3120
const char * GetFontFamilyName(FontParam font)
Query a font's family name.
Definition: SDL3pp_ttf.h:2908
constexpr FontStyleFlags STYLE_NORMAL
No special style.
Definition: SDL3pp_ttf.h:339
Uint32 GetGlyphScript(Uint32 ch)
Get the script used by a 32-bit codepoint.
Definition: SDL3pp_ttf.h:3093
void SetFontLineSkip(FontParam font, int lineskip)
Set the spacing between lines of text for a font.
Definition: SDL3pp_ttf.h:2773
constexpr SubStringFlags SUBSTRING_LINE_END
This substring contains the end of line line_index
Definition: SDL3pp_ttf.h:3960
constexpr HintingFlags HINTING_LIGHT
Light hinting applies subtle adjustments to improve rendering.
Definition: SDL3pp_ttf.h:371
void DrawSurface(Point p, SurfaceParam surface) const
Draw text to an SDL surface.
Definition: SDL3pp_ttf.h:5387
constexpr HorizontalAlignment HORIZONTAL_ALIGN_CENTER
CENTER.
Definition: SDL3pp_ttf.h:398
PropertiesRef GetTextProperties(TextConstParam text)
Get the properties associated with a text object.
Definition: SDL3pp_ttf.h:5753
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:5413
void SetFontSDF(FontParam font, bool enabled)
Enable Signed Distance Field rendering for a font.
Definition: SDL3pp_ttf.h:2591
constexpr HorizontalAlignment HORIZONTAL_ALIGN_RIGHT
RIGHT.
Definition: SDL3pp_ttf.h:401
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:3514
int GetFontHeight(FontParam font)
Query the total height of a font.
Definition: SDL3pp_ttf.h:2722
void Destroy() final
Destroy a text engine created for drawing text on an SDL renderer.
Definition: SDL3pp_ttf.h:5534
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:3978
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:3373
bool IsFixedWidth() const
Query whether a font is fixed-width.
Definition: SDL3pp_ttf.h:2869
TTF_Font * FontRaw
Alias to raw representation for Font.
Definition: SDL3pp_ttf.h:36
RendererTextEngine CreateRendererTextEngine(RendererParam renderer)
Create a text engine for drawing text on an SDL renderer.
Definition: SDL3pp_ttf.h:5434
constexpr SubStringFlags SUBSTRING_TEXT_START
This substring contains the beginning of the text.
Definition: SDL3pp_ttf.h:3952
const char * GetStyleName() const
Query a font's style name.
Definition: SDL3pp_ttf.h:2939
static Uint32 GetGlyphScript(Uint32 ch)
Get the script used by a 32-bit codepoint.
Definition: SDL3pp_ttf.h:3098
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:3558
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:3839
HintingFlags GetFontHinting(FontParam font)
Query a font's current FreeType hinter setting.
Definition: SDL3pp_ttf.h:2558
void SetFontScript(FontParam font, Uint32 script)
Set the script to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:3050
int GetFontWeight(FontParam font)
Query a font's weight, in terms of the lightness/heaviness of the strokes.
Definition: SDL3pp_ttf.h:2627
void SetSizeDPI(float ptsize, int hdpi, int vdpi)
Set font size dynamically with target resolutions, in dots per inch.
Definition: SDL3pp_ttf.h:2326
constexpr int FONT_WEIGHT_BLACK
Black (900) named font weight value.
Definition: SDL3pp_ttf.h:2655
void SetPosition(Point p)
Set the position of a text object.
Definition: SDL3pp_ttf.h:6162
void SetLanguage(StringParam language_bcp47)
Set language to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:3125
void RemoveFallback(FontParam fallback)
Remove a fallback font.
Definition: SDL3pp_ttf.h:2250
void SetTextScript(TextParam text, Uint32 script)
Set the script to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5930
void GetTextColorFloat(TextConstParam text, float *r, float *g, float *b, float *a)
Get the color of a text object.
Definition: SDL3pp_ttf.h:6097
int GetFontOutline(FontParam font)
Query a font's current outline.
Definition: SDL3pp_ttf.h:2482
void DestroyRendererTextEngine(TextEngineRaw engine)
Destroy a text engine created for drawing text on an SDL renderer.
Definition: SDL3pp_ttf.h:5529
void DrawRenderer(FPoint p) const
Draw text to an SDL renderer.
Definition: SDL3pp_ttf.h:5508
constexpr SubStringFlags SUBSTRING_LINE_START
This substring contains the beginning of line line_index
Definition: SDL3pp_ttf.h:3957
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:3299
constexpr Direction DIRECTION_LTR
Left to Right.
Definition: SDL3pp_ttf.h:419
constexpr ImageType IMAGE_COLOR
The color channels have image data.
Definition: SDL3pp_ttf.h:439
bool SetFont(FontParam font)
Set the font used by a text object.
Definition: SDL3pp_ttf.h:5839
Direction GetFontDirection(FontParam font)
Get the direction to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:2984
Text CreateText(FontParam font, std::string_view text)
Create a text object from UTF-8 text and a text engine.
Definition: SDL3pp_ttf.h:5736
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:3006
HintingFlags GetHinting() const
Query a font's current FreeType hinter setting.
Definition: SDL3pp_ttf.h:2563
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:3172
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:2321
Uint32 SubStringFlags
Flags for SubString.
Definition: SDL3pp_ttf.h:3946
const char * GetFamilyName() const
Query a font's family name.
Definition: SDL3pp_ttf.h:2913
void ClearFallbacks()
Remove all fallback fonts.
Definition: SDL3pp_ttf.h:2272
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:5957
Direction GetDirection() const
Get the direction to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5908
TTF_HintingFlags HintingFlags
Hinting flags for TTF (TrueType Fonts)
Definition: SDL3pp_ttf.h:363
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:3142
void SetStyle(FontStyleFlags style)
Set a font's current style.
Definition: SDL3pp_ttf.h:2404
RendererTextEngine CreateRendererTextEngineWithProperties(PropertiesParam props)
Create a text engine for drawing text on an SDL renderer, with the specified properties.
Definition: SDL3pp_ttf.h:5463
Surface GetGlyphImageForIndex(Uint32 glyph_index, ImageType *image_type) const
Get the pixel image for a character index.
Definition: SDL3pp_ttf.h:3202
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:5885
constexpr ImageType IMAGE_INVALID
INVALID.
Definition: SDL3pp_ttf.h:434
FontStyleFlags GetStyle() const
Query a font's current style.
Definition: SDL3pp_ttf.h:2434
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:3480
void GetHarfBuzzVersion(int *major, int *minor, int *patch)
Query the version of the HarfBuzz library in use.
Definition: SDL3pp_ttf.h:320
void SetOutline(int outline)
Set a font's current outline.
Definition: SDL3pp_ttf.h:2465
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:3754
constexpr HintingFlags HINTING_INVALID
INVALID.
Definition: SDL3pp_ttf.h:365
int GetHeight() const
Query the total height of a font.
Definition: SDL3pp_ttf.h:2724
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:2846
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:3434
GPUTextEngine CreateGPUTextEngineWithProperties(PropertiesParam props)
Create a text engine for drawing text with the SDL GPU API, with the specified properties.
Definition: SDL3pp_ttf.h:5584
void DestroySurfaceTextEngine(TextEngineRaw engine)
Destroy a text engine created for drawing text on SDL surfaces.
Definition: SDL3pp_ttf.h:5408
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:2484
constexpr int FONT_WEIGHT_EXTRA_LIGHT
ExtraLight (200) named font weight value.
Definition: SDL3pp_ttf.h:2634
bool GetFontKerning(FontParam font)
Query whether or not kerning is enabled for a font.
Definition: SDL3pp_ttf.h:2844
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:337
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:5681
void SetFontKerning(FontParam font, bool enabled)
Set if kerning is enabled for a font.
Definition: SDL3pp_ttf.h:2822
Font CopyFont(FontParam existing_font)
Create a copy of an existing font.
Definition: SDL3pp_ttf.h:2135
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:3236
void SetColor(Color c)
Set the color of a text object.
Definition: SDL3pp_ttf.h:5986
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:2348
int GetGlyphKerning(Uint32 previous_ch, Uint32 ch) const
Query the kerning size between the glyphs of two UNICODE codepoints.
Definition: SDL3pp_ttf.h:3277
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:3708
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:3429
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:2795
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:3793
constexpr Direction DIRECTION_BTT
Bottom to Top.
Definition: SDL3pp_ttf.h:425
constexpr HintingFlags HINTING_MONO
Monochrome hinting adjusts the font for better rendering at lower resolutions.
Definition: SDL3pp_ttf.h:377
GPUTextEngine CreateGPUTextEngine(GPUDeviceParam device)
Create a text engine for drawing text with the SDL GPU API.
Definition: SDL3pp_ttf.h:5555
void SetSDF(bool enabled)
Enable Signed Distance Field rendering for a font.
Definition: SDL3pp_ttf.h:2596
Font OpenFontWithProperties(PropertiesParam props)
Create a font with the specified properties.
Definition: SDL3pp_ttf.h:2072
constexpr int FONT_WEIGHT_EXTRA_BOLD
ExtraBold (800) named font weight value.
Definition: SDL3pp_ttf.h:2652
void GetFontDPI(FontParam font, int *hdpi, int *vdpi)
Get font target resolutions, in dots per inch.
Definition: SDL3pp_ttf.h:2365
void SetScript(Uint32 script)
Set the script to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5935
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:343
Uint32 GetFontGeneration(FontParam font)
Get the font generation.
Definition: SDL3pp_ttf.h:2187
void SetLineSkip(int lineskip)
Set the spacing between lines of text for a font.
Definition: SDL3pp_ttf.h:2778
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:2612
void SetKerning(bool enabled)
Set if kerning is enabled for a font.
Definition: SDL3pp_ttf.h:2827
float GetFontSize(FontParam font)
Get the size of a font.
Definition: SDL3pp_ttf.h:2346
bool IsScalable() const
Query whether a font is scalable or not.
Definition: SDL3pp_ttf.h:2890
void SetFontDirection(FontParam font, Direction direction)
Set the direction to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:2961
Uint32 GetFontScript(FontParam font)
Get the script used for text shaping a font.
Definition: SDL3pp_ttf.h:3075
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:3889
void GetFreeTypeVersion(int *major, int *minor, int *patch)
Query the version of the FreeType library in use.
Definition: SDL3pp_ttf.h:302
void TagToString(Uint32 tag, char *string, size_t size)
Convert from a 32-bit tag to a 4 character string.
Definition: SDL3pp_ttf.h:3026
TTF_GPUTextEngineWinding GPUTextEngineWinding
The winding order of the vertices returned by Text.GetGPUDrawData.
Definition: SDL3pp_ttf.h:3970
constexpr FontStyleFlags STYLE_BOLD
Bold style.
Definition: SDL3pp_ttf.h:341
constexpr FontStyleFlags STYLE_STRIKETHROUGH
Strikethrough text.
Definition: SDL3pp_ttf.h:348
constexpr int FONT_WEIGHT_THIN
Thin (100) named font weight value.
Definition: SDL3pp_ttf.h:2631
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:2888
void SetColorFloat(FColor c)
Set the color of a text object.
Definition: SDL3pp_ttf.h:6010
constexpr Direction DIRECTION_RTL
Right to Left.
Definition: SDL3pp_ttf.h:421
TTF_ImageType ImageType
The type of data in a glyph image.
Definition: SDL3pp_ttf.h:432
Direction GetDirection() const
Get the direction to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:2989
GPUTextEngineWinding GetGPUWinding() const
Get the winding order of the vertices returned by Text.GetGPUDrawData for a particular GPU text engin...
Definition: SDL3pp_ttf.h:5707
Uint32 GetGeneration() const
Get the font generation.
Definition: SDL3pp_ttf.h:2192
void SetFontSize(FontParam font, float ptsize)
Set a font's size dynamically.
Definition: SDL3pp_ttf.h:2291
int GetDescent() const
Query the offset from the baseline to the bottom of a font.
Definition: SDL3pp_ttf.h:2756
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:3519
TTF_TextEngine * TextEngineRaw
Alias to raw representation for TextEngine.
Definition: SDL3pp_ttf.h:72
int GetFontDescent(FontParam font)
Query the offset from the baseline to the bottom of a font.
Definition: SDL3pp_ttf.h:2754
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:3332
constexpr HintingFlags HINTING_NORMAL
Normal hinting applies standard grid-fitting.
Definition: SDL3pp_ttf.h:367
int GetGlyphKerning(FontParam font, Uint32 previous_ch, Uint32 ch)
Query the kerning size between the glyphs of two UNICODE codepoints.
Definition: SDL3pp_ttf.h:3271
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:3387
constexpr HorizontalAlignment HORIZONTAL_ALIGN_INVALID
INVALID.
Definition: SDL3pp_ttf.h:392
TextEngineParam GetEngine() const
Get the text engine used by a text object.
Definition: SDL3pp_ttf.h:5808
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:5880
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:3607
void SetTextPosition(TextParam text, Point p)
Set the position of a text object.
Definition: SDL3pp_ttf.h:6157
bool HasGlyph(Uint32 ch) const
Check whether a glyph is provided by the font for a UNICODE codepoint.
Definition: SDL3pp_ttf.h:3147
constexpr Direction DIRECTION_INVALID
INVALID.
Definition: SDL3pp_ttf.h:417
FontStyleFlags GetFontStyle(FontParam font)
Query a font's current style.
Definition: SDL3pp_ttf.h:2429
const char * GetFontStyleName(FontParam font)
Query a font's style name.
Definition: SDL3pp_ttf.h:2934
constexpr HintingFlags HINTING_NONE
No hinting, the font is rendered without any grid-fitting.
Definition: SDL3pp_ttf.h:380
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:2649
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:3662
constexpr ImageType IMAGE_ALPHA
The color channels are white.
Definition: SDL3pp_ttf.h:436
void SetWrapAlignment(HorizontalAlignment align)
Set a font's current wrap alignment option.
Definition: SDL3pp_ttf.h:2683
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:2643
void ClearFallbackFonts(FontParam font)
Remove all fallback fonts.
Definition: SDL3pp_ttf.h:2270
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:5858
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:3617
void SetFontStyle(FontParam font, FontStyleFlags style)
Set a font's current style.
Definition: SDL3pp_ttf.h:2399
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:3745
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:5675
HorizontalAlignment GetFontWrapAlignment(FontParam font)
Query a font's current wrap alignment option.
Definition: SDL3pp_ttf.h:2700
int GetWeight() const
Query a font's weight, in terms of the lightness/heaviness of the strokes.
Definition: SDL3pp_ttf.h:2629
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:3566
constexpr GPUTextEngineWinding GPU_TEXTENGINE_WINDING_INVALID
INVALID.
Definition: SDL3pp_ttf.h:3972
void SetDirection(Direction direction)
Set the direction to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:2966
void SetScript(Uint32 script)
Set the script to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:3055
bool FontIsFixedWidth(FontParam font)
Query whether a font is fixed-width.
Definition: SDL3pp_ttf.h:2864
int GetLineSkip() const
Query the spacing between lines of text for a font.
Definition: SDL3pp_ttf.h:2797
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:2610
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:3934
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:2705
void AddFallback(FontParam fallback)
Add a fallback font.
Definition: SDL3pp_ttf.h:2224
void DestroyGPUTextEngine(TextEngineRaw engine)
Destroy a text engine created for drawing text with the SDL GPU API.
Definition: SDL3pp_ttf.h:5653
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:3701
int GetFontAscent(FontParam font)
Query the offset from the baseline to the top of a font.
Definition: SDL3pp_ttf.h:2738
void DrawSurfaceText(TextConstParam text, Point p, SurfaceParam surface)
Draw text to an SDL surface.
Definition: SDL3pp_ttf.h:5382
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:5702
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:2219
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:345
constexpr int FONT_WEIGHT_EXTRA_BLACK
ExtraBlack (950) named font weight value.
Definition: SDL3pp_ttf.h:2658
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:5903
constexpr SubStringFlags SUBSTRING_TEXT_END
This substring contains the end of the text.
Definition: SDL3pp_ttf.h:3962
Font Copy() const
Create a copy of an existing font.
Definition: SDL3pp_ttf.h:2140
constexpr SubStringFlags SUBSTRING_DIRECTION_MASK
The mask for the flow direction for this substring.
Definition: SDL3pp_ttf.h:3948
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:3471
TTF_HorizontalAlignment HorizontalAlignment
The horizontal alignment used when rendering wrapped text.
Definition: SDL3pp_ttf.h:390
PropertiesRef GetProperties() const
Get the properties associated with a text object.
Definition: SDL3pp_ttf.h:5758
constexpr Direction DIRECTION_TTB
Top to Bottom.
Definition: SDL3pp_ttf.h:423
int GetNumFaces() const
Query the number of faces of a font.
Definition: SDL3pp_ttf.h:2532
void SetTextColor(TextParam text, Color c)
Set the color of a text object.
Definition: SDL3pp_ttf.h:5981
void RemoveFallbackFont(FontParam font, FontParam fallback)
Remove a fallback font.
Definition: SDL3pp_ttf.h:2245
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:6073
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:3926
void SetEngine(TextEngineParam engine)
Set the text engine used by a text object.
Definition: SDL3pp_ttf.h:5784
TextEngineParam GetTextEngine(TextConstParam text)
Get the text engine used by a text object.
Definition: SDL3pp_ttf.h:5803
void SetSize(float ptsize)
Set a font's size dynamically.
Definition: SDL3pp_ttf.h:2296
constexpr HintingFlags HINTING_LIGHT_SUBPIXEL
Light hinting with subpixel rendering for more precise font edges.
Definition: SDL3pp_ttf.h:383
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:2460
SurfaceTextEngine CreateSurfaceTextEngine()
Create a text engine for drawing text on SDL surfaces.
Definition: SDL3pp_ttf.h:5357
void GetDPI(int *hdpi, int *vdpi) const
Get font target resolutions, in dots per inch.
Definition: SDL3pp_ttf.h:2370
Font OpenFont(StringParam file, float ptsize)
Create a font from a file, using a specified point size.
Definition: SDL3pp_ttf.h:1995
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:2162
Surface GetGlyphImageForIndex(FontParam font, Uint32 glyph_index, ImageType *image_type)
Get the pixel image for a character index.
Definition: SDL3pp_ttf.h:3195
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:3831
void SetFontWrapAlignment(FontParam font, HorizontalAlignment align)
Set a font's current wrap alignment option.
Definition: SDL3pp_ttf.h:2678
void SetHinting(HintingFlags hinting)
Set a font's current hinter setting.
Definition: SDL3pp_ttf.h:2515
GPUAtlasDrawSequence * GetGPUDrawData() const
Get the geometry data needed for drawing the text.
Definition: SDL3pp_ttf.h:5633
TTF_Text * TextRaw
Alias to raw representation for Text.
Definition: SDL3pp_ttf.h:105
void DrawRendererText(TextConstParam text, FPoint p)
Draw text to an SDL renderer.
Definition: SDL3pp_ttf.h:5503
FColor GetColorFloat() const
Get the color of a text object.
Definition: SDL3pp_ttf.h:6133
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:3247
Uint32 GetScript() const
Get the script used for text shaping a font.
Definition: SDL3pp_ttf.h:3077
void GetTextColor(TextConstParam text, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Get the color of a text object.
Definition: SDL3pp_ttf.h:6037
constexpr HorizontalAlignment HORIZONTAL_ALIGN_LEFT
LEFT.
Definition: SDL3pp_ttf.h:395
void SetTextEngine(TextParam text, TextEngineParam engine)
Set the text engine used by a text object.
Definition: SDL3pp_ttf.h:5779
constexpr int FONT_WEIGHT_SEMI_BOLD
SemiBold (600) named font weight value.
Definition: SDL3pp_ttf.h:2646
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:2740
PropertiesRef GetProperties()
Get the properties associated with a font.
Definition: SDL3pp_ttf.h:2167
Uint32 GetScript() const
Get the script used for text shaping a text object.
Definition: SDL3pp_ttf.h:5962
bool SetTextFont(TextParam text, FontParam font)
Set the font used by a text object.
Definition: SDL3pp_ttf.h:5834
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:3879
constexpr int FONT_WEIGHT_NORMAL
Normal (400) named font weight value.
Definition: SDL3pp_ttf.h:2640
int GetNumFontFaces(FontParam font)
Query the number of faces of a font.
Definition: SDL3pp_ttf.h:2530
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:3654
Surface GetGlyphImage(FontParam font, Uint32 ch, ImageType *image_type)
Get the pixel image for a UNICODE codepoint.
Definition: SDL3pp_ttf.h:3167
TTF_Direction Direction
Direction flags.
Definition: SDL3pp_ttf.h:415
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:3788
constexpr ImageType IMAGE_SDF
The alpha channel has signed distance field information.
Definition: SDL3pp_ttf.h:443
constexpr int FONT_WEIGHT_LIGHT
Light (300) named font weight value.
Definition: SDL3pp_ttf.h:2637
void SetFontHinting(FontParam font, HintingFlags hinting)
Set a font's current hinter setting.
Definition: SDL3pp_ttf.h:2510
void Destroy() final
Destroy a text engine created for drawing text with the SDL GPU API.
Definition: SDL3pp_ttf.h:5658
GPUAtlasDrawSequence * GetGPUTextDrawData(TextConstParam text)
Get the geometry data needed for drawing the text.
Definition: SDL3pp_ttf.h:5628
constexpr GPUTextEngineWinding GPU_TEXTENGINE_WINDING_CLOCKWISE
CLOCKWISE.
Definition: SDL3pp_ttf.h:3975
void SetTextColorFloat(TextParam text, FColor c)
Set the color of a text object.
Definition: SDL3pp_ttf.h:6005
::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:2189
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition: SDL3pp_pixels.h:2362
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:43
constexpr FontParam(FontRaw value)
Constructs from FontRaw.
Definition: SDL3pp_ttf.h:47
constexpr FontParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_ttf.h:53
FontRaw value
parameter's FontRaw
Definition: SDL3pp_ttf.h:44
constexpr auto operator<=>(const FontParam &other) const =default
Comparison.
Semi-safe reference for Font.
Definition: SDL3pp_ttf.h:1938
FontRef(const FontRef &other) noexcept
Copy constructor.
Definition: SDL3pp_ttf.h:1966
~FontRef()
Destructor.
Definition: SDL3pp_ttf.h:1972
FontRef(FontParam resource) noexcept
Constructs from FontParam.
Definition: SDL3pp_ttf.h:1948
FontRef(FontRaw resource) noexcept
Constructs from FontParam.
Definition: SDL3pp_ttf.h:1960
Safely wrap GPUDevice for non owning parameters.
Definition: SDL3pp_gpu.h:308
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:52
Semi-safe reference for Properties.
Definition: SDL3pp_properties.h:708
Safely wrap Renderer for non owning parameters.
Definition: SDL3pp_render.h:53
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:46
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:142
constexpr auto operator<=>(const TextConstParam &other) const =default
Comparison.
const TextRaw value
parameter's const TextRaw
Definition: SDL3pp_ttf.h:143
constexpr TextConstParam(TextParam value)
Constructs from TextParam.
Definition: SDL3pp_ttf.h:152
constexpr TextConstParam(const TextRaw value)
Constructs from const TextRaw.
Definition: SDL3pp_ttf.h:146
constexpr TextConstParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_ttf.h:158
constexpr auto operator->()
member access to underlying TextRaw.
Definition: SDL3pp_ttf.h:173
Safely wrap TextEngine for non owning parameters.
Definition: SDL3pp_ttf.h:76
constexpr TextEngineParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_ttf.h:86
constexpr auto operator<=>(const TextEngineParam &other) const =default
Comparison.
constexpr TextEngineParam(TextEngineRaw value)
Constructs from TextEngineRaw.
Definition: SDL3pp_ttf.h:80
TextEngineRaw value
parameter's TextEngineRaw
Definition: SDL3pp_ttf.h:77
Safely wrap Text for non owning parameters.
Definition: SDL3pp_ttf.h:112
constexpr auto operator<=>(const TextParam &other) const =default
Comparison.
constexpr TextParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_ttf.h:122
constexpr TextParam(TextRaw value)
Constructs from TextRaw.
Definition: SDL3pp_ttf.h:116
TextRaw value
parameter's TextRaw
Definition: SDL3pp_ttf.h:113
constexpr auto operator->()
member access to underlying TextRaw.
Definition: SDL3pp_ttf.h:137
Semi-safe reference for Text.
Definition: SDL3pp_ttf.h:5236
TextRef(TextRaw resource) noexcept
Constructs from TextParam.
Definition: SDL3pp_ttf.h:5258
TextRef(const TextRef &other) noexcept
Copy constructor.
Definition: SDL3pp_ttf.h:5264
TextRef(TextParam resource=nullptr) noexcept
Constructs from TextParam.
Definition: SDL3pp_ttf.h:5246
~TextRef()
Destructor.
Definition: SDL3pp_ttf.h:5270