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
36// Forward decl
37struct TextEngine;
38
40using TextEngineRaw = TTF_TextEngine*;
41
44{
46
49 : value(value)
50 {
51 }
52
54 constexpr TextEngineRef(std::nullptr_t = nullptr)
55 : value(nullptr)
56 {
57 }
58
60 constexpr explicit operator bool() const { return !!value; }
61
63 constexpr auto operator<=>(const TextEngineRef& other) const = default;
64
66 constexpr operator TextEngineRaw() const { return value; }
67};
68
69// Forward decl
70struct Text;
71
73using TextRaw = TTF_Text*;
74
75// Forward decl
76struct TextRef;
77
80{
81 const TextRaw value;
82
84 constexpr TextConstRef(const TextRaw value)
85 : value(value)
86 {
87 }
88
90 constexpr TextConstRef(std::nullptr_t = nullptr)
91 : value(nullptr)
92 {
93 }
94
96 constexpr explicit operator bool() const { return !!value; }
97
99 constexpr auto operator<=>(const TextConstRef& other) const = default;
100
102 constexpr operator const TextRaw() const { return value; }
103
105 constexpr auto operator->() { return value; }
106};
107
108#ifdef SDL3PP_DOC
109
115#define SDL_TTF_MAJOR_VERSION
116
117#define SDL_TTF_MINOR_VERSION
118
119#define SDL_TTF_MICRO_VERSION
120
122
126#define SDL_TTF_VERSION \
127 SDL_VERSIONNUM( \
128 SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_MICRO_VERSION)
129
133#define SDL_TTF_VERSION_ATLEAST(X, Y, Z) \
134 ((SDL_TTF_MAJOR_VERSION >= X) && \
135 (SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION >= Y) && \
136 (SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION > Y || \
137 SDL_TTF_MICRO_VERSION >= Z))
138
139#endif // SDL3PP_DOC
140
141namespace TTF {
142
152inline int Version() { return TTF_Version(); }
153
169inline void Init() { CheckError(TTF_Init()); }
170
191inline void Quit() { TTF_Quit(); }
192
215inline int WasInit() { return TTF_WasInit(); }
216
217} // namespace TTF
218
234inline void GetFreeTypeVersion(int* major, int* minor, int* patch)
235{
236 TTF_GetFreeTypeVersion(major, minor, patch);
237}
238
252inline void GetHarfBuzzVersion(int* major, int* minor, int* patch)
253{
254 TTF_GetHarfBuzzVersion(major, minor, patch);
255}
256
270
271constexpr FontStyleFlags STYLE_NORMAL = TTF_STYLE_NORMAL;
272
273constexpr FontStyleFlags STYLE_BOLD = TTF_STYLE_BOLD;
274
275constexpr FontStyleFlags STYLE_ITALIC = TTF_STYLE_ITALIC;
276
278 TTF_STYLE_UNDERLINE;
279
281 TTF_STYLE_STRIKETHROUGH;
282
295using HintingFlags = TTF_HintingFlags;
296
297#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
298
299constexpr HintingFlags HINTING_INVALID = TTF_HINTING_INVALID;
300
301#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 2)
302
304 TTF_HINTING_NORMAL;
305
307constexpr HintingFlags HINTING_LIGHT = TTF_HINTING_LIGHT;
308
313constexpr HintingFlags HINTING_MONO = TTF_HINTING_MONO;
314
316constexpr HintingFlags HINTING_NONE = TTF_HINTING_NONE;
317
319constexpr HintingFlags HINTING_LIGHT_SUBPIXEL = TTF_HINTING_LIGHT_SUBPIXEL;
320
326using HorizontalAlignment = TTF_HorizontalAlignment;
327
329 TTF_HORIZONTAL_ALIGN_INVALID;
330
332 TTF_HORIZONTAL_ALIGN_LEFT;
333
335 TTF_HORIZONTAL_ALIGN_CENTER;
336
338 TTF_HORIZONTAL_ALIGN_RIGHT;
339
351using Direction = TTF_Direction;
352
353constexpr Direction DIRECTION_INVALID = TTF_DIRECTION_INVALID;
354
355constexpr Direction DIRECTION_LTR = TTF_DIRECTION_LTR;
356
357constexpr Direction DIRECTION_RTL = TTF_DIRECTION_RTL;
358
359constexpr Direction DIRECTION_TTB = TTF_DIRECTION_TTB;
360
361constexpr Direction DIRECTION_BTT = TTF_DIRECTION_BTT;
362
368using ImageType = TTF_ImageType;
369
370constexpr ImageType IMAGE_INVALID = TTF_IMAGE_INVALID;
371
373 TTF_IMAGE_ALPHA;
374
376 TTF_IMAGE_COLOR;
377
379constexpr ImageType IMAGE_SDF = TTF_IMAGE_SDF;
380
388class Font
389{
390 FontRaw m_resource = nullptr;
391
392public:
394 constexpr Font(std::nullptr_t = nullptr) noexcept
395 : m_resource(nullptr)
396 {
397 }
398
406 constexpr explicit Font(const FontRaw resource) noexcept
407 : m_resource(resource)
408 {
409 }
410
411protected:
413 constexpr Font(const Font& other) noexcept = default;
414
415public:
417 constexpr Font(Font&& other) noexcept
418 : Font(other.release())
419 {
420 }
421
422 constexpr Font(const FontRef& other) = delete;
423
424 constexpr Font(FontRef&& other) = delete;
425
444 Font(StringParam file, float ptsize);
445
469 Font(IOStreamRef src, float ptsize, bool closeio = false);
470
515
517 ~Font() { TTF_CloseFont(m_resource); }
518
520 constexpr Font& operator=(Font&& other) noexcept
521 {
522 std::swap(m_resource, other.m_resource);
523 return *this;
524 }
525
526protected:
528 constexpr Font& operator=(const Font& other) noexcept = default;
529
530public:
532 constexpr FontRaw get() const noexcept { return m_resource; }
533
535 constexpr FontRaw release() noexcept
536 {
537 auto r = m_resource;
538 m_resource = nullptr;
539 return r;
540 }
541
543 constexpr auto operator<=>(const Font& other) const noexcept = default;
544
546 constexpr explicit operator bool() const noexcept { return !!m_resource; }
547
567 void Close();
568
585 Font Copy() const;
586
607
622 Uint32 GetGeneration() const;
623
645 void AddFallback(FontRef fallback);
646
662 void RemoveFallback(FontRef fallback);
663
677 void ClearFallbacks();
678
695 void SetSize(float ptsize);
696
716 void SetSizeDPI(float ptsize, int hdpi, int vdpi);
717
732 float GetSize() const;
733
748 void GetDPI(int* hdpi, int* vdpi) const;
749
773 void SetStyle(FontStyleFlags style);
774
794 FontStyleFlags GetStyle() const;
795
816 void SetOutline(int outline);
817
829 int GetOutline() const;
830
854 void SetHinting(HintingFlags hinting);
855
865 int GetNumFaces() const;
866
887 HintingFlags GetHinting() const;
888
911 void SetSDF(bool enabled);
912
924 bool GetSDF() const;
925
926#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
927
938 int GetWeight() const;
939
940#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 2)
941
957
970
982 int GetHeight() const;
983
995 int GetAscent() const;
996
1008 int GetDescent() const;
1009
1024 void SetLineSkip(int lineskip);
1025
1037 int GetLineSkip() const;
1038
1058 void SetKerning(bool enabled);
1059
1071 bool GetKerning() const;
1072
1088 bool IsFixedWidth() const;
1089
1103 bool IsScalable() const;
1104
1120 const char* GetFamilyName() const;
1121
1137 const char* GetStyleName() const;
1138
1155 void SetDirection(Direction direction);
1156
1169 Direction GetDirection() const;
1170
1189 void SetScript(Uint32 script);
1190
1205 Uint32 GetScript() const;
1206
1222 static Uint32 GetGlyphScript(Uint32 ch);
1223
1241 void SetLanguage(StringParam language_bcp47);
1242
1254 bool HasGlyph(Uint32 ch) const;
1255
1270 Surface GetGlyphImage(Uint32 ch, ImageType* image_type) const;
1271
1290 ImageType* image_type) const;
1291
1319 void GetGlyphMetrics(Uint32 ch,
1320 int* minx,
1321 int* maxx,
1322 int* miny,
1323 int* maxy,
1324 int* advance) const;
1325
1339 int GetGlyphKerning(Uint32 previous_ch, Uint32 ch) const;
1340
1356 Point GetStringSize(std::string_view text) const
1357 {
1358 Point p;
1359 GetStringSize(text, &p.x, &p.y);
1360 return p;
1361 }
1362
1379 void GetStringSize(std::string_view text, int* w, int* h) const;
1380
1402 Point GetStringSizeWrapped(std::string_view text, int wrap_width) const
1403 {
1404 Point p;
1405 GetStringSizeWrapped(text, wrap_width, &p.x, &p.y);
1406 return p;
1407 }
1408
1431 void GetStringSizeWrapped(std::string_view text,
1432 int wrap_width,
1433 int* w,
1434 int* h) const;
1435
1458 void MeasureString(std::string_view text,
1459 int max_width,
1460 int* measured_width,
1461 size_t* measured_length) const;
1462
1495 Surface RenderText_Solid(std::string_view text, Color fg) const;
1496
1528 Surface RenderText_Solid_Wrapped(std::string_view text,
1529 Color fg,
1530 int wrapLength) const;
1531
1559
1593 Surface RenderText_Shaded(std::string_view text, Color fg, Color bg) const;
1594
1628 Surface RenderText_Shaded_Wrapped(std::string_view text,
1629 Color fg,
1630 Color bg,
1631 int wrap_width) const;
1632
1662
1694 Surface RenderText_Blended(std::string_view text, Color fg) const;
1695
1727 Surface RenderText_Blended_Wrapped(std::string_view text,
1728 Color fg,
1729 int wrap_width) const;
1730
1758
1791 Surface RenderText_LCD(std::string_view text, Color fg, Color bg) const;
1792
1826 Surface RenderText_LCD_Wrapped(std::string_view text,
1827 Color fg,
1828 Color bg,
1829 int wrap_width) const;
1830
1860};
1861
1868{
1869 using Font::Font;
1870
1878 FontRef(FontRaw resource) noexcept
1879 : Font(resource)
1880 {
1881 }
1882
1890 constexpr FontRef(const Font& resource) noexcept
1891 : Font(resource.get())
1892 {
1893 }
1894
1902 constexpr FontRef(Font&& resource) noexcept
1903 : Font(std::move(resource).release())
1904 {
1905 }
1906
1908 constexpr FontRef(const FontRef& other) noexcept
1909 : Font(other.get())
1910 {
1911 }
1912
1914 constexpr FontRef(FontRef&& other) noexcept
1915 : Font(other.get())
1916 {
1917 }
1918
1921
1923 constexpr FontRef& operator=(const FontRef& other) noexcept = default;
1924
1926 constexpr operator FontRaw() const noexcept { return get(); }
1927};
1928
1949inline Font OpenFont(StringParam file, float ptsize)
1950{
1951 return Font(std::move(file), ptsize);
1952}
1953
1979inline Font OpenFont(IOStreamRef src, float ptsize, bool closeio = false)
1980{
1981 return Font(src, ptsize, closeio);
1982}
1983
1984inline Font::Font(StringParam file, float ptsize)
1985 : m_resource(CheckError(TTF_OpenFont(file, ptsize)))
1986{
1987}
1988
1989inline Font::Font(IOStreamRef src, float ptsize, bool closeio)
1990 : m_resource(CheckError(TTF_OpenFontIO(src, closeio, ptsize)))
1991{
1992}
1993
1995 : m_resource(CheckError(TTF_OpenFontWithProperties(props)))
1996{
1997}
1998
2041inline Font OpenFontWithProperties(PropertiesRef props) { return Font(props); }
2042
2043namespace prop::Font {
2044
2045constexpr auto CREATE_FILENAME_STRING = TTF_PROP_FONT_CREATE_FILENAME_STRING;
2046
2047constexpr auto CREATE_IOSTREAM_POINTER = TTF_PROP_FONT_CREATE_IOSTREAM_POINTER;
2048
2049constexpr auto CREATE_IOSTREAM_OFFSET_NUMBER =
2050 TTF_PROP_FONT_CREATE_IOSTREAM_OFFSET_NUMBER;
2051
2052constexpr auto CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN =
2053 TTF_PROP_FONT_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN;
2054
2055constexpr auto CREATE_SIZE_FLOAT = TTF_PROP_FONT_CREATE_SIZE_FLOAT;
2056
2057constexpr auto CREATE_FACE_NUMBER = TTF_PROP_FONT_CREATE_FACE_NUMBER;
2058
2059constexpr auto CREATE_HORIZONTAL_DPI_NUMBER =
2060 TTF_PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER;
2061
2062constexpr auto CREATE_VERTICAL_DPI_NUMBER =
2063 TTF_PROP_FONT_CREATE_VERTICAL_DPI_NUMBER;
2064
2065#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
2066
2067constexpr auto CREATE_EXISTING_FONT_POINTER =
2068 TTF_PROP_FONT_CREATE_EXISTING_FONT;
2069
2070#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 2)
2071
2072constexpr auto OUTLINE_LINE_CAP_NUMBER = TTF_PROP_FONT_OUTLINE_LINE_CAP_NUMBER;
2073
2074constexpr auto OUTLINE_LINE_JOIN_NUMBER =
2075 TTF_PROP_FONT_OUTLINE_LINE_JOIN_NUMBER;
2076
2077constexpr auto OUTLINE_MITER_LIMIT_NUMBER =
2078 TTF_PROP_FONT_OUTLINE_MITER_LIMIT_NUMBER;
2079
2080} // namespace prop::Font
2081
2101inline Font CopyFont(FontRef existing_font)
2102{
2103 return Font(CheckError(TTF_CopyFont(existing_font)));
2104}
2105
2106inline Font Font::Copy() const { return SDL::CopyFont(m_resource); }
2107
2129{
2130 return {CheckError(TTF_GetFontProperties(font))};
2131}
2132
2134{
2135 return SDL::GetFontProperties(m_resource);
2136}
2137
2154{
2155 return TTF_GetFontGeneration(font);
2156}
2157
2159{
2160 return SDL::GetFontGeneration(m_resource);
2161}
2162
2185inline void AddFallbackFont(FontRef font, FontRef fallback)
2186{
2187 CheckError(TTF_AddFallbackFont(font, fallback));
2188}
2189
2190inline void Font::AddFallback(FontRef fallback)
2191{
2192 SDL::AddFallbackFont(m_resource, fallback);
2193}
2194
2211inline void RemoveFallbackFont(FontRef font, FontRef fallback)
2212{
2213 TTF_RemoveFallbackFont(font, fallback);
2214}
2215
2216inline void Font::RemoveFallback(FontRef fallback)
2217{
2218 SDL::RemoveFallbackFont(m_resource, fallback);
2219}
2220
2236inline void ClearFallbackFonts(FontRef font) { TTF_ClearFallbackFonts(font); }
2237
2238inline void Font::ClearFallbacks() { SDL::ClearFallbackFonts(m_resource); }
2239
2257inline void SetFontSize(FontRef font, float ptsize)
2258{
2259 CheckError(TTF_SetFontSize(font, ptsize));
2260}
2261
2262inline void Font::SetSize(float ptsize)
2263{
2264 SDL::SetFontSize(m_resource, ptsize);
2265}
2266
2287inline void SetFontSizeDPI(FontRef font, float ptsize, int hdpi, int vdpi)
2288{
2289 CheckError(TTF_SetFontSizeDPI(font, ptsize, hdpi, vdpi));
2290}
2291
2292inline void Font::SetSizeDPI(float ptsize, int hdpi, int vdpi)
2293{
2294 SDL::SetFontSizeDPI(m_resource, ptsize, hdpi, vdpi);
2295}
2296
2312inline float GetFontSize(FontRef font) { return TTF_GetFontSize(font); }
2313
2314inline float Font::GetSize() const { return SDL::GetFontSize(m_resource); }
2315
2331inline void GetFontDPI(FontRef font, int* hdpi, int* vdpi)
2332{
2333 CheckError(TTF_GetFontDPI(font, hdpi, vdpi));
2334}
2335
2336inline void Font::GetDPI(int* hdpi, int* vdpi) const
2337{
2338 SDL::GetFontDPI(m_resource, hdpi, vdpi);
2339}
2340
2365inline void SetFontStyle(FontRef font, FontStyleFlags style)
2366{
2367 TTF_SetFontStyle(font, style);
2368}
2369
2371{
2372 SDL::SetFontStyle(m_resource, style);
2373}
2374
2396{
2397 return TTF_GetFontStyle(font);
2398}
2399
2401{
2402 return SDL::GetFontStyle(m_resource);
2403}
2404
2426inline void SetFontOutline(FontRef font, int outline)
2427{
2428 CheckError(TTF_SetFontOutline(font, outline));
2429}
2430
2431inline void Font::SetOutline(int outline)
2432{
2433 SDL::SetFontOutline(m_resource, outline);
2434}
2435
2448inline int GetFontOutline(FontRef font) { return TTF_GetFontOutline(font); }
2449
2450inline int Font::GetOutline() const { return SDL::GetFontOutline(m_resource); }
2451
2476inline void SetFontHinting(FontRef font, HintingFlags hinting)
2477{
2478 TTF_SetFontHinting(font, hinting);
2479}
2480
2481inline void Font::SetHinting(HintingFlags hinting)
2482{
2483 SDL::SetFontHinting(m_resource, hinting);
2484}
2485
2496inline int GetNumFontFaces(FontRef font) { return TTF_GetNumFontFaces(font); }
2497
2498inline int Font::GetNumFaces() const
2499{
2500 return SDL::GetNumFontFaces(m_resource);
2501}
2502
2525{
2526 return TTF_GetFontHinting(font);
2527}
2528
2530{
2531 return SDL::GetFontHinting(m_resource);
2532}
2533
2557inline void SetFontSDF(FontRef font, bool enabled)
2558{
2559 CheckError(TTF_SetFontSDF(font, enabled));
2560}
2561
2562inline void Font::SetSDF(bool enabled) { SDL::SetFontSDF(m_resource, enabled); }
2563
2576inline bool GetFontSDF(FontRef font) { return TTF_GetFontSDF(font); }
2577
2578inline bool Font::GetSDF() const { return SDL::GetFontSDF(m_resource); }
2579
2580#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
2581
2593inline int GetFontWeight(FontRef font) { return TTF_GetFontWeight(font); }
2594
2595inline int Font::GetWeight() const { return SDL::GetFontWeight(m_resource); }
2596
2597constexpr int FONT_WEIGHT_THIN =
2598 TTF_FONT_WEIGHT_THIN;
2599
2601 TTF_FONT_WEIGHT_EXTRA_LIGHT;
2602
2603constexpr int FONT_WEIGHT_LIGHT =
2604 TTF_FONT_WEIGHT_LIGHT;
2605
2606constexpr int FONT_WEIGHT_NORMAL =
2607 TTF_FONT_WEIGHT_NORMAL;
2608
2609constexpr int FONT_WEIGHT_MEDIUM =
2610 TTF_FONT_WEIGHT_MEDIUM;
2611
2613 TTF_FONT_WEIGHT_SEMI_BOLD;
2614
2615constexpr int FONT_WEIGHT_BOLD =
2616 TTF_FONT_WEIGHT_BOLD;
2617
2619 TTF_FONT_WEIGHT_EXTRA_BOLD;
2620
2621constexpr int FONT_WEIGHT_BLACK =
2622 TTF_FONT_WEIGHT_BLACK;
2623
2625 TTF_FONT_WEIGHT_EXTRA_BLACK;
2626
2627#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 2)
2628
2645{
2646 TTF_SetFontWrapAlignment(font, align);
2647}
2648
2650{
2651 SDL::SetFontWrapAlignment(m_resource, align);
2652}
2653
2667{
2668 return TTF_GetFontWrapAlignment(font);
2669}
2670
2672{
2673 return SDL::GetFontWrapAlignment(m_resource);
2674}
2675
2688inline int GetFontHeight(FontRef font) { return TTF_GetFontHeight(font); }
2689
2690inline int Font::GetHeight() const { return SDL::GetFontHeight(m_resource); }
2691
2704inline int GetFontAscent(FontRef font) { return TTF_GetFontAscent(font); }
2705
2706inline int Font::GetAscent() const { return SDL::GetFontAscent(m_resource); }
2707
2720inline int GetFontDescent(FontRef font) { return TTF_GetFontDescent(font); }
2721
2722inline int Font::GetDescent() const { return SDL::GetFontDescent(m_resource); }
2723
2739inline void SetFontLineSkip(FontRef font, int lineskip)
2740{
2741 TTF_SetFontLineSkip(font, lineskip);
2742}
2743
2744inline void Font::SetLineSkip(int lineskip)
2745{
2746 SDL::SetFontLineSkip(m_resource, lineskip);
2747}
2748
2761inline int GetFontLineSkip(FontRef font) { return TTF_GetFontLineSkip(font); }
2762
2763inline int Font::GetLineSkip() const
2764{
2765 return SDL::GetFontLineSkip(m_resource);
2766}
2767
2788inline void SetFontKerning(FontRef font, bool enabled)
2789{
2790 TTF_SetFontKerning(font, enabled);
2791}
2792
2793inline void Font::SetKerning(bool enabled)
2794{
2795 SDL::SetFontKerning(m_resource, enabled);
2796}
2797
2810inline bool GetFontKerning(FontRef font) { return TTF_GetFontKerning(font); }
2811
2812inline bool Font::GetKerning() const { return SDL::GetFontKerning(m_resource); }
2813
2830inline bool FontIsFixedWidth(FontRef font)
2831{
2832 return TTF_FontIsFixedWidth(font);
2833}
2834
2835inline bool Font::IsFixedWidth() const
2836{
2837 return SDL::FontIsFixedWidth(m_resource);
2838}
2839
2854inline bool FontIsScalable(FontRef font) { return TTF_FontIsScalable(font); }
2855
2856inline bool Font::IsScalable() const { return SDL::FontIsScalable(m_resource); }
2857
2874inline const char* GetFontFamilyName(FontRef font)
2875{
2876 return TTF_GetFontFamilyName(font);
2877}
2878
2879inline const char* Font::GetFamilyName() const
2880{
2881 return SDL::GetFontFamilyName(m_resource);
2882}
2883
2900inline const char* GetFontStyleName(FontRef font)
2901{
2902 return TTF_GetFontStyleName(font);
2903}
2904
2905inline const char* Font::GetStyleName() const
2906{
2907 return SDL::GetFontStyleName(m_resource);
2908}
2909
2927inline void SetFontDirection(FontRef font, Direction direction)
2928{
2929 CheckError(TTF_SetFontDirection(font, direction));
2930}
2931
2932inline void Font::SetDirection(Direction direction)
2933{
2934 SDL::SetFontDirection(m_resource, direction);
2935}
2936
2951{
2952 return TTF_GetFontDirection(font);
2953}
2954
2956{
2957 return SDL::GetFontDirection(m_resource);
2958}
2959
2973{
2974 return TTF_StringToTag(string);
2975}
2976
2992inline void TagToString(Uint32 tag, char* string, size_t size)
2993{
2994 TTF_TagToString(tag, string, size);
2995}
2996
3016inline void SetFontScript(FontRef font, Uint32 script)
3017{
3018 CheckError(TTF_SetFontScript(font, script));
3019}
3020
3021inline void Font::SetScript(Uint32 script)
3022{
3023 SDL::SetFontScript(m_resource, script);
3024}
3025
3041inline Uint32 GetFontScript(FontRef font) { return TTF_GetFontScript(font); }
3042
3043inline Uint32 Font::GetScript() const { return SDL::GetFontScript(m_resource); }
3044
3060{
3061 return CheckError(TTF_GetGlyphScript(ch));
3062}
3063
3065{
3066 return SDL::GetGlyphScript(ch);
3067}
3068
3086inline void SetFontLanguage(FontRef font, StringParam language_bcp47)
3087{
3088 CheckError(TTF_SetFontLanguage(font, language_bcp47));
3089}
3090
3091inline void Font::SetLanguage(StringParam language_bcp47)
3092{
3093 SDL::SetFontLanguage(m_resource, std::move(language_bcp47));
3094}
3095
3108inline bool FontHasGlyph(FontRef font, Uint32 ch)
3109{
3110 return TTF_FontHasGlyph(font, ch);
3111}
3112
3113inline bool Font::HasGlyph(Uint32 ch) const
3114{
3115 return SDL::FontHasGlyph(m_resource, ch);
3116}
3117
3133inline Surface GetGlyphImage(FontRef font, Uint32 ch, ImageType* image_type)
3134{
3135 return Surface{CheckError(TTF_GetGlyphImage(font, ch, image_type))};
3136}
3137
3138inline Surface Font::GetGlyphImage(Uint32 ch, ImageType* image_type) const
3139{
3140 return SDL::GetGlyphImage(m_resource, ch, image_type);
3141}
3142
3162 Uint32 glyph_index,
3163 ImageType* image_type)
3164{
3165 return Surface(
3166 CheckError(TTF_GetGlyphImageForIndex(font, glyph_index, image_type)));
3167}
3168
3170 ImageType* image_type) const
3171{
3172 return SDL::GetGlyphImageForIndex(m_resource, glyph_index, image_type);
3173}
3174
3203inline void GetGlyphMetrics(FontRef font,
3204 Uint32 ch,
3205 int* minx,
3206 int* maxx,
3207 int* miny,
3208 int* maxy,
3209 int* advance)
3210{
3211 CheckError(TTF_GetGlyphMetrics(font, ch, minx, maxx, miny, maxy, advance));
3212}
3213
3215 int* minx,
3216 int* maxx,
3217 int* miny,
3218 int* maxy,
3219 int* advance) const
3220{
3221 SDL::GetGlyphMetrics(m_resource, ch, minx, maxx, miny, maxy, advance);
3222}
3223
3238inline int GetGlyphKerning(FontRef font, Uint32 previous_ch, Uint32 ch)
3239{
3240 if (int r; TTF_GetGlyphKerning(font, previous_ch, ch, &r)) return r;
3241 throw Error();
3242}
3243
3244inline int Font::GetGlyphKerning(Uint32 previous_ch, Uint32 ch) const
3245{
3246 return SDL::GetGlyphKerning(m_resource, previous_ch, ch);
3247}
3248
3266inline void GetStringSize(FontRef font, std::string_view text, int* w, int* h)
3267{
3268 CheckError(TTF_GetStringSize(font, text.data(), text.size(), w, h));
3269}
3270
3271inline void Font::GetStringSize(std::string_view text, int* w, int* h) const
3272{
3273 SDL::GetStringSize(m_resource, text, w, h);
3274}
3275
3300 std::string_view text,
3301 int wrap_width,
3302 int* w,
3303 int* h)
3304{
3305 CheckError(
3306 TTF_GetStringSizeWrapped(font, text.data(), text.size(), wrap_width, w, h));
3307}
3308
3309inline void Font::GetStringSizeWrapped(std::string_view text,
3310 int wrap_width,
3311 int* w,
3312 int* h) const
3313{
3314 SDL::GetStringSizeWrapped(m_resource, text, wrap_width, w, h);
3315}
3316
3340inline void MeasureString(FontRef font,
3341 std::string_view text,
3342 int max_width,
3343 int* measured_width,
3344 size_t* measured_length)
3345{
3346 CheckError(TTF_MeasureString(font,
3347 text.data(),
3348 text.size(),
3349 max_width,
3350 measured_width,
3351 measured_length));
3352}
3353
3354inline void Font::MeasureString(std::string_view text,
3355 int max_width,
3356 int* measured_width,
3357 size_t* measured_length) const
3358{
3360 m_resource, text, max_width, measured_width, measured_length);
3361}
3362
3396inline Surface RenderText_Solid(FontRef font, std::string_view text, Color fg)
3397{
3398 return Surface{TTF_RenderText_Solid(font, text.data(), text.size(), fg)};
3399}
3400
3401inline Surface Font::RenderText_Solid(std::string_view text, Color fg) const
3402{
3403 return SDL::RenderText_Solid(m_resource, text, fg);
3404}
3405
3439 std::string_view text,
3440 Color fg,
3441 int wrapLength)
3442{
3443 return Surface(TTF_RenderText_Solid_Wrapped(
3444 font, text.data(), text.size(), fg, wrapLength));
3445}
3446
3447inline Surface Font::RenderText_Solid_Wrapped(std::string_view text,
3448 Color fg,
3449 int wrapLength) const
3450{
3451 return SDL::RenderText_Solid_Wrapped(m_resource, text, fg, wrapLength);
3452}
3453
3482{
3483 return Surface(TTF_RenderGlyph_Solid(font, ch, fg));
3484}
3485
3487{
3488 return SDL::RenderGlyph_Solid(m_resource, ch, fg);
3489}
3490
3526 std::string_view text,
3527 Color fg,
3528 Color bg)
3529{
3530 return Surface(TTF_RenderText_Shaded(font, text.data(), text.size(), fg, bg));
3531}
3532
3533inline Surface Font::RenderText_Shaded(std::string_view text,
3534 Color fg,
3535 Color bg) const
3536{
3537 return SDL::RenderText_Shaded(m_resource, text, fg, bg);
3538}
3539
3575 std::string_view text,
3576 Color fg,
3577 Color bg,
3578 int wrap_width)
3579{
3580 return Surface(TTF_RenderText_Shaded_Wrapped(
3581 font, text.data(), text.size(), fg, bg, wrap_width));
3582}
3583
3584inline Surface Font::RenderText_Shaded_Wrapped(std::string_view text,
3585 Color fg,
3586 Color bg,
3587 int wrap_width) const
3588{
3589 return SDL::RenderText_Shaded_Wrapped(m_resource, text, fg, bg, wrap_width);
3590}
3591
3622 Uint32 ch,
3623 ColorRaw fg,
3624 ColorRaw bg)
3625{
3626 return Surface(TTF_RenderGlyph_Shaded(font, ch, fg, bg));
3627}
3628
3630 ColorRaw fg,
3631 ColorRaw bg) const
3632{
3633 return SDL::RenderGlyph_Shaded(m_resource, ch, fg, bg);
3634}
3635
3668inline Surface RenderText_Blended(FontRef font, std::string_view text, Color fg)
3669{
3670 return Surface(TTF_RenderText_Blended(font, text.data(), text.size(), fg));
3671}
3672
3673inline Surface Font::RenderText_Blended(std::string_view text, Color fg) const
3674{
3675 return SDL::RenderText_Blended(m_resource, text, fg);
3676}
3677
3711 std::string_view text,
3712 Color fg,
3713 int wrap_width)
3714{
3715 return Surface(TTF_RenderText_Blended_Wrapped(
3716 font, text.data(), text.size(), fg, wrap_width));
3717}
3718
3719inline Surface Font::RenderText_Blended_Wrapped(std::string_view text,
3720 Color fg,
3721 int wrap_width) const
3722{
3723 return SDL::RenderText_Blended_Wrapped(m_resource, text, fg, wrap_width);
3724}
3725
3754{
3755 return Surface(TTF_RenderGlyph_Blended(font, ch, fg));
3756}
3757
3759{
3760 return SDL::RenderGlyph_Blended(m_resource, ch, fg);
3761}
3762
3797 std::string_view text,
3798 Color fg,
3799 Color bg)
3800{
3801 return Surface(TTF_RenderText_LCD(font, text.data(), text.size(), fg, bg));
3802}
3803
3804inline Surface Font::RenderText_LCD(std::string_view text,
3805 Color fg,
3806 Color bg) const
3807{
3808 return SDL::RenderText_LCD(m_resource, text, fg, bg);
3809}
3810
3845 std::string_view text,
3846 Color fg,
3847 Color bg,
3848 int wrap_width)
3849{
3850 return Surface(TTF_RenderText_LCD_Wrapped(
3851 font, text.data(), text.size(), fg, bg, wrap_width));
3852}
3853
3854inline Surface Font::RenderText_LCD_Wrapped(std::string_view text,
3855 Color fg,
3856 Color bg,
3857 int wrap_width) const
3858{
3859 return SDL::RenderText_LCD_Wrapped(m_resource, text, fg, bg, wrap_width);
3860}
3861
3892 Uint32 ch,
3893 ColorRaw fg,
3894 ColorRaw bg)
3895{
3896 return Surface(TTF_RenderGlyph_LCD(font, ch, fg, bg));
3897}
3898
3900{
3901 return SDL::RenderGlyph_LCD(m_resource, ch, fg, bg);
3902}
3903
3912
3914 TTF_SUBSTRING_DIRECTION_MASK;
3916
3918 TTF_SUBSTRING_TEXT_START;
3920
3922constexpr SubStringFlags SUBSTRING_LINE_START = TTF_SUBSTRING_LINE_START;
3923
3925constexpr SubStringFlags SUBSTRING_LINE_END = TTF_SUBSTRING_LINE_END;
3926
3928 TTF_SUBSTRING_TEXT_END;
3929
3935using GPUTextEngineWinding = TTF_GPUTextEngineWinding;
3936
3938 TTF_GPU_TEXTENGINE_WINDING_INVALID;
3939
3941 TTF_GPU_TEXTENGINE_WINDING_CLOCKWISE;
3942
3944 TTF_GPU_TEXTENGINE_WINDING_COUNTER_CLOCKWISE;
3945
3965{
3966 TextEngineRaw m_resource = nullptr;
3967
3968public:
3970 constexpr TextEngine(std::nullptr_t = nullptr) noexcept
3971 : m_resource(nullptr)
3972 {
3973 }
3974
3982 constexpr explicit TextEngine(const TextEngineRaw resource) noexcept
3983 : m_resource(resource)
3984 {
3985 }
3986
3987protected:
3989 constexpr TextEngine(const TextEngine& other) noexcept = default;
3990
3991public:
3993 constexpr TextEngine(TextEngine&& other) noexcept
3994 : TextEngine(other.release())
3995 {
3996 }
3997
3999 virtual ~TextEngine() = default;
4000
4002 constexpr TextEngine& operator=(TextEngine&& other) noexcept
4003 {
4004 std::swap(m_resource, other.m_resource);
4005 return *this;
4006 }
4007
4008protected:
4010 constexpr TextEngine& operator=(const TextEngine& other) noexcept = default;
4011
4012public:
4014 constexpr TextEngineRaw get() const noexcept { return m_resource; }
4015
4017 constexpr TextEngineRaw release() noexcept
4018 {
4019 auto r = m_resource;
4020 m_resource = nullptr;
4021 return r;
4022 }
4023
4025 constexpr auto operator<=>(const TextEngine& other) const noexcept = default;
4026
4028 constexpr explicit operator bool() const noexcept { return !!m_resource; }
4029
4031 virtual void Destroy() = 0;
4032
4048 Text CreateText(FontRef font, std::string_view text);
4049};
4050
4053{
4068
4070
4084 void Destroy() final;
4085};
4086
4089{
4107
4133
4135
4149 void Destroy() final;
4150};
4151
4154{
4172
4198
4199 ~GPUTextEngine() { Destroy(); }
4200
4214 void SetGPUWinding(GPUTextEngineWinding winding);
4215
4231
4245 void Destroy() final;
4246};
4247
4255using GPUAtlasDrawSequence = TTF_GPUAtlasDrawSequence;
4256
4269using SubString = TTF_SubString;
4270
4271// Forward decl
4272struct SubStringIterator;
4273
4279using TextData = TTF_TextData;
4280
4292class Text
4293{
4294 TextRaw m_resource = nullptr;
4295
4296public:
4298 constexpr Text(std::nullptr_t = nullptr) noexcept
4299 : m_resource(nullptr)
4300 {
4301 }
4302
4310 constexpr explicit Text(const TextRaw resource) noexcept
4311 : m_resource(resource)
4312 {
4313 }
4314
4315protected:
4317 constexpr Text(const Text& other) noexcept = default;
4318
4319public:
4321 constexpr Text(Text&& other) noexcept
4322 : Text(other.release())
4323 {
4324 }
4325
4326 constexpr Text(const TextRef& other) = delete;
4327
4328 constexpr Text(TextRef&& other) = delete;
4329
4347 Text(TextEngineRef engine, FontRef font, std::string_view text);
4348
4350 constexpr const TextRaw operator->() const noexcept { return m_resource; }
4351
4353 constexpr TextRaw operator->() noexcept { return m_resource; }
4354
4356 constexpr operator TextConstRef() const noexcept { return m_resource; }
4357
4359 ~Text() { TTF_DestroyText(m_resource); }
4360
4362 constexpr Text& operator=(Text&& other) noexcept
4363 {
4364 std::swap(m_resource, other.m_resource);
4365 return *this;
4366 }
4367
4368protected:
4370 constexpr Text& operator=(const Text& other) noexcept = default;
4371
4372public:
4374 constexpr TextRaw get() const noexcept { return m_resource; }
4375
4377 constexpr TextRaw release() noexcept
4378 {
4379 auto r = m_resource;
4380 m_resource = nullptr;
4381 return r;
4382 }
4383
4385 constexpr auto operator<=>(const Text& other) const noexcept = default;
4386
4388 constexpr explicit operator bool() const noexcept { return !!m_resource; }
4389
4400 void Destroy();
4401
4421 void DrawSurface(Point p, SurfaceRef surface) const;
4422
4442 void DrawRenderer(FPoint p) const;
4443
4471
4484
4500 void SetEngine(TextEngineRef engine);
4501
4515 TextEngineRef GetEngine() const;
4516
4537 bool SetFont(FontRef font);
4538
4552 FontRef GetFont() const;
4553
4568 void SetDirection(Direction direction);
4569
4582 Direction GetDirection() const;
4583
4600 void SetScript(Uint32 script);
4601
4618 Uint32 GetScript() const;
4619
4636 void SetColor(Color c);
4637
4654 void SetColorFloat(FColor c);
4655
4677 void GetColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a) const;
4678
4693 Color GetColor() const;
4694
4716 void GetColorFloat(float* r, float* g, float* b, float* a) const;
4717
4732 FColor GetColorFloat() const;
4733
4752 void SetPosition(const PointRaw& p);
4753
4770 void GetPosition(int* x, int* y) const;
4771
4786 Point GetPosition() const;
4787
4804 void SetWrapWidth(int wrap_width);
4805
4820 int GetWrapWidth() const;
4821
4843 void SetWrapWhitespaceVisible(bool visible);
4844
4858 bool IsWrapWhitespaceVisible() const;
4859
4877 void SetString(std::string_view string);
4878
4900 void InsertString(int offset, std::string_view string);
4901
4919 void AppendString(std::string_view string);
4920
4943 void DeleteString(int offset, int length);
4944
4962 void GetSize(int* w, int* h) const;
4963
4980 Point GetSize() const;
4981
5001 void GetSubString(int offset, SubString* substring) const;
5002
5007
5012
5029
5048 void GetSubStringForLine(int line, SubString* substring) const;
5049
5062 {
5063 return GetSubStringsForRange(0);
5064 }
5065
5082 OwnArray<SubString*> GetSubStringsForRange(int offset, int length = -1) const;
5083
5100
5117 void GetSubStringForPoint(Point p, SubString* substring) const;
5118
5135 void GetPreviousSubString(const SubString& substring,
5136 SubString* previous) const;
5137
5153 void GetNextSubString(const SubString& substring, SubString* next) const;
5154
5169 void Update();
5170
5175 const char* GetText() const { return m_resource->text; }
5176
5178 int GetNumLines() const { return m_resource->num_lines; }
5179};
5180
5187{
5188 using Text::Text;
5189
5197 TextRef(TextRaw resource) noexcept
5198 : Text(resource)
5199 {
5200 }
5201
5209 constexpr TextRef(const Text& resource) noexcept
5210 : Text(resource.get())
5211 {
5212 }
5213
5221 constexpr TextRef(Text&& resource) noexcept
5222 : Text(std::move(resource).release())
5223 {
5224 }
5225
5227 constexpr TextRef(const TextRef& other) noexcept
5228 : Text(other.get())
5229 {
5230 }
5231
5233 constexpr TextRef(TextRef&& other) noexcept
5234 : Text(other.get())
5235 {
5236 }
5237
5240
5242 constexpr TextRef& operator=(const TextRef& other) noexcept = default;
5243
5245 constexpr operator TextRaw() const noexcept { return get(); }
5246};
5247
5253{
5254 TextRef m_text;
5255
5256 SubString m_subString;
5257
5258 constexpr SubStringIterator(TextRef text)
5259 : m_text(text)
5260 , m_subString(0)
5261 {
5262 }
5263
5264public:
5268 {
5269 }
5270
5272 constexpr operator bool() const { return bool(m_text); }
5273
5275 constexpr const SubString& operator*() const { return m_subString; }
5276
5278 constexpr const SubString* operator->() const { return &m_subString; }
5279
5281 constexpr bool operator==(const SubStringIterator& other) const
5282 {
5283 return m_subString.offset == other.m_subString.offset;
5284 }
5285
5288 {
5289 m_text.GetNextSubString(m_subString, &m_subString);
5290 return *this;
5291 }
5292
5295 {
5296 auto curr = *this;
5297 m_text.GetNextSubString(m_subString, &m_subString);
5298 return curr;
5299 }
5300
5303 {
5304 m_text.GetPreviousSubString(m_subString, &m_subString);
5305 return *this;
5306 }
5307
5310 {
5311 auto curr = *this;
5312 m_text.GetPreviousSubString(m_subString, &m_subString);
5313 return curr;
5314 }
5315
5316 friend class Text;
5317};
5318
5333{
5334 return SurfaceTextEngine();
5335}
5336
5338 : TextEngine(TTF_CreateSurfaceTextEngine())
5339{
5340}
5341
5362inline void DrawSurfaceText(TextConstRef text, Point p, SurfaceRef surface)
5363{
5364 CheckError(TTF_DrawSurfaceText(text, p.x, p.y, surface));
5365}
5366
5367inline void Text::DrawSurface(Point p, SurfaceRef surface) const
5368{
5369 SDL::DrawSurfaceText(m_resource, p, surface);
5370}
5371
5389{
5390 TTF_DestroySurfaceTextEngine(engine);
5391}
5392
5394{
5396}
5397
5415{
5416 return RendererTextEngine(renderer);
5417}
5418
5420 : TextEngine(TTF_CreateRendererTextEngine(renderer))
5421{
5422}
5423
5425 : TextEngine(TTF_CreateRendererTextEngineWithProperties(props))
5426{
5427}
5428
5454 PropertiesRef props)
5455{
5456 return RendererTextEngine(props);
5457}
5458
5459namespace prop::RendererTextEngine {
5460
5461#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
5462
5463constexpr auto RENDERER_POINTER = TTF_PROP_RENDERER_TEXT_ENGINE_RENDERER;
5464
5465constexpr auto ATLAS_TEXTURE_SIZE_NUMBER =
5466 TTF_PROP_RENDERER_TEXT_ENGINE_ATLAS_TEXTURE_SIZE;
5467
5468#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 2)
5469
5470} // namespace prop::RendererTextEngine
5471
5493{
5494 CheckError(TTF_DrawRendererText(text, p.x, p.y));
5495}
5496
5497inline void Text::DrawRenderer(FPoint p) const
5498{
5499 SDL::DrawRendererText(m_resource, p);
5500}
5501
5519{
5520 TTF_DestroyRendererTextEngine(engine);
5521}
5522
5524{
5526}
5527
5545{
5546 return GPUTextEngine(device);
5547}
5548
5550 : TextEngine(TTF_CreateGPUTextEngine(device))
5551{
5552}
5553
5555 : TextEngine(TTF_CreateGPUTextEngineWithProperties(props))
5556{
5557}
5558
5584{
5585 return GPUTextEngine(props);
5586}
5587
5588namespace prop::GpuTextEngine {
5589
5590#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
5591
5592constexpr auto DEVICE_POINTER = TTF_PROP_GPU_TEXT_ENGINE_DEVICE;
5593
5594constexpr auto ATLAS_TEXTURE_SIZE_NUMBER =
5595 TTF_PROP_GPU_TEXT_ENGINE_ATLAS_TEXTURE_SIZE;
5596
5597#endif // SDL_TTF_VERSION_ATLEAST(3, 2, 2)
5598
5599} // namespace prop::GpuTextEngine
5600
5628{
5629 return TTF_GetGPUTextDrawData(text);
5630}
5631
5633{
5634 return SDL::GetGPUTextDrawData(m_resource);
5635}
5636
5653{
5654 TTF_DestroyGPUTextEngine(engine);
5655}
5656
5658
5675 GPUTextEngineWinding winding)
5676{
5677 TTF_SetGPUTextEngineWinding(engine, winding);
5678}
5679
5681{
5683}
5684
5702{
5703 return TTF_GetGPUTextEngineWinding(engine);
5704}
5705
5707{
5709}
5710
5729 FontRef font,
5730 std::string_view text)
5731{
5732 return Text(engine, font, text);
5733}
5734
5735inline Text TextEngine::CreateText(FontRef font, std::string_view text)
5736{
5737 return Text(m_resource, font, text);
5738}
5739
5740inline Text::Text(TextEngineRef engine, FontRef font, std::string_view text)
5741 : m_resource(TTF_CreateText(engine, font, text.data(), text.size()))
5742{
5743}
5744
5758{
5759 return {CheckError(TTF_GetTextProperties(text))};
5760}
5761
5763{
5764 return SDL::GetTextProperties(m_resource);
5765}
5766
5783inline void SetTextEngine(TextRef text, TextEngineRef engine)
5784{
5785 CheckError(TTF_SetTextEngine(text, engine));
5786}
5787
5789{
5790 SDL::SetTextEngine(m_resource, engine);
5791}
5792
5808{
5809 return CheckError(TTF_GetTextEngine(text));
5810}
5811
5813{
5814 return SDL::GetTextEngine(m_resource);
5815}
5816
5838inline bool SetTextFont(TextRef text, FontRef font)
5839{
5840 return TTF_SetTextFont(text, font);
5841}
5842
5843inline bool Text::SetFont(FontRef font)
5844{
5845 return SDL::SetTextFont(m_resource, font);
5846}
5847
5863{
5864 return {CheckError(TTF_GetTextFont(text))};
5865}
5866
5867inline FontRef Text::GetFont() const { return SDL::GetTextFont(m_resource); }
5868
5884inline void SetTextDirection(TextRef text, Direction direction)
5885{
5886 CheckError(TTF_SetTextDirection(text, direction));
5887}
5888
5889inline void Text::SetDirection(Direction direction)
5890{
5891 SDL::SetTextDirection(m_resource, direction);
5892}
5893
5908{
5909 return TTF_GetTextDirection(text);
5910}
5911
5913{
5914 return SDL::GetTextDirection(m_resource);
5915}
5916
5934inline void SetTextScript(TextRef text, Uint32 script)
5935{
5936 CheckError(TTF_SetTextScript(text, script));
5937}
5938
5939inline void Text::SetScript(Uint32 script)
5940{
5941 SDL::SetTextScript(m_resource, script);
5942}
5943
5962{
5963 return TTF_GetTextScript(text);
5964}
5965
5966inline Uint32 Text::GetScript() const { return SDL::GetTextScript(m_resource); }
5967
5985inline void SetTextColor(TextRef text, Color c)
5986{
5987 CheckError(TTF_SetTextColor(text, c.r, c.g, c.b, c.a));
5988}
5989
5990inline void Text::SetColor(Color c) { SDL::SetTextColor(m_resource, c); }
5991
6010{
6011 CheckError(TTF_SetTextColorFloat(text, c.r, c.g, c.b, c.a));
6012}
6013
6015{
6016 SDL::SetTextColorFloat(m_resource, c);
6017}
6018
6042 Uint8* r,
6043 Uint8* g,
6044 Uint8* b,
6045 Uint8* a)
6046{
6047 CheckError(TTF_GetTextColor(text, r, g, b, a));
6048}
6049
6066{
6067 Color c;
6068 GetTextColor(text, &c.r, &c.g, &c.b, &c.a);
6069 return c;
6070}
6071
6072inline void Text::GetColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a) const
6073{
6074 SDL::GetTextColor(m_resource, r, g, b, a);
6075}
6076
6077inline Color Text::GetColor() const { return SDL::GetTextColor(m_resource); }
6078
6102 float* r,
6103 float* g,
6104 float* b,
6105 float* a)
6106{
6107 CheckError(TTF_GetTextColorFloat(text, r, g, b, a));
6108}
6109
6126{
6127 FColor c;
6128 GetTextColorFloat(text, &c.r, &c.g, &c.b, &c.a);
6129 return c;
6130}
6131
6132inline void Text::GetColorFloat(float* r, float* g, float* b, float* a) const
6133{
6134 SDL::GetTextColorFloat(m_resource, r, g, b, a);
6135}
6136
6138{
6139 return SDL::GetTextColorFloat(m_resource);
6140}
6141
6161inline void SetTextPosition(TextRef text, const PointRaw& p)
6162{
6163 CheckError(TTF_SetTextPosition(text, p.x, p.y));
6164}
6165
6166inline void Text::SetPosition(const PointRaw& p)
6167{
6168 SDL::SetTextPosition(m_resource, p);
6169}
6170
6188inline void GetTextPosition(TextConstRef text, int* x, int* y)
6189{
6190 CheckError(TTF_GetTextPosition(text, x, y));
6191}
6192
6209{
6210 Point p;
6211 GetTextPosition(text, &p.x, &p.y);
6212 return p;
6213}
6214
6215inline void Text::GetPosition(int* x, int* y) const
6216{
6217 SDL::GetTextPosition(m_resource, x, y);
6218}
6219
6221{
6222 return SDL::GetTextPosition(m_resource);
6223}
6224
6242inline void SetTextWrapWidth(TextRef text, int wrap_width)
6243{
6244 CheckError(TTF_SetTextWrapWidth(text, wrap_width));
6245}
6246
6247inline void Text::SetWrapWidth(int wrap_width)
6248{
6249 SDL::SetTextWrapWidth(m_resource, wrap_width);
6250}
6251
6268{
6269 int w;
6270 CheckError(TTF_GetTextWrapWidth(text, &w));
6271 return w;
6272}
6273
6274inline int Text::GetWrapWidth() const
6275{
6276 return SDL::GetTextWrapWidth(m_resource);
6277}
6278
6299inline void SetTextWrapWhitespaceVisible(TextRef text, bool visible)
6300{
6301 CheckError(TTF_SetTextWrapWhitespaceVisible(text, visible));
6302}
6303
6304inline void Text::SetWrapWhitespaceVisible(bool visible)
6305{
6306 SDL::SetTextWrapWhitespaceVisible(m_resource, visible);
6307}
6308
6323{
6324 return TTF_TextWrapWhitespaceVisible(text);
6325}
6326
6328{
6329 return SDL::TextWrapWhitespaceVisible(m_resource);
6330}
6331
6350inline void SetTextString(TextRef text, std::string_view string)
6351{
6352 CheckError(TTF_SetTextString(text, string.data(), string.size()));
6353}
6354
6355inline void Text::SetString(std::string_view string)
6356{
6357 SDL::SetTextString(m_resource, string);
6358}
6359
6382inline void InsertTextString(TextRef text, int offset, std::string_view string)
6383{
6384 CheckError(TTF_InsertTextString(text, offset, string.data(), string.size()));
6385}
6386
6387inline void Text::InsertString(int offset, std::string_view string)
6388{
6389 SDL::InsertTextString(m_resource, offset, string);
6390}
6391
6410inline void AppendTextString(TextRef text, std::string_view string)
6411{
6412 CheckError(TTF_AppendTextString(text, string.data(), string.size()));
6413}
6414
6415inline void Text::AppendString(std::string_view string)
6416{
6417 SDL::AppendTextString(m_resource, string);
6418}
6419
6443inline void DeleteTextString(TextRef text, int offset, int length)
6444{
6445 CheckError(TTF_DeleteTextString(text, offset, length));
6446}
6447
6448inline void Text::DeleteString(int offset, int length)
6449{
6450 SDL::DeleteTextString(m_resource, offset, length);
6451}
6452
6470inline void GetTextSize(TextConstRef text, int* w, int* h)
6471{
6472 CheckError(TTF_GetTextSize(text, w, h));
6473}
6474
6491{
6492 Point p;
6493 GetTextSize(text, &p.x, &p.y);
6494 return p;
6495}
6496
6497inline void Text::GetSize(int* w, int* h) const
6498{
6499 SDL::GetTextSize(m_resource, w, h);
6500}
6501
6502inline Point Text::GetSize() const { return SDL::GetTextSize(m_resource); }
6503
6525 int offset,
6526 SubString* substring)
6527{
6528 CheckError(TTF_GetTextSubString(text, offset, substring));
6529}
6530
6531inline void Text::GetSubString(int offset, SubString* substring) const
6532{
6533 SDL::GetTextSubString(m_resource, offset, substring);
6534}
6535
6556 int line,
6557 SubString* substring)
6558{
6559 CheckError(TTF_GetTextSubStringForLine(text, line, substring));
6560}
6561
6562inline void Text::GetSubStringForLine(int line, SubString* substring) const
6563{
6564 SDL::GetTextSubStringForLine(m_resource, line, substring);
6565}
6566
6583 int offset,
6584 int length)
6585{
6586 int count = 0;
6587 auto data = TTF_GetTextSubStringsForRange(text, offset, length, &count);
6588 return OwnArray<SubString*>{data, size_t(count)};
6589}
6590
6592 int length) const
6593{
6594 return SDL::GetTextSubStringsForRange(m_resource, offset, length);
6595}
6596
6615 Point p,
6616 SubString* substring)
6617{
6618 CheckError(TTF_GetTextSubStringForPoint(text, p.x, p.y, substring));
6619}
6620
6621inline void Text::GetSubStringForPoint(Point p, SubString* substring) const
6622{
6623 SDL::GetTextSubStringForPoint(m_resource, p, substring);
6624}
6625
6644 const SubString& substring,
6645 SubString* previous)
6646{
6647 CheckError(TTF_GetPreviousTextSubString(text, &substring, previous));
6648}
6649
6650inline void Text::GetPreviousSubString(const SubString& substring,
6651 SubString* previous) const
6652{
6653 SDL::GetPreviousTextSubString(m_resource, substring, previous);
6654}
6655
6673 const SubString& substring,
6674 SubString* next)
6675{
6676 CheckError(TTF_GetNextTextSubString(text, &substring, next));
6677}
6678
6679inline void Text::GetNextSubString(const SubString& substring,
6680 SubString* next) const
6681{
6682 SDL::GetNextTextSubString(m_resource, substring, next);
6683}
6684
6700inline void UpdateText(TextRef text) { CheckError(TTF_UpdateText(text)); }
6701
6702inline void Text::Update() { SDL::UpdateText(m_resource); }
6703
6716inline void DestroyText(TextRaw text) { TTF_DestroyText(text); }
6717
6718inline void Text::Destroy() { DestroyText(release()); }
6719
6742inline void CloseFont(FontRaw font) { TTF_CloseFont(font); }
6743
6744inline void Font::Close() { CloseFont(release()); }
6745
6747
6748} // namespace SDL
6749
6750#endif // defined(SDL3PP_ENABLE_TTF) || defined(SDL3PP_DOC)
6751
6752#endif /* SDL3PP_TTF_H_ */
An exception that returns GetError()
Definition: SDL3pp_error.h:164
The internal structure containing font information.
Definition: SDL3pp_ttf.h:389
constexpr Font(Font &&other) noexcept
Move constructor.
Definition: SDL3pp_ttf.h:417
~Font()
Destructor.
Definition: SDL3pp_ttf.h:517
constexpr Font & operator=(const Font &other) noexcept=default
Assignment operator.
Point GetStringSize(std::string_view text) const
Calculate the dimensions of a rendered string of UTF-8 text.
Definition: SDL3pp_ttf.h:1356
constexpr Font(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_ttf.h:394
constexpr auto operator<=>(const Font &other) const noexcept=default
Comparison.
constexpr Font(const FontRaw resource) noexcept
Constructs from FontRef.
Definition: SDL3pp_ttf.h:406
constexpr FontRaw get() const noexcept
Retrieves underlying FontRaw.
Definition: SDL3pp_ttf.h:532
constexpr Font(const Font &other) noexcept=default
Copy constructor.
constexpr Font & operator=(Font &&other) noexcept
Assignment operator.
Definition: SDL3pp_ttf.h:520
constexpr FontRaw release() noexcept
Retrieves underlying FontRaw and clear this.
Definition: SDL3pp_ttf.h:535
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:1402
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:5253
constexpr SubStringIterator()
Default constructor.
Definition: SDL3pp_ttf.h:5266
constexpr SubStringIterator & operator--()
Decrement operator.
Definition: SDL3pp_ttf.h:5302
constexpr const SubString & operator*() const
Retrieve SubString.
Definition: SDL3pp_ttf.h:5275
constexpr const SubString * operator->() const
Retrieve SubString.
Definition: SDL3pp_ttf.h:5278
constexpr bool operator==(const SubStringIterator &other) const
Comparison.
Definition: SDL3pp_ttf.h:5281
constexpr SubStringIterator operator--(int)
Decrement operator.
Definition: SDL3pp_ttf.h:5309
constexpr SubStringIterator operator++(int)
Increment operator.
Definition: SDL3pp_ttf.h:5294
constexpr SubStringIterator & operator++()
Increment operator.
Definition: SDL3pp_ttf.h:5287
A collection of pixels used in software blitting.
Definition: SDL3pp_surface.h:191
A text engine used to create text objects.
Definition: SDL3pp_ttf.h:3965
constexpr TextEngineRaw release() noexcept
Retrieves underlying TextEngineRaw and clear this.
Definition: SDL3pp_ttf.h:4017
virtual void Destroy()=0
frees up textEngine. Pure virtual
constexpr TextEngineRaw get() const noexcept
Retrieves underlying TextEngineRaw.
Definition: SDL3pp_ttf.h:4014
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 TextEngineRef.
Definition: SDL3pp_ttf.h:3982
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:4002
constexpr TextEngine(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_ttf.h:3970
constexpr TextEngine(TextEngine &&other) noexcept
Move constructor.
Definition: SDL3pp_ttf.h:3993
Text created with Text.Text()
Definition: SDL3pp_ttf.h:4293
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:5175
int GetNumLines() const
The number of lines in the text, 0 if it's empty.
Definition: SDL3pp_ttf.h:5178
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:4377
constexpr TextRaw get() const noexcept
Retrieves underlying TextRaw.
Definition: SDL3pp_ttf.h:4374
constexpr TextRaw operator->() noexcept
member access to underlying TextRaw.
Definition: SDL3pp_ttf.h:4353
SubStringIterator begin() const
Get iterator to first substring.
constexpr const TextRaw operator->() const noexcept
member access to underlying TextRaw.
Definition: SDL3pp_ttf.h:4350
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:4359
OwnArray< SubString * > GetSubStrings() const
Get all substrings of a text object.
Definition: SDL3pp_ttf.h:5061
constexpr Text & operator=(Text &&other) noexcept
Assignment operator.
Definition: SDL3pp_ttf.h:4362
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:4321
constexpr Text(const TextRaw resource) noexcept
Constructs from TextRef.
Definition: SDL3pp_ttf.h:4310
constexpr Text & operator=(const Text &other) noexcept=default
Assignment operator.
constexpr Text(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_ttf.h:4298
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:197
SDL_Color ColorRaw
Alias to raw representation for Color.
Definition: SDL3pp_pixels.h:84
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:6220
void GetStringSize(FontRef font, std::string_view text, int *w, int *h)
Calculate the dimensions of a rendered string of UTF-8 text.
Definition: SDL3pp_ttf.h:3266
FontRef GetFont() const
Get the font used by a text object.
Definition: SDL3pp_ttf.h:5867
constexpr FontStyleFlags STYLE_NORMAL
No special style.
Definition: SDL3pp_ttf.h:271
void SetTextPosition(TextRef text, const PointRaw &p)
Set the position of a text object.
Definition: SDL3pp_ttf.h:6161
Uint32 GetGlyphScript(Uint32 ch)
Get the script used by a 32-bit codepoint.
Definition: SDL3pp_ttf.h:3059
constexpr SubStringFlags SUBSTRING_LINE_END
This substring contains the end of line line_index
Definition: SDL3pp_ttf.h:3925
constexpr HintingFlags HINTING_LIGHT
Light hinting applies subtle adjustments to improve rendering.
Definition: SDL3pp_ttf.h:307
FontStyleFlags GetFontStyle(FontRef font)
Query a font's current style.
Definition: SDL3pp_ttf.h:2395
bool GetFontKerning(FontRef font)
Query whether or not kerning is enabled for a font.
Definition: SDL3pp_ttf.h:2810
constexpr HorizontalAlignment HORIZONTAL_ALIGN_CENTER
CENTER.
Definition: SDL3pp_ttf.h:334
void GetPreviousTextSubString(TextConstRef text, const SubString &substring, SubString *previous)
Get the previous substring in a text object.
Definition: SDL3pp_ttf.h:6643
PropertiesRef GetTextProperties(TextConstRef text)
Get the properties associated with a text object.
Definition: SDL3pp_ttf.h:5757
void Destroy() final
Destroy a text engine created for drawing text on SDL surfaces.
Definition: SDL3pp_ttf.h:5393
void SetTextScript(TextRef text, Uint32 script)
Set the script to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5934
int GetFontDescent(FontRef font)
Query the offset from the baseline to the bottom of a font.
Definition: SDL3pp_ttf.h:2720
constexpr HorizontalAlignment HORIZONTAL_ALIGN_RIGHT
RIGHT.
Definition: SDL3pp_ttf.h:337
void Destroy() final
Destroy a text engine created for drawing text on an SDL renderer.
Definition: SDL3pp_ttf.h:5523
int GetFontWeight(FontRef font)
Query a font's weight, in terms of the lightness/heaviness of the strokes.
Definition: SDL3pp_ttf.h:2593
void SetTextWrapWhitespaceVisible(TextRef text, bool visible)
Set whether whitespace should be visible when wrapping a text object.
Definition: SDL3pp_ttf.h:6299
TTF_GPUAtlasDrawSequence GPUAtlasDrawSequence
Draw sequence returned by Text.GetGPUDrawData.
Definition: SDL3pp_ttf.h:4255
void SetFontLanguage(FontRef font, StringParam language_bcp47)
Set language to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:3086
void GetPreviousSubString(const SubString &substring, SubString *previous) const
Get the previous substring in a text object.
Definition: SDL3pp_ttf.h:6650
constexpr GPUTextEngineWinding GPU_TEXTENGINE_WINDING_COUNTER_CLOCKWISE
COUNTER_CLOCKWISE.
Definition: SDL3pp_ttf.h:3943
Surface RenderText_Solid_Wrapped(FontRef 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:3438
void MeasureString(FontRef 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:3340
bool IsFixedWidth() const
Query whether a font is fixed-width.
Definition: SDL3pp_ttf.h:2835
void SetFontStyle(FontRef font, FontStyleFlags style)
Set a font's current style.
Definition: SDL3pp_ttf.h:2365
Surface RenderText_LCD_Wrapped(FontRef 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:3844
GPUTextEngine CreateGPUTextEngineWithProperties(PropertiesRef props)
Create a text engine for drawing text with the SDL GPU API, with the specified properties.
Definition: SDL3pp_ttf.h:5583
void GetTextColorFloat(TextConstRef text, float *r, float *g, float *b, float *a)
Get the color of a text object.
Definition: SDL3pp_ttf.h:6101
TTF_Font * FontRaw
Alias to raw representation for Font.
Definition: SDL3pp_ttf.h:31
constexpr SubStringFlags SUBSTRING_TEXT_START
This substring contains the beginning of the text.
Definition: SDL3pp_ttf.h:3917
const char * GetStyleName() const
Query a font's style name.
Definition: SDL3pp_ttf.h:2905
void SetTextDirection(TextRef text, Direction direction)
Set the direction to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5884
static Uint32 GetGlyphScript(Uint32 ch)
Get the script used by a 32-bit codepoint.
Definition: SDL3pp_ttf.h:3064
void ClearFallbackFonts(FontRef font)
Remove all fallback fonts.
Definition: SDL3pp_ttf.h:2236
void SetFontScript(FontRef font, Uint32 script)
Set the script to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:3016
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:3804
Uint32 GetFontGeneration(FontRef font)
Get the font generation.
Definition: SDL3pp_ttf.h:2153
void AppendTextString(TextRef text, std::string_view string)
Append UTF-8 text to a text object.
Definition: SDL3pp_ttf.h:6410
void SetSizeDPI(float ptsize, int hdpi, int vdpi)
Set font size dynamically with target resolutions, in dots per inch.
Definition: SDL3pp_ttf.h:2292
constexpr int FONT_WEIGHT_BLACK
Black (900) named font weight value.
Definition: SDL3pp_ttf.h:2621
void SetLanguage(StringParam language_bcp47)
Set language to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:3091
void SetFontWrapAlignment(FontRef font, HorizontalAlignment align)
Set a font's current wrap alignment option.
Definition: SDL3pp_ttf.h:2644
TextEngineRef GetTextEngine(TextConstRef text)
Get the text engine used by a text object.
Definition: SDL3pp_ttf.h:5807
void DestroyRendererTextEngine(TextEngineRaw engine)
Destroy a text engine created for drawing text on an SDL renderer.
Definition: SDL3pp_ttf.h:5518
void DrawRenderer(FPoint p) const
Draw text to an SDL renderer.
Definition: SDL3pp_ttf.h:5497
constexpr SubStringFlags SUBSTRING_LINE_START
This substring contains the beginning of line line_index
Definition: SDL3pp_ttf.h:3922
void DestroyText(TextRaw text)
Destroy a text object created by a text engine.
Definition: SDL3pp_ttf.h:6716
constexpr Direction DIRECTION_LTR
Left to Right.
Definition: SDL3pp_ttf.h:355
constexpr ImageType IMAGE_COLOR
The color channels have image data.
Definition: SDL3pp_ttf.h:375
Surface GetGlyphImage(FontRef font, Uint32 ch, ImageType *image_type)
Get the pixel image for a UNICODE codepoint.
Definition: SDL3pp_ttf.h:3133
Uint32 GetTextScript(TextConstRef text)
Get the script used for text shaping a text object.
Definition: SDL3pp_ttf.h:5961
void AddFallback(FontRef fallback)
Add a fallback font.
Definition: SDL3pp_ttf.h:2190
Uint32 StringToTag(StringParam string)
Convert from a 4 character string to a 32-bit tag.
Definition: SDL3pp_ttf.h:2972
Direction GetTextDirection(TextConstRef text)
Get the direction to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5907
Surface RenderText_LCD(FontRef 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:3796
HintingFlags GetHinting() const
Query a font's current FreeType hinter setting.
Definition: SDL3pp_ttf.h:2529
Surface GetGlyphImage(Uint32 ch, ImageType *image_type) const
Get the pixel image for a UNICODE codepoint.
Definition: SDL3pp_ttf.h:3138
void GetTextSubStringForPoint(TextConstRef text, Point p, SubString *substring)
Get the portion of a text string that is closest to a point.
Definition: SDL3pp_ttf.h:6614
Uint32 SubStringFlags
Flags for SubString.
Definition: SDL3pp_ttf.h:3911
const char * GetFamilyName() const
Query a font's family name.
Definition: SDL3pp_ttf.h:2879
void ClearFallbacks()
Remove all fallback fonts.
Definition: SDL3pp_ttf.h:2238
void SetString(std::string_view string)
Set the UTF-8 text used by a text object.
Definition: SDL3pp_ttf.h:6355
void UpdateText(TextRef text)
Update the layout of a text object.
Definition: SDL3pp_ttf.h:6700
Direction GetDirection() const
Get the direction to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5912
void DrawSurfaceText(TextConstRef text, Point p, SurfaceRef surface)
Draw text to an SDL surface.
Definition: SDL3pp_ttf.h:5362
TTF_HintingFlags HintingFlags
Hinting flags for TTF (TrueType Fonts)
Definition: SDL3pp_ttf.h:295
int GetWrapWidth() const
Get whether wrapping is enabled on a text object.
Definition: SDL3pp_ttf.h:6274
Point GetSize() const
Get the size of a text object.
Definition: SDL3pp_ttf.h:6502
void SetStyle(FontStyleFlags style)
Set a font's current style.
Definition: SDL3pp_ttf.h:2370
bool SetTextFont(TextRef text, FontRef font)
Set the font used by a text object.
Definition: SDL3pp_ttf.h:5838
SurfaceTextEngine()
Create a text engine for drawing text on SDL surfaces.
Definition: SDL3pp_ttf.h:5337
Surface GetGlyphImageForIndex(Uint32 glyph_index, ImageType *image_type) const
Get the pixel image for a character index.
Definition: SDL3pp_ttf.h:3169
void SetWrapWhitespaceVisible(bool visible)
Set whether whitespace should be visible when wrapping a text object.
Definition: SDL3pp_ttf.h:6304
void SetDirection(Direction direction)
Set the direction to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5889
constexpr ImageType IMAGE_INVALID
INVALID.
Definition: SDL3pp_ttf.h:370
Text CreateText(TextEngineRef engine, FontRef font, std::string_view text)
Create a text object from UTF-8 text and a text engine.
Definition: SDL3pp_ttf.h:5728
FontStyleFlags GetStyle() const
Query a font's current style.
Definition: SDL3pp_ttf.h:2400
TextEngineRef GetEngine() const
Get the text engine used by a text object.
Definition: SDL3pp_ttf.h:5812
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:3447
float GetFontSize(FontRef font)
Get the size of a font.
Definition: SDL3pp_ttf.h:2312
Surface RenderText_Shaded(FontRef 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:3525
void SetTextWrapWidth(TextRef text, int wrap_width)
Set whether wrapping is enabled on a text object.
Definition: SDL3pp_ttf.h:6242
void RemoveFallbackFont(FontRef font, FontRef fallback)
Remove a fallback font.
Definition: SDL3pp_ttf.h:2211
void GetHarfBuzzVersion(int *major, int *minor, int *patch)
Query the version of the HarfBuzz library in use.
Definition: SDL3pp_ttf.h:252
Font OpenFontWithProperties(PropertiesRef props)
Create a font with the specified properties.
Definition: SDL3pp_ttf.h:2041
const char * GetFontStyleName(FontRef font)
Query a font's style name.
Definition: SDL3pp_ttf.h:2900
void SetOutline(int outline)
Set a font's current outline.
Definition: SDL3pp_ttf.h:2431
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:3719
constexpr HintingFlags HINTING_INVALID
INVALID.
Definition: SDL3pp_ttf.h:299
int GetHeight() const
Query the total height of a font.
Definition: SDL3pp_ttf.h:2690
void AddFallbackFont(FontRef font, FontRef fallback)
Add a fallback font.
Definition: SDL3pp_ttf.h:2185
bool GetKerning() const
Query whether or not kerning is enabled for a font.
Definition: SDL3pp_ttf.h:2812
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:3401
bool FontHasGlyph(FontRef font, Uint32 ch)
Check whether a glyph is provided by the font for a UNICODE codepoint.
Definition: SDL3pp_ttf.h:3108
GPUAtlasDrawSequence * GetGPUTextDrawData(TextConstRef text)
Get the geometry data needed for drawing the text.
Definition: SDL3pp_ttf.h:5627
void DestroySurfaceTextEngine(TextEngineRaw engine)
Destroy a text engine created for drawing text on SDL surfaces.
Definition: SDL3pp_ttf.h:5388
int GetOutline() const
Query a font's current outline.
Definition: SDL3pp_ttf.h:2450
constexpr int FONT_WEIGHT_EXTRA_LIGHT
ExtraLight (200) named font weight value.
Definition: SDL3pp_ttf.h:2600
Surface GetGlyphImageForIndex(FontRef font, Uint32 glyph_index, ImageType *image_type)
Get the pixel image for a character index.
Definition: SDL3pp_ttf.h:3161
Uint32 FontStyleFlags
Font style flags for Font.
Definition: SDL3pp_ttf.h:269
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:5680
bool FontIsFixedWidth(FontRef font)
Query whether a font is fixed-width.
Definition: SDL3pp_ttf.h:2830
void RemoveFallback(FontRef fallback)
Remove a fallback font.
Definition: SDL3pp_ttf.h:2216
bool TextWrapWhitespaceVisible(TextConstRef text)
Return whether whitespace is shown when wrapping a text object.
Definition: SDL3pp_ttf.h:6322
void SetColor(Color c)
Set the color of a text object.
Definition: SDL3pp_ttf.h:5990
bool IsWrapWhitespaceVisible() const
Return whether whitespace is shown when wrapping a text object.
Definition: SDL3pp_ttf.h:6327
int GetFontAscent(FontRef font)
Query the offset from the baseline to the top of a font.
Definition: SDL3pp_ttf.h:2704
float GetSize() const
Get the size of a font.
Definition: SDL3pp_ttf.h:2314
int GetGlyphKerning(Uint32 previous_ch, Uint32 ch) const
Query the kerning size between the glyphs of two UNICODE codepoints.
Definition: SDL3pp_ttf.h:3244
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:3673
void GetGlyphMetrics(FontRef 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:3203
void SetTextColor(TextRef text, Color c)
Set the color of a text object.
Definition: SDL3pp_ttf.h:5985
void SetFontLineSkip(FontRef font, int lineskip)
Set the spacing between lines of text for a font.
Definition: SDL3pp_ttf.h:2739
Surface RenderText_Shaded_Wrapped(FontRef 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:3574
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:3758
constexpr Direction DIRECTION_BTT
Bottom to Top.
Definition: SDL3pp_ttf.h:361
constexpr HintingFlags HINTING_MONO
Monochrome hinting adjusts the font for better rendering at lower resolutions.
Definition: SDL3pp_ttf.h:313
void SetSDF(bool enabled)
Enable Signed Distance Field rendering for a font.
Definition: SDL3pp_ttf.h:2562
FontRef GetTextFont(TextConstRef text)
Get the font used by a text object.
Definition: SDL3pp_ttf.h:5862
constexpr int FONT_WEIGHT_EXTRA_BOLD
ExtraBold (800) named font weight value.
Definition: SDL3pp_ttf.h:2618
void SetScript(Uint32 script)
Set the script to be used for text shaping a text object.
Definition: SDL3pp_ttf.h:5939
void GetFontDPI(FontRef font, int *hdpi, int *vdpi)
Get font target resolutions, in dots per inch.
Definition: SDL3pp_ttf.h:2331
void SetWrapWidth(int wrap_width)
Set whether wrapping is enabled on a text object.
Definition: SDL3pp_ttf.h:6247
constexpr FontStyleFlags STYLE_ITALIC
Italic style.
Definition: SDL3pp_ttf.h:275
Direction GetFontDirection(FontRef font)
Get the direction to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:2950
void SetLineSkip(int lineskip)
Set the spacing between lines of text for a font.
Definition: SDL3pp_ttf.h:2744
bool GetSDF() const
Query whether Signed Distance Field rendering is enabled for a font.
Definition: SDL3pp_ttf.h:2578
HorizontalAlignment GetFontWrapAlignment(FontRef font)
Query a font's current wrap alignment option.
Definition: SDL3pp_ttf.h:2666
void SetPosition(const PointRaw &p)
Set the position of a text object.
Definition: SDL3pp_ttf.h:6166
void SetKerning(bool enabled)
Set if kerning is enabled for a font.
Definition: SDL3pp_ttf.h:2793
bool IsScalable() const
Query whether a font is scalable or not.
Definition: SDL3pp_ttf.h:2856
GPUTextEngine CreateGPUTextEngine(GPUDeviceRef device)
Create a text engine for drawing text with the SDL GPU API.
Definition: SDL3pp_ttf.h:5544
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:3854
void GetFreeTypeVersion(int *major, int *minor, int *patch)
Query the version of the FreeType library in use.
Definition: SDL3pp_ttf.h:234
void TagToString(Uint32 tag, char *string, size_t size)
Convert from a 32-bit tag to a 4 character string.
Definition: SDL3pp_ttf.h:2992
bool GetFontSDF(FontRef font)
Query whether Signed Distance Field rendering is enabled for a font.
Definition: SDL3pp_ttf.h:2576
void GetTextSubStringForLine(TextConstRef text, int line, SubString *substring)
Get the substring of a text object that contains the given line.
Definition: SDL3pp_ttf.h:6555
TTF_GPUTextEngineWinding GPUTextEngineWinding
The winding order of the vertices returned by Text.GetGPUDrawData.
Definition: SDL3pp_ttf.h:3935
constexpr FontStyleFlags STYLE_BOLD
Bold style.
Definition: SDL3pp_ttf.h:273
constexpr FontStyleFlags STYLE_STRIKETHROUGH
Strikethrough text.
Definition: SDL3pp_ttf.h:280
constexpr int FONT_WEIGHT_THIN
Thin (100) named font weight value.
Definition: SDL3pp_ttf.h:2597
void GetNextSubString(const SubString &substring, SubString *next) const
Get the next substring in a text object.
Definition: SDL3pp_ttf.h:6679
void SetColorFloat(FColor c)
Set the color of a text object.
Definition: SDL3pp_ttf.h:6014
void SetTextEngine(TextRef text, TextEngineRef engine)
Set the text engine used by a text object.
Definition: SDL3pp_ttf.h:5783
constexpr Direction DIRECTION_RTL
Right to Left.
Definition: SDL3pp_ttf.h:357
const char * GetFontFamilyName(FontRef font)
Query a font's family name.
Definition: SDL3pp_ttf.h:2874
TTF_ImageType ImageType
The type of data in a glyph image.
Definition: SDL3pp_ttf.h:368
Direction GetDirection() const
Get the direction to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:2955
HintingFlags GetFontHinting(FontRef font)
Query a font's current FreeType hinter setting.
Definition: SDL3pp_ttf.h:2524
GPUTextEngineWinding GetGPUWinding() const
Get the winding order of the vertices returned by Text.GetGPUDrawData for a particular GPU text engin...
Definition: SDL3pp_ttf.h:5706
Uint32 GetGeneration() const
Get the font generation.
Definition: SDL3pp_ttf.h:2158
int GetDescent() const
Query the offset from the baseline to the bottom of a font.
Definition: SDL3pp_ttf.h:2722
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:3486
TTF_TextEngine * TextEngineRaw
Alias to raw representation for TextEngine.
Definition: SDL3pp_ttf.h:40
Font CopyFont(FontRef existing_font)
Create a copy of an existing font.
Definition: SDL3pp_ttf.h:2101
void Update()
Update the layout of a text object.
Definition: SDL3pp_ttf.h:6702
constexpr HintingFlags HINTING_NORMAL
Normal hinting applies standard grid-fitting.
Definition: SDL3pp_ttf.h:303
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:3354
void SetEngine(TextEngineRef engine)
Set the text engine used by a text object.
Definition: SDL3pp_ttf.h:5788
constexpr HorizontalAlignment HORIZONTAL_ALIGN_INVALID
INVALID.
Definition: SDL3pp_ttf.h:328
void SetFontSize(FontRef font, float ptsize)
Set a font's size dynamically.
Definition: SDL3pp_ttf.h:2257
RendererTextEngine CreateRendererTextEngine(RendererRef renderer)
Create a text engine for drawing text on an SDL renderer.
Definition: SDL3pp_ttf.h:5414
bool HasGlyph(Uint32 ch) const
Check whether a glyph is provided by the font for a UNICODE codepoint.
Definition: SDL3pp_ttf.h:3113
constexpr Direction DIRECTION_INVALID
INVALID.
Definition: SDL3pp_ttf.h:353
constexpr HintingFlags HINTING_NONE
No hinting, the font is rendered without any grid-fitting.
Definition: SDL3pp_ttf.h:316
TTF_SubString SubString
The representation of a substring within text.
Definition: SDL3pp_ttf.h:4269
Surface RenderText_Blended(FontRef font, std::string_view text, Color fg)
Render UTF-8 text at high quality to a new ARGB surface.
Definition: SDL3pp_ttf.h:3668
void SetGPUTextEngineWinding(TextEngineRef engine, GPUTextEngineWinding winding)
Sets the winding order of the vertices returned by Text.GetGPUDrawData for a particular GPU text engi...
Definition: SDL3pp_ttf.h:5674
constexpr int FONT_WEIGHT_BOLD
Bold (700) named font weight value.
Definition: SDL3pp_ttf.h:2615
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:3629
constexpr ImageType IMAGE_ALPHA
The color channels are white.
Definition: SDL3pp_ttf.h:372
void SetWrapAlignment(HorizontalAlignment align)
Set a font's current wrap alignment option.
Definition: SDL3pp_ttf.h:2649
void SetFontOutline(FontRef font, int outline)
Set a font's current outline.
Definition: SDL3pp_ttf.h:2426
void DeleteTextString(TextRef text, int offset, int length)
Delete UTF-8 text from a text object.
Definition: SDL3pp_ttf.h:6443
constexpr int FONT_WEIGHT_MEDIUM
Medium (500) named font weight value.
Definition: SDL3pp_ttf.h:2609
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:3584
Surface RenderGlyph_Solid(FontRef font, Uint32 ch, ColorRaw fg)
Render a single 32-bit glyph at fast quality to a new 8-bit surface.
Definition: SDL3pp_ttf.h:3481
void DrawSurface(Point p, SurfaceRef surface) const
Draw text to an SDL surface.
Definition: SDL3pp_ttf.h:5367
int GetWeight() const
Query a font's weight, in terms of the lightness/heaviness of the strokes.
Definition: SDL3pp_ttf.h:2595
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:3533
int GetGlyphKerning(FontRef font, Uint32 previous_ch, Uint32 ch)
Query the kerning size between the glyphs of two UNICODE codepoints.
Definition: SDL3pp_ttf.h:3238
RendererTextEngine CreateRendererTextEngineWithProperties(PropertiesRef props)
Create a text engine for drawing text on an SDL renderer, with the specified properties.
Definition: SDL3pp_ttf.h:5453
constexpr GPUTextEngineWinding GPU_TEXTENGINE_WINDING_INVALID
INVALID.
Definition: SDL3pp_ttf.h:3937
void SetDirection(Direction direction)
Set the direction to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:2932
void SetScript(Uint32 script)
Set the script to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:3021
void SetFontKerning(FontRef font, bool enabled)
Set if kerning is enabled for a font.
Definition: SDL3pp_ttf.h:2788
int GetLineSkip() const
Query the spacing between lines of text for a font.
Definition: SDL3pp_ttf.h:2763
GPUTextEngine(GPUDeviceRef device)
Create a text engine for drawing text with the SDL GPU API.
Definition: SDL3pp_ttf.h:5549
void Close()
Dispose of a previously-created font.
Definition: SDL3pp_ttf.h:6744
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:3899
void InsertString(int offset, std::string_view string)
Insert UTF-8 text into a text object.
Definition: SDL3pp_ttf.h:6387
HorizontalAlignment GetWrapAlignment() const
Query a font's current wrap alignment option.
Definition: SDL3pp_ttf.h:2671
void SetTextColorFloat(TextRef text, FColor c)
Set the color of a text object.
Definition: SDL3pp_ttf.h:6009
bool SetFont(FontRef font)
Set the font used by a text object.
Definition: SDL3pp_ttf.h:5843
void DestroyGPUTextEngine(TextEngineRaw engine)
Destroy a text engine created for drawing text with the SDL GPU API.
Definition: SDL3pp_ttf.h:5652
OwnArray< SubString * > GetTextSubStringsForRange(TextConstRef text, int offset, int length)
Get the substrings of a text object that contain a range of text.
Definition: SDL3pp_ttf.h:6582
void GetNextTextSubString(TextConstRef text, const SubString &substring, SubString *next)
Get the next substring in a text object.
Definition: SDL3pp_ttf.h:6672
void SetFontHinting(FontRef font, HintingFlags hinting)
Set a font's current hinter setting.
Definition: SDL3pp_ttf.h:2476
TTF_TextData TextData
Internal data for Text.
Definition: SDL3pp_ttf.h:4279
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:6591
Surface RenderText_Blended_Wrapped(FontRef 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:3710
void GetSubString(int offset, SubString *substring) const
Get the substring of a text object that surrounds a text offset.
Definition: SDL3pp_ttf.h:6531
constexpr FontStyleFlags STYLE_UNDERLINE
Underlined text.
Definition: SDL3pp_ttf.h:277
constexpr int FONT_WEIGHT_EXTRA_BLACK
ExtraBlack (950) named font weight value.
Definition: SDL3pp_ttf.h:2624
void GetTextPosition(TextConstRef text, int *x, int *y)
Get the position of a text object.
Definition: SDL3pp_ttf.h:6188
void AppendString(std::string_view string)
Append UTF-8 text to a text object.
Definition: SDL3pp_ttf.h:6415
constexpr SubStringFlags SUBSTRING_TEXT_END
This substring contains the end of the text.
Definition: SDL3pp_ttf.h:3927
Font Copy() const
Create a copy of an existing font.
Definition: SDL3pp_ttf.h:2106
void GetTextSize(TextConstRef text, int *w, int *h)
Get the size of a text object.
Definition: SDL3pp_ttf.h:6470
void GetTextSubString(TextConstRef text, int offset, SubString *substring)
Get the substring of a text object that surrounds a text offset.
Definition: SDL3pp_ttf.h:6524
constexpr SubStringFlags SUBSTRING_DIRECTION_MASK
The mask for the flow direction for this substring.
Definition: SDL3pp_ttf.h:3913
void GetTextColor(TextConstRef text, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Get the color of a text object.
Definition: SDL3pp_ttf.h:6041
int GetTextWrapWidth(TextConstRef text)
Get whether wrapping is enabled on a text object.
Definition: SDL3pp_ttf.h:6267
TTF_HorizontalAlignment HorizontalAlignment
The horizontal alignment used when rendering wrapped text.
Definition: SDL3pp_ttf.h:326
PropertiesRef GetProperties() const
Get the properties associated with a text object.
Definition: SDL3pp_ttf.h:5762
constexpr Direction DIRECTION_TTB
Top to Bottom.
Definition: SDL3pp_ttf.h:359
int GetNumFaces() const
Query the number of faces of a font.
Definition: SDL3pp_ttf.h:2498
int GetFontHeight(FontRef font)
Query the total height of a font.
Definition: SDL3pp_ttf.h:2688
Text CreateText(FontRef font, std::string_view text)
Create a text object from UTF-8 text and a text engine.
Definition: SDL3pp_ttf.h:5735
Surface RenderText_Solid(FontRef font, std::string_view text, Color fg)
Render UTF-8 text at fast quality to a new 8-bit surface.
Definition: SDL3pp_ttf.h:3396
Color GetColor() const
Get the color of a text object.
Definition: SDL3pp_ttf.h:6077
void SetSize(float ptsize)
Set a font's size dynamically.
Definition: SDL3pp_ttf.h:2262
constexpr HintingFlags HINTING_LIGHT_SUBPIXEL
Light hinting with subpixel rendering for more precise font edges.
Definition: SDL3pp_ttf.h:319
void DeleteString(int offset, int length)
Delete UTF-8 text from a text object.
Definition: SDL3pp_ttf.h:6448
SurfaceTextEngine CreateSurfaceTextEngine()
Create a text engine for drawing text on SDL surfaces.
Definition: SDL3pp_ttf.h:5332
void GetDPI(int *hdpi, int *vdpi) const
Get font target resolutions, in dots per inch.
Definition: SDL3pp_ttf.h:2336
Font OpenFont(StringParam file, float ptsize)
Create a font from a file, using a specified point size.
Definition: SDL3pp_ttf.h:1949
void Destroy()
Destroy a text object created by a text engine.
Definition: SDL3pp_ttf.h:6718
Uint32 GetFontScript(FontRef font)
Get the script used for text shaping a font.
Definition: SDL3pp_ttf.h:3041
RendererTextEngine(RendererRef renderer)
Create a text engine for drawing text on an SDL renderer.
Definition: SDL3pp_ttf.h:5419
void SetFontDirection(FontRef font, Direction direction)
Set the direction to be used for text shaping by a font.
Definition: SDL3pp_ttf.h:2927
void SetHinting(HintingFlags hinting)
Set a font's current hinter setting.
Definition: SDL3pp_ttf.h:2481
GPUAtlasDrawSequence * GetGPUDrawData() const
Get the geometry data needed for drawing the text.
Definition: SDL3pp_ttf.h:5632
TTF_Text * TextRaw
Alias to raw representation for Text.
Definition: SDL3pp_ttf.h:73
void SetFontSizeDPI(FontRef font, float ptsize, int hdpi, int vdpi)
Set font size dynamically with target resolutions, in dots per inch.
Definition: SDL3pp_ttf.h:2287
FColor GetColorFloat() const
Get the color of a text object.
Definition: SDL3pp_ttf.h:6137
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:3214
Uint32 GetScript() const
Get the script used for text shaping a font.
Definition: SDL3pp_ttf.h:3043
void InsertTextString(TextRef text, int offset, std::string_view string)
Insert UTF-8 text into a text object.
Definition: SDL3pp_ttf.h:6382
constexpr HorizontalAlignment HORIZONTAL_ALIGN_LEFT
LEFT.
Definition: SDL3pp_ttf.h:331
bool FontIsScalable(FontRef font)
Query whether a font is scalable or not.
Definition: SDL3pp_ttf.h:2854
constexpr int FONT_WEIGHT_SEMI_BOLD
SemiBold (600) named font weight value.
Definition: SDL3pp_ttf.h:2612
Surface RenderGlyph_LCD(FontRef 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:3891
void CloseFont(FontRaw font)
Dispose of a previously-created font.
Definition: SDL3pp_ttf.h:6742
Surface RenderGlyph_Blended(FontRef font, Uint32 ch, ColorRaw fg)
Render a single UNICODE codepoint at high quality to a new ARGB surface.
Definition: SDL3pp_ttf.h:3753
int GetAscent() const
Query the offset from the baseline to the top of a font.
Definition: SDL3pp_ttf.h:2706
PropertiesRef GetProperties()
Get the properties associated with a font.
Definition: SDL3pp_ttf.h:2133
Uint32 GetScript() const
Get the script used for text shaping a text object.
Definition: SDL3pp_ttf.h:5966
void DrawRendererText(TextConstRef text, FPoint p)
Draw text to an SDL renderer.
Definition: SDL3pp_ttf.h:5492
int GetFontLineSkip(FontRef font)
Query the spacing between lines of text for a font.
Definition: SDL3pp_ttf.h:2761
int GetFontOutline(FontRef font)
Query a font's current outline.
Definition: SDL3pp_ttf.h:2448
constexpr int FONT_WEIGHT_NORMAL
Normal (400) named font weight value.
Definition: SDL3pp_ttf.h:2606
void GetStringSizeWrapped(FontRef 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:3299
int GetNumFontFaces(FontRef font)
Query the number of faces of a font.
Definition: SDL3pp_ttf.h:2496
void SetFontSDF(FontRef font, bool enabled)
Enable Signed Distance Field rendering for a font.
Definition: SDL3pp_ttf.h:2557
TTF_Direction Direction
Direction flags.
Definition: SDL3pp_ttf.h:351
void SetTextString(TextRef text, std::string_view string)
Set the UTF-8 text used by a text object.
Definition: SDL3pp_ttf.h:6350
PropertiesRef GetFontProperties(FontRef font)
Get the properties associated with a font.
Definition: SDL3pp_ttf.h:2128
constexpr ImageType IMAGE_SDF
The alpha channel has signed distance field information.
Definition: SDL3pp_ttf.h:379
constexpr int FONT_WEIGHT_LIGHT
Light (300) named font weight value.
Definition: SDL3pp_ttf.h:2603
void Destroy() final
Destroy a text engine created for drawing text with the SDL GPU API.
Definition: SDL3pp_ttf.h:5657
constexpr GPUTextEngineWinding GPU_TEXTENGINE_WINDING_CLOCKWISE
CLOCKWISE.
Definition: SDL3pp_ttf.h:3940
GPUTextEngineWinding GetGPUTextEngineWinding(TextEngineRef engine)
Get the winding order of the vertices returned by Text.GetGPUDrawData for a particular GPU text engin...
Definition: SDL3pp_ttf.h:5701
Surface RenderGlyph_Shaded(FontRef 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:3621
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:280
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:228
Main include header for the SDL3pp library.
A structure that represents a color as RGBA components.
Definition: SDL3pp_pixels.h:2166
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition: SDL3pp_pixels.h:2339
The structure that defines a point (using floating point values).
Definition: SDL3pp_rect.h:512
Reference for Font.
Definition: SDL3pp_ttf.h:1868
constexpr FontRef & operator=(const FontRef &other) noexcept=default
Assignment operator.
constexpr FontRef(const Font &resource) noexcept
Constructs from Font.
Definition: SDL3pp_ttf.h:1890
constexpr FontRef(Font &&resource) noexcept
Constructs from Font.
Definition: SDL3pp_ttf.h:1902
constexpr FontRef(FontRef &&other) noexcept
Move constructor.
Definition: SDL3pp_ttf.h:1914
~FontRef()
Destructor.
Definition: SDL3pp_ttf.h:1920
constexpr FontRef(const FontRef &other) noexcept
Copy constructor.
Definition: SDL3pp_ttf.h:1908
FontRef(FontRaw resource) noexcept
Constructs from raw Font.
Definition: SDL3pp_ttf.h:1878
Reference for GPUDevice.
Definition: SDL3pp_gpu.h:4126
A GPU based text engine.
Definition: SDL3pp_ttf.h:4154
Reference for IOStream.
Definition: SDL3pp_iostream.h:1631
The structure that defines a point (using integers).
Definition: SDL3pp_rect.h:83
Reference for Properties.
Definition: SDL3pp_properties.h:691
Reference for Renderer.
Definition: SDL3pp_render.h:2326
A renderer based text engine.
Definition: SDL3pp_ttf.h:4089
Reference for Surface.
Definition: SDL3pp_surface.h:1959
A surface based text engine.
Definition: SDL3pp_ttf.h:4053
Safely wrap Text for non owning const parameters.
Definition: SDL3pp_ttf.h:80
constexpr auto operator->()
member access to underlying TextRaw.
Definition: SDL3pp_ttf.h:105
constexpr TextConstRef(const TextRaw value)
Constructs from const TextRaw.
Definition: SDL3pp_ttf.h:84
const TextRaw value
parameter's const TextRaw
Definition: SDL3pp_ttf.h:81
constexpr auto operator<=>(const TextConstRef &other) const =default
Comparison.
constexpr TextConstRef(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_ttf.h:90
Safely wrap TextEngine for non owning parameters.
Definition: SDL3pp_ttf.h:44
constexpr TextEngineRef(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_ttf.h:54
TextEngineRaw value
parameter's TextEngineRaw
Definition: SDL3pp_ttf.h:45
constexpr TextEngineRef(TextEngineRaw value)
Constructs from TextEngineRaw.
Definition: SDL3pp_ttf.h:48
constexpr auto operator<=>(const TextEngineRef &other) const =default
Comparison.
Reference for Text.
Definition: SDL3pp_ttf.h:5187
TextRef(TextRaw resource) noexcept
Constructs from raw Text.
Definition: SDL3pp_ttf.h:5197
constexpr TextRef(Text &&resource) noexcept
Constructs from Text.
Definition: SDL3pp_ttf.h:5221
constexpr TextRef(TextRef &&other) noexcept
Move constructor.
Definition: SDL3pp_ttf.h:5233
constexpr TextRef & operator=(const TextRef &other) noexcept=default
Assignment operator.
~TextRef()
Destructor.
Definition: SDL3pp_ttf.h:5239
constexpr TextRef(const Text &resource) noexcept
Constructs from Text.
Definition: SDL3pp_ttf.h:5209
constexpr TextRef(const TextRef &other) noexcept
Copy constructor.
Definition: SDL3pp_ttf.h:5227