4#include "SDL3pp_error.h"
5#include "SDL3pp_init.h"
6#include "SDL3pp_rect.h"
7#include "SDL3pp_render.h"
8#include "SDL3pp_stdinc.h"
9#include "SDL3pp_surface.h"
10#include "SDL3pp_version.h"
12#if !defined(SDL3PP_DISABLE_TTF) && !defined(SDL3PP_ENABLE_TTF) && \
13 __has_include(<SDL3_ttf/SDL_ttf.h>)
14#define SDL3PP_ENABLE_TTF
17#if defined(SDL3PP_ENABLE_TTF) || defined(SDL3PP_DOC)
19#include <SDL3_ttf/SDL_ttf.h>
152 TTF_STYLE_STRIKETHROUGH;
216 TTF_HORIZONTAL_ALIGN_INVALID;
219 TTF_HORIZONTAL_ALIGN_LEFT;
222 TTF_HORIZONTAL_ALIGN_CENTER;
225 TTF_HORIZONTAL_ALIGN_RIGHT;
300 TTF_SUBSTRING_DIRECTION_MASK;
304 TTF_SUBSTRING_TEXT_START;
318 TTF_SUBSTRING_TEXT_END;
335 TTF_GPU_TEXTENGINE_WINDING_INVALID;
338 TTF_GPU_TEXTENGINE_WINDING_CLOCKWISE;
341 TTF_GPU_TEXTENGINE_WINDING_COUNTER_CLOCKWISE;
352#define SDL_TTF_MAJOR_VERSION
354#define SDL_TTF_MINOR_VERSION
356#define SDL_TTF_MICRO_VERSION
363#define SDL_TTF_VERSION \
365 SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_MICRO_VERSION)
370#define SDL_TTF_VERSION_ATLEAST(X, Y, Z) \
371 ((SDL_TTF_MAJOR_VERSION >= X) && \
372 (SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION >= Y) && \
373 (SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION > Y || \
374 SDL_TTF_MICRO_VERSION >= Z))
408 TTF_GetFreeTypeVersion(major, minor, patch);
426 TTF_GetHarfBuzzVersion(major, minor, patch);
550 TTF_RemoveFallbackFont(
get(), fallback.
get());
825#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
857 TTF_SetFontWrapAlignment(
get(), align);
873 return TTF_GetFontWrapAlignment(
get());
1168 bool HasGlyph(Uint32 ch)
const {
return TTF_FontHasGlyph(
get(), ch); }
1186 return TTF_GetGlyphImage(
get(), ch, image_type);
1209 return TTF_GetGlyphImageForIndex(
get(), glyph_index, image_type);
1246 CheckError(TTF_GetGlyphMetrics(
get(), ch, minx, maxx, miny, maxy, advance));
1264 if (
int r; TTF_GetGlyphKerning(
get(), previous_ch, ch, &r))
return r;
1308 CheckError(TTF_GetStringSize(
get(), text.data(), text.size(), w, h));
1367 get(), text.data(), text.size(), wrap_width, w, h));
1394 int* measured_width,
1395 size_t* measured_length)
const
1439 return Surface{TTF_RenderText_Solid(
get(), text.data(), text.size(), fg)};
1476 int wrapLength)
const
1478 return Surface{TTF_RenderText_Solid_Wrapped(
1479 get(), text.data(), text.size(), fg, wrapLength)};
1510 return Surface{TTF_RenderGlyph_Solid(
get(), ch, fg)};
1549 TTF_RenderText_Shaded(
get(), text.data(), text.size(), fg, bg)};
1589 int wrap_width)
const
1591 return Surface{TTF_RenderText_Shaded_Wrapped(
1592 get(), text.data(), text.size(), fg, bg, wrap_width)};
1625 return Surface{TTF_RenderGlyph_Shaded(
get(), ch, fg, bg)};
1661 return Surface{TTF_RenderText_Blended(
get(), text.data(), text.size(), fg)};
1698 int wrap_width)
const
1700 return Surface{TTF_RenderText_Blended_Wrapped(
1701 get(), text.data(), text.size(), fg, wrap_width)};
1732 return Surface{TTF_RenderGlyph_Blended(
get(), ch, fg)};
1769 return Surface{TTF_RenderText_LCD(
get(), text.data(), text.size(), fg, bg)};
1809 int wrap_width)
const
1811 return Surface{TTF_RenderText_LCD_Wrapped(
1812 get(), text.data(), text.size(), fg, bg, wrap_width)};
1845 return Surface{TTF_RenderGlyph_LCD(
get(), ch, fg, bg)};
1870 static void reset(TTF_Font* resource) { TTF_CloseFont(resource); }
2090 TTF_SetGPUTextEngineWinding(
get(), winding);
2109 return TTF_GetGPUTextEngineWinding(
get());
2129 TTF_DestroySurfaceTextEngine(engine);
2150 TTF_DestroyRendererTextEngine(engine);
2171 TTF_DestroyGPUTextEngine(engine);
2201 return TextEngine(TTF_CreateSurfaceTextEngine(),
2223 return TextEngine(TTF_CreateRendererTextEngine(renderer),
2253 return TextEngine(TTF_CreateRendererTextEngineWithProperties(props),
2276 return TextEngine(TTF_CreateGPUTextEngine(device),
2306 return TextEngine(TTF_CreateGPUTextEngineWithProperties(props),
2371namespace prop::Font {
2373constexpr auto CREATE_FILENAME_STRING = TTF_PROP_FONT_CREATE_FILENAME_STRING;
2375constexpr auto CREATE_IOSTREAM_POINTER = TTF_PROP_FONT_CREATE_IOSTREAM_POINTER;
2377constexpr auto CREATE_IOSTREAM_OFFSET_NUMBER =
2378 TTF_PROP_FONT_CREATE_IOSTREAM_OFFSET_NUMBER;
2380constexpr auto CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN =
2381 TTF_PROP_FONT_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN;
2383constexpr auto CREATE_SIZE_FLOAT = TTF_PROP_FONT_CREATE_SIZE_FLOAT;
2385constexpr auto CREATE_FACE_NUMBER = TTF_PROP_FONT_CREATE_FACE_NUMBER;
2387constexpr auto CREATE_HORIZONTAL_DPI_NUMBER =
2388 TTF_PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER;
2390constexpr auto CREATE_VERTICAL_DPI_NUMBER =
2391 TTF_PROP_FONT_CREATE_VERTICAL_DPI_NUMBER;
2393#if SDL_TTF_VERSION_ATLEAST(3, 2, 3)
2395constexpr auto CREATE_EXISTING_FONT_POINTER =
2396 TTF_PROP_FONT_CREATE_EXISTING_FONT_POINTER;
2400constexpr auto CREATE_EXISTING_FONT_POINTER =
2401 TTF_PROP_FONT_CREATE_EXISTING_FONT;
2405constexpr auto OUTLINE_LINE_CAP_NUMBER = TTF_PROP_FONT_OUTLINE_LINE_CAP_NUMBER;
2407constexpr auto OUTLINE_LINE_JOIN_NUMBER =
2408 TTF_PROP_FONT_OUTLINE_LINE_JOIN_NUMBER;
2410constexpr auto OUTLINE_MITER_LIMIT_NUMBER =
2411 TTF_PROP_FONT_OUTLINE_MITER_LIMIT_NUMBER;
2422#define SDL_FONT_WEIGHT_THIN TTF_FONT_WEIGHT_THIN
2427#define SDL_FONT_WEIGHT_EXTRA_LIGHT TTF_FONT_WEIGHT_EXTRA_LIGHT
2432#define SDL_FONT_WEIGHT_LIGHT TTF_FONT_WEIGHT_LIGHT
2437#define SDL_FONT_WEIGHT_NORMAL TTF_FONT_WEIGHT_NORMAL
2442#define SDL_FONT_WEIGHT_MEDIUM TTF_FONT_WEIGHT_MEDIUM
2447#define SDL_FONT_WEIGHT_SEMI_BOLD TTF_FONT_WEIGHT_SEMI_BOLD
2452#define SDL_FONT_WEIGHT_BOLD TTF_FONT_WEIGHT_BOLD
2457#define SDL_FONT_WEIGHT_EXTRA_BOLD TTF_FONT_WEIGHT_EXTRA_BOLD
2462#define SDL_FONT_WEIGHT_BLACK TTF_FONT_WEIGHT_BLACK
2467#define SDL_FONT_WEIGHT_EXTRA_BLACK TTF_FONT_WEIGHT_EXTRA_BLACK
2485 return TTF_StringToTag(
string);
2505 TTF_TagToString(tag,
string, size);
2600 return TTF_GetGPUTextDrawData(
get());
2806 CheckError(TTF_SetTextColorFloat(
get(), c.r, c.g, c.b, c.a));
2844 GetColor(&c->r, &c->g, &c->b, &c->a);
2864 GetColor(&c->r, &c->g, &c->b, &c->a);
2887 void GetColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a)
const
2912 void GetColor(
float* r,
float* g,
float* b,
float* a)
const
2976 return TTF_GetTextPosition(
get(), x, y);
3044 CheckError(TTF_SetTextWrapWhitespaceVisible(
get(), visible));
3062 return TTF_TextWrapWhitespaceVisible(
get());
3084 CheckError(TTF_SetTextString(
get(),
string.data(),
string.size()));
3111 TTF_InsertTextString(
get(), offset,
string.data(),
string.size()));
3133 CheckError(TTF_AppendTextString(
get(),
string.data(),
string.size()));
3279 CheckError(TTF_GetTextSubStringForLine(
get(), line, substring));
3315 auto data = TTF_GetTextSubStringsForRange(
get(), offset, length, &count);
3354 CheckError(TTF_GetTextSubStringForPoint(
get(), p.x, p.y, substring));
3375 CheckError(TTF_GetPreviousTextSubString(
get(), &substring, previous));
3395 CheckError(TTF_GetNextTextSubString(
get(), &substring, next));
3437 static void reset(TTF_Text* resource) { TTF_DestroyText(resource); }
3470 return Text(TTF_CreateText(engine, font, text.data(), text.size()));
3531 : m_text(std::move(text))
3544 constexpr operator bool()
const {
return m_text !=
nullptr; }
3555 return m_subString.offset == other.m_subString.offset;
3591namespace prop::RendererTextEngine {
3593#if SDL_TTF_VERSION_ATLEAST(3, 2, 3)
3595constexpr auto RENDERER_POINTER =
3596 TTF_PROP_RENDERER_TEXT_ENGINE_RENDERER_POINTER;
3598constexpr auto ATLAS_TEXTURE_SIZE_NUMBER =
3599 TTF_PROP_RENDERER_TEXT_ENGINE_ATLAS_TEXTURE_SIZE_NUMBER;
3603constexpr auto RENDERER_POINTER = TTF_PROP_RENDERER_TEXT_ENGINE_RENDERER;
3605constexpr auto ATLAS_TEXTURE_SIZE_NUMBER =
3606 TTF_PROP_RENDERER_TEXT_ENGINE_ATLAS_TEXTURE_SIZE;
3612namespace prop::GpuTextEngine {
3614#if SDL_TTF_VERSION_ATLEAST(3, 2, 3)
3616constexpr auto DEVICE_POINTER = TTF_PROP_GPU_TEXT_ENGINE_DEVICE_POINTER;
3618constexpr auto ATLAS_TEXTURE_SIZE_NUMBER =
3619 TTF_PROP_GPU_TEXT_ENGINE_ATLAS_TEXTURE_SIZE_NUMBER;
3623constexpr auto DEVICE_POINTER = TTF_PROP_GPU_TEXT_ENGINE_DEVICE;
3625constexpr auto ATLAS_TEXTURE_SIZE_NUMBER =
3626 TTF_PROP_GPU_TEXT_ENGINE_ATLAS_TEXTURE_SIZE;
3711#pragma endregion impl
An exception that returns GetError()
Definition SDL3pp_error.h:167
Base class for SDL memory allocated array wrap.
Definition SDL3pp_ownPtr.h:43
RESOURCE release()
Returns reference and reset this.
Definition SDL3pp_resource.h:178
Implement shared ownership for a resource.
Definition SDL3pp_resource.h:283
Implement unique ownership for a resource.
Definition SDL3pp_resource.h:226
constexpr ResourceUnique(std::nullptr_t=nullptr)
Default constructor.
Definition SDL3pp_resource.h:231
void reset()
Resets the value, destroying the resource if not nullptr.
Definition SDL3pp_resource.h:265
A dumb pointer to resource.
Definition SDL3pp_resource.h:197
constexpr ResourceUnsafe()=default
Default constructor.
Implement weak ownership for a resource.
Definition SDL3pp_resource.h:328
A SDL managed resource.
Definition SDL3pp_resource.h:29
constexpr Resource(T resource={})
Constructs from the underlying resource.
Definition SDL3pp_resource.h:37
constexpr TTF_Font * get() const
Return contained resource;.
Definition SDL3pp_resource.h:76
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:43
Iterator for substrings.
Definition SDL3pp_ttf.h:3525
constexpr SubStringIterator()
Default constructor.
Definition SDL3pp_ttf.h:3538
constexpr SubStringIterator & operator--()
Decrement operator.
Definition SDL3pp_ttf.h:3574
constexpr const SubString & operator*() const
Retrieve SubString.
Definition SDL3pp_ttf.h:3547
constexpr const SubString * operator->() const
Retrieve SubString.
Definition SDL3pp_ttf.h:3550
constexpr bool operator==(const SubStringIterator &other) const
Comparison.
Definition SDL3pp_ttf.h:3553
constexpr SubStringIterator operator--(int)
Decrement operator.
Definition SDL3pp_ttf.h:3581
constexpr SubStringIterator operator++(int)
Increment operator.
Definition SDL3pp_ttf.h:3566
constexpr SubStringIterator & operator++()
Increment operator.
Definition SDL3pp_ttf.h:3559
#define SDL_assert_paranoid(condition)
An assertion test that is performed only when built with paranoid settings.
Definition SDL3pp_assert.h:364
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:206
void InitSubSystem(InitFlags flags)
Initialize the SDL library.
Definition SDL3pp_init.h:279
bool WasInit(InitFlags flags)
Check if all of the specified subsystems which are currently initialized.
Definition SDL3pp_init.h:485
void QuitSubSystem(InitFlags flags)
Shut down specific SDL subsystems.
Definition SDL3pp_init.h:427
constexpr FontStyleFlags STYLE_NORMAL
No special style.
Definition SDL3pp_ttf.h:142
TextShared share()
Move this text into a TextShared.
Definition SDL3pp_ttf.h:3493
constexpr SubStringFlags SUBSTRING_LINE_END
This substring contains the end of line line_index
Definition SDL3pp_ttf.h:315
constexpr HintingFlags HINTING_LIGHT
Light hinting applies subtle adjustments to improve rendering.
Definition SDL3pp_ttf.h:183
constexpr HorizontalAlignment HORIZONTAL_ALIGN_CENTER
CENTER.
Definition SDL3pp_ttf.h:221
constexpr HorizontalAlignment HORIZONTAL_ALIGN_RIGHT
RIGHT.
Definition SDL3pp_ttf.h:224
TextEngineShared share()
Move this textEngine into a TextEngineShared.
Definition SDL3pp_ttf.h:2317
TTF_GPUAtlasDrawSequence GPUAtlasDrawSequence
Draw sequence returned by TextRef.GetGPUDrawData.
Definition SDL3pp_ttf.h:2351
constexpr GPUTextEngineWinding GPU_TEXTENGINE_WINDING_COUNTER_CLOCKWISE
COUNTER_CLOCKWISE.
Definition SDL3pp_ttf.h:340
constexpr SubStringFlags SUBSTRING_TEXT_START
This substring contains the beginning of the text.
Definition SDL3pp_ttf.h:303
constexpr SubStringFlags SUBSTRING_LINE_START
This substring contains the beginning of line line_index
Definition SDL3pp_ttf.h:310
constexpr Direction DIRECTION_LTR
Left to Right.
Definition SDL3pp_ttf.h:248
constexpr ImageType IMAGE_COLOR
The color channels have image data.
Definition SDL3pp_ttf.h:275
FontShared share()
Move this font into a FontShared.
Definition SDL3pp_ttf.h:2007
Uint32 StringToTag(StringParam string)
Convert from a 4 character string to a 32-bit tag.
Definition SDL3pp_ttf.h:2483
Uint32 SubStringFlags
Flags for SubString.
Definition SDL3pp_ttf.h:297
TTF_HintingFlags HintingFlags
Hinting flags for TTF (TrueType Fonts)
Definition SDL3pp_ttf.h:173
constexpr ImageType IMAGE_INVALID
INVALID.
Definition SDL3pp_ttf.h:270
int TTF_Version()
This function gets the version of the dynamically linked SDL_ttf library.
Definition SDL3pp_ttf.h:387
ResourceShared< Font > FontShared
Handle to a shared font.
Definition SDL3pp_ttf.h:59
void GetHarfBuzzVersion(int *major, int *minor, int *patch)
Query the version of the HarfBuzz library in use.
Definition SDL3pp_ttf.h:424
constexpr HintingFlags HINTING_INVALID
INVALID.
Definition SDL3pp_ttf.h:175
Uint32 FontStyleFlags
Font style flags for Font.
Definition SDL3pp_ttf.h:140
Font Copy() const
Create a copy of an existing font.
Definition SDL3pp_ttf.h:2415
constexpr Direction DIRECTION_BTT
Bottom to Top.
Definition SDL3pp_ttf.h:254
constexpr HintingFlags HINTING_MONO
Monochrome hinting adjusts the font for better rendering at lower resolutions.
Definition SDL3pp_ttf.h:189
constexpr FontStyleFlags STYLE_ITALIC
Italic style.
Definition SDL3pp_ttf.h:146
void GetFreeTypeVersion(int *major, int *minor, int *patch)
Query the version of the FreeType library in use.
Definition SDL3pp_ttf.h:406
void TagToString(Uint32 tag, char *string, size_t size)
Convert from a 32-bit tag to a 4 character string.
Definition SDL3pp_ttf.h:2503
TTF_GPUTextEngineWinding GPUTextEngineWinding
The winding order of the vertices returned by TextRef.GetGPUDrawData.
Definition SDL3pp_ttf.h:332
constexpr FontStyleFlags STYLE_BOLD
Bold style.
Definition SDL3pp_ttf.h:144
constexpr FontStyleFlags STYLE_STRIKETHROUGH
Strikethrough text.
Definition SDL3pp_ttf.h:151
constexpr Direction DIRECTION_RTL
Right to Left.
Definition SDL3pp_ttf.h:250
TTF_ImageType ImageType
The type of data in a glyph image.
Definition SDL3pp_ttf.h:268
SDL::TtfInitFlag INIT_TTF
Flag to init TTF support.
constexpr HintingFlags HINTING_NORMAL
Normal hinting applies standard grid-fitting.
Definition SDL3pp_ttf.h:177
constexpr HorizontalAlignment HORIZONTAL_ALIGN_INVALID
INVALID.
Definition SDL3pp_ttf.h:215
constexpr Direction DIRECTION_INVALID
INVALID.
Definition SDL3pp_ttf.h:246
constexpr HintingFlags HINTING_NONE
No hinting, the font is rendered without any grid-fitting.
Definition SDL3pp_ttf.h:194
TTF_SubString SubString
The representation of a substring within text.
Definition SDL3pp_ttf.h:2366
constexpr ImageType IMAGE_ALPHA
The color channels are white.
Definition SDL3pp_ttf.h:272
void(*)(TTF_TextEngine *) TextEngineDeleter
Deleter for TextEngine.
Definition SDL3pp_ttf.h:43
constexpr GPUTextEngineWinding GPU_TEXTENGINE_WINDING_INVALID
INVALID.
Definition SDL3pp_ttf.h:334
ResourceShared< Text > TextShared
Handle to a shared text.
Definition SDL3pp_ttf.h:111
TTF_TextData TextData
Internal data for TTF_Text.
Definition SDL3pp_ttf.h:434
constexpr FontStyleFlags STYLE_UNDERLINE
Underlined text.
Definition SDL3pp_ttf.h:148
constexpr SubStringFlags SUBSTRING_TEXT_END
This substring contains the end of the text.
Definition SDL3pp_ttf.h:317
constexpr SubStringFlags SUBSTRING_DIRECTION_MASK
The mask for the flow direction for this substring.
Definition SDL3pp_ttf.h:299
ResourceShared< TextEngine > TextEngineShared
Handle to a shared textEngine.
Definition SDL3pp_ttf.h:85
TTF_HorizontalAlignment HorizontalAlignment
The horizontal alignment used when rendering wrapped text.
Definition SDL3pp_ttf.h:213
constexpr Direction DIRECTION_TTB
Top to Bottom.
Definition SDL3pp_ttf.h:252
constexpr HintingFlags HINTING_LIGHT_SUBPIXEL
Light hinting with subpixel rendering for more precise font edges.
Definition SDL3pp_ttf.h:199
constexpr HorizontalAlignment HORIZONTAL_ALIGN_LEFT
LEFT.
Definition SDL3pp_ttf.h:218
TTF_Direction Direction
Direction flags.
Definition SDL3pp_ttf.h:244
constexpr ImageType IMAGE_SDF
The alpha channel has signed distance field information.
Definition SDL3pp_ttf.h:281
constexpr GPUTextEngineWinding GPU_TEXTENGINE_WINDING_CLOCKWISE
CLOCKWISE.
Definition SDL3pp_ttf.h:337
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
A structure that represents a color as RGBA components.
Definition SDL3pp_pixels.h:1638
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition SDL3pp_pixels.h:1833
The structure that defines a point (using floating point values).
Definition SDL3pp_rect.h:487
The internal structure containing font information.
Definition SDL3pp_ttf.h:444
Direction GetDirection() const
Get the direction to be used for text shaping by a font.
Definition SDL3pp_ttf.h:1077
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:1546
Surface RenderGlyph_Shaded(Uint32 ch, Color fg, Color bg) const
Render a single UNICODE codepoint at high quality to a new 8-bit surface.
Definition SDL3pp_ttf.h:1623
int GetGlyphKerning(Uint32 previous_ch, Uint32 ch) const
Query the kerning size between the glyphs of two UNICODE codepoints.
Definition SDL3pp_ttf.h:1262
const char * GetStyleName() const
Query a font's style name.
Definition SDL3pp_ttf.h:1042
void GetStringSizeWrapped(std::string_view text, int wrap_width, int *w, int *h) const
Calculate the dimensions of a rendered string of UTF-8 text.
Definition SDL3pp_ttf.h:1361
Uint32 GetGeneration() const
Get the font generation.
Definition SDL3pp_ttf.h:505
bool GetKerning() const
Query whether or not kerning is enabled for a font.
Definition SDL3pp_ttf.h:976
static Uint32 GetGlyphScript(Uint32 ch)
Get the script used by a 32-bit codepoint.
Definition SDL3pp_ttf.h:1133
Point GetStringSize(std::string_view text) const
Calculate the dimensions of a rendered string of UTF-8 text.
Definition SDL3pp_ttf.h:1283
void SetSize(float ptsize)
Set a font's size dynamically.
Definition SDL3pp_ttf.h:585
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:1239
HorizontalAlignment GetWrapAlignment() const
Query a font's current wrap alignment option.
Definition SDL3pp_ttf.h:871
Surface RenderGlyph_LCD(Uint32 ch, Color fg, Color bg) const
Render a single UNICODE codepoint at LCD subpixel quality to a new ARGB surface.
Definition SDL3pp_ttf.h:1843
int GetOutline() const
Query a font's current outline.
Definition SDL3pp_ttf.h:728
void SetLineSkip(int lineskip)
Set the spacing between lines of text for a font.
Definition SDL3pp_ttf.h:929
void SetWrapAlignment(HorizontalAlignment align)
Set a font's current wrap alignment option.
Definition SDL3pp_ttf.h:855
void SetKerning(bool enabled)
Set if kerning is enabled for a font.
Definition SDL3pp_ttf.h:963
HintingFlags GetHinting() const
Query a font's current FreeType hinter setting.
Definition SDL3pp_ttf.h:786
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:1767
void RemoveFallback(FontRef fallback)
Remove a fallback font.
Definition SDL3pp_ttf.h:548
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:1659
FontStyleFlags GetStyle() const
Query a font's current style.
Definition SDL3pp_ttf.h:690
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:1696
void SetScript(Uint32 script)
Set the script to be used for text shaping by a font.
Definition SDL3pp_ttf.h:1097
int GetNumFaces() const
Query the number of faces of a font.
Definition SDL3pp_ttf.h:764
int GetLineSkip() const
Query the spacing between lines of text for a font.
Definition SDL3pp_ttf.h:942
int GetHeight() const
Query the total height of a font.
Definition SDL3pp_ttf.h:887
void SetOutline(int outline)
Set a font's current outline.
Definition SDL3pp_ttf.h:712
void SetSDF(bool enabled)
Enable Signed Distance Field rendering for a font.
Definition SDL3pp_ttf.h:810
SurfaceRef GetGlyphImage(Uint32 ch, ImageType *image_type=nullptr) const
Get the pixel image for a UNICODE codepoint.
Definition SDL3pp_ttf.h:1184
int GetAscent() const
Query the offset from the baseline to the top of a font.
Definition SDL3pp_ttf.h:900
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:1332
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:1586
int GetDescent() const
Query the offset from the baseline to the bottom of a font.
Definition SDL3pp_ttf.h:913
bool GetSDF() const
Query whether Signed Distance Field rendering is enabled for a font.
Definition SDL3pp_ttf.h:823
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:1437
SurfaceRef GetGlyphImageForIndex(Uint32 glyph_index, ImageType *image_type=nullptr) const
Get the pixel image for a character index.
Definition SDL3pp_ttf.h:1206
static void reset(TTF_Font *resource)
Dispose of a previously-created font.
Definition SDL3pp_ttf.h:1870
Uint32 GetScript() const
Get the script used for text shaping a font.
Definition SDL3pp_ttf.h:1116
void AddFallback(FontRef fallback)
Add a fallback font.
Definition SDL3pp_ttf.h:528
bool IsFixedWidth() const
Query whether a font is fixed-width.
Definition SDL3pp_ttf.h:993
void SetSizeDPI(float ptsize, int hdpi, int vdpi)
Set font size dynamically with target resolutions, in dots per inch.
Definition SDL3pp_ttf.h:606
bool HasGlyph(Uint32 ch) const
Check whether a glyph is provided by the font for a UNICODE codepoint.
Definition SDL3pp_ttf.h:1168
void GetDPI(int *hdpi, int *vdpi) const
Get font target resolutions, in dots per inch.
Definition SDL3pp_ttf.h:641
Surface RenderGlyph_Blended(Uint32 ch, Color fg) const
Render a single UNICODE codepoint at high quality to a new ARGB surface.
Definition SDL3pp_ttf.h:1730
bool IsScalable() const
Query whether a font is scalable or not.
Definition SDL3pp_ttf.h:1008
float GetSize() const
Get the size of a font.
Definition SDL3pp_ttf.h:625
void SetHinting(HintingFlags hinting)
Set a font's current hinter setting.
Definition SDL3pp_ttf.h:753
void SetDirection(Direction direction)
Set the direction to be used for text shaping by a font.
Definition SDL3pp_ttf.h:1060
PropertiesRef GetProperties()
Get the properties associated with a font.
Definition SDL3pp_ttf.h:486
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:1806
int GetWeight() const
Query a font's weight, in terms of the lightness/heaviness of the strokes.
Definition SDL3pp_ttf.h:837
void SetStyle(FontStyleFlags style)
Set a font's current style.
Definition SDL3pp_ttf.h:669
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:1392
Surface RenderGlyph_Solid(Uint32 ch, Color fg) const
Render a single 32-bit glyph at fast quality to a new 8-bit surface.
Definition SDL3pp_ttf.h:1508
void SetLanguage(StringParam language_bcp47)
Set language to be used for text shaping by a font.
Definition SDL3pp_ttf.h:1152
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:1474
const char * GetFamilyName() const
Query a font's family name.
Definition SDL3pp_ttf.h:1025
void ClearFallbacks()
Remove all fallback fonts.
Definition SDL3pp_ttf.h:567
void GetStringSize(std::string_view text, int *w, int *h) const
Calculate the dimensions of a rendered string of UTF-8 text.
Definition SDL3pp_ttf.h:1306
Unsafe Handle to font.
Definition SDL3pp_ttf.h:2022
constexpr FontUnsafe(Font &&other)
Constructs FontUnsafe from Font.
Definition SDL3pp_ttf.h:2028
Handle to an owned font.
Definition SDL3pp_ttf.h:1881
static Font Open(IOStreamRef src, float ptsize)
Create a font from an IOStreamRef, using a specified point size.
Definition SDL3pp_ttf.h:1925
static Font Open(StringParam file, float ptsize)
Create a font from a file, using a specified point size.
Definition SDL3pp_ttf.h:1902
static Font OpenWithProperties(PropertiesRef props)
Create a font with the specified properties.
Definition SDL3pp_ttf.h:1973
void Close()
Dispose of a previously-created font.
Definition SDL3pp_ttf.h:1998
The read/write operation structure.
Definition SDL3pp_iostream.h:123
The structure that defines a point (using integers).
Definition SDL3pp_rect.h:46
SDL properties ID.
Definition SDL3pp_properties.h:209
A structure representing rendering state.
Definition SDL3pp_render.h:182
A collection of pixels used in software blitting.
Definition SDL3pp_surface.h:153
Handle to an owned surface.
Definition SDL3pp_surface.h:1824
A text engine used to create text objects.
Definition SDL3pp_ttf.h:2072
GPUTextEngineWinding GetGPUWinding() const
Get the winding order of the vertices returned by TextRef.GetGPUDrawData for a particular GPU text en...
Definition SDL3pp_ttf.h:2107
static void DestroySurface(TTF_TextEngine *engine)
Destroy a text engine created for drawing text on SDL surfaces.
Definition SDL3pp_ttf.h:2127
static void DestroyRenderer(TTF_TextEngine *engine)
Destroy a text engine created for drawing text on an SDL renderer.
Definition SDL3pp_ttf.h:2148
void SetGPUWinding(GPUTextEngineWinding winding)
Sets the winding order of the vertices returned by TextRef.GetGPUDrawData for a particular GPU text e...
Definition SDL3pp_ttf.h:2088
static void DestroyGPU(TTF_TextEngine *engine)
Destroy a text engine created for drawing text with the SDL GPU API.
Definition SDL3pp_ttf.h:2169
Unsafe Handle to textEngine.
Definition SDL3pp_ttf.h:2332
constexpr TextEngineUnsafe(TextEngine &&other)
Constructs TextEngineUnsafe from TextEngine.
Definition SDL3pp_ttf.h:2338
Handle to an owned textEngine.
Definition SDL3pp_ttf.h:2183
static TextEngine CreateGPU(SDL_GPUDevice *device)
Create a text engine for drawing text with the SDL GPU API.
Definition SDL3pp_ttf.h:2274
static TextEngine CreateSurface()
Create a text engine for drawing text on SDL surfaces.
Definition SDL3pp_ttf.h:2199
static TextEngine CreateRendererWithProperties(PropertiesRef props)
Create a text engine for drawing text on an SDL renderer, with the specified properties.
Definition SDL3pp_ttf.h:2251
static TextEngine CreateRenderer(RendererRef renderer)
Create a text engine for drawing text on an SDL renderer.
Definition SDL3pp_ttf.h:2221
static TextEngine CreateGPUWithProperties(PropertiesRef props)
Create a text engine for drawing text with the SDL GPU API, with the specified properties.
Definition SDL3pp_ttf.h:2304
Text created with Text.Create()
Definition SDL3pp_ttf.h:2521
void Update()
Update the layout of a text object.
Definition SDL3pp_ttf.h:3412
SubStringIterator GetSubStringForPoint(Point p) const
Get the portion of a text string that is closest to a point.
Definition SDL3pp_ttf.h:3704
bool SetPosition(Point p)
Set the position of a text object.
Definition SDL3pp_ttf.h:2934
void InsertString(int offset, std::string_view string)
Insert UTF-8 text into a text object.
Definition SDL3pp_ttf.h:3108
void GetNextSubString(const SubString &substring, SubString *next) const
Get the next substring in a text object.
Definition SDL3pp_ttf.h:3393
Point GetSize() const
Get the size of a text object.
Definition SDL3pp_ttf.h:3179
void GetSubStringForPoint(Point p, SubString *substring) const
Get the portion of a text string that is closest to a point.
Definition SDL3pp_ttf.h:3352
void SetWrapWidth(int wrap_width)
Set whether wrapping is enabled on a text object.
Definition SDL3pp_ttf.h:2995
void AppendString(std::string_view string)
Append UTF-8 text to a text object.
Definition SDL3pp_ttf.h:3131
void GetSubStringForLine(int line, SubString *substring) const
Get the substring of a text object that contains the given line.
Definition SDL3pp_ttf.h:3277
void SetEngine(TextEngineRef engine)
Set the text engine used by a text object.
Definition SDL3pp_ttf.h:2634
int GetWrapWidth() const
Get whether wrapping is enabled on a text object.
Definition SDL3pp_ttf.h:3014
void SetScript(Uint32 script)
Set the script to be used for text shaping a text object.
Definition SDL3pp_ttf.h:2743
bool SetFont(FontRef font)
Set the font used by a text object.
Definition SDL3pp_ttf.h:2677
Direction GetDirection() const
Get the direction to be used for text shaping a text object.
Definition SDL3pp_ttf.h:2725
void GetColor(FColor *c) const
Get the color of a text object.
Definition SDL3pp_ttf.h:2861
SubStringIterator end() const
Get iterator to one past last substring.
Definition SDL3pp_ttf.h:3690
void DrawSurface(Point p, SurfaceRef surface) const
Draw text to an SDL surface.
Definition SDL3pp_ttf.h:2543
Uint32 GetScript() const
Get the script used for text shaping a text object.
Definition SDL3pp_ttf.h:2765
void GetSize(int *w, int *h) const
Get the size of a text object.
Definition SDL3pp_ttf.h:3203
void SetDirection(Direction direction)
Set the direction to be used for text shaping a text object.
Definition SDL3pp_ttf.h:2708
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:3418
void GetColor(float *r, float *g, float *b, float *a) const
Get the color of a text object.
Definition SDL3pp_ttf.h:2912
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:3312
void SetString(std::string_view string)
Set the UTF-8 text used by a text object.
Definition SDL3pp_ttf.h:3082
FontRef GetFont() const
Get the font used by a text object.
Definition SDL3pp_ttf.h:2692
void DeleteString(int offset, int length=-1)
Delete UTF-8 text from a text object.
Definition SDL3pp_ttf.h:3158
int GetNumLines() const
The number of lines in the text, 0 if it's empty.
Definition SDL3pp_ttf.h:3423
void SetColor(Color c)
Set the color of a text object.
Definition SDL3pp_ttf.h:2783
void SetColor(FColor c)
Set the color of a text object.
Definition SDL3pp_ttf.h:2804
GPUAtlasDrawSequence * GetGPUDrawData() const
Get the geometry data needed for drawing the text.
Definition SDL3pp_ttf.h:2598
void GetColor(Color *c) const
Get the color of a text object.
Definition SDL3pp_ttf.h:2841
PropertiesRef GetProperties() const
Get the properties associated with a text object.
Definition SDL3pp_ttf.h:2614
bool GetPosition(int *x, int *y) const
Get the position of a text object.
Definition SDL3pp_ttf.h:2974
static void reset(TTF_Text *resource)
Destroy a text object created by a text engine.
Definition SDL3pp_ttf.h:3437
SubStringIterator GetSubStringForLine(int line) const
Get iterator to substring of a text object that contains the given line.
Definition SDL3pp_ttf.h:3697
FColor GetColor() const
Get the color of a text object.
Definition SDL3pp_ttf.h:2820
void SetWrapWhitespaceVisible(bool visible)
Set whether whitespace should be visible when wrapping a text object.
Definition SDL3pp_ttf.h:3042
TextEngineRef GetEngine() const
Get the text engine used by a text object.
Definition SDL3pp_ttf.h:2652
void GetPreviousSubString(const SubString &substring, SubString *previous) const
Get the previous substring in a text object.
Definition SDL3pp_ttf.h:3372
void DrawRenderer(FPoint p) const
Draw text to an SDL renderer.
Definition SDL3pp_ttf.h:2567
bool IsWrapWhitespaceVisible() const
Return whether whitespace is shown when wrapping a text object.
Definition SDL3pp_ttf.h:3060
OwnArray< SubString * > GetSubStrings() const
Get all substrings of a text object.
Definition SDL3pp_ttf.h:3293
SubStringIterator begin() const
Get iterator to first substring.
Definition SDL3pp_ttf.h:3683
Point GetPosition() const
Get the position of a text object.
Definition SDL3pp_ttf.h:2950
void GetSubString(int offset, SubString *substring) const
Get the substring of a text object that surrounds a text offset.
Definition SDL3pp_ttf.h:3227
void GetColor(Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const
Get the color of a text object.
Definition SDL3pp_ttf.h:2887
Unsafe Handle to text.
Definition SDL3pp_ttf.h:3508
constexpr TextUnsafe(Text &&other)
Constructs TextUnsafe from Text.
Definition SDL3pp_ttf.h:3514
Handle to an owned text.
Definition SDL3pp_ttf.h:3448
static Text Create(TextEngineRef engine, FontRef font, std::string_view text)
Create a text object from UTF-8 text and a text engine.
Definition SDL3pp_ttf.h:3468
void Destroy()
Destroy a text object created by a text engine.
Definition SDL3pp_ttf.h:3484
Flag to init TTF.
Definition SDL3pp_ttf.h:39