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>
98 TTF_STYLE_STRIKETHROUGH;
162 TTF_HORIZONTAL_ALIGN_INVALID;
165 TTF_HORIZONTAL_ALIGN_LEFT;
168 TTF_HORIZONTAL_ALIGN_CENTER;
171 TTF_HORIZONTAL_ALIGN_RIGHT;
246 TTF_SUBSTRING_DIRECTION_MASK;
250 TTF_SUBSTRING_TEXT_START;
264 TTF_SUBSTRING_TEXT_END;
281 TTF_GPU_TEXTENGINE_WINDING_INVALID;
284 TTF_GPU_TEXTENGINE_WINDING_CLOCKWISE;
287 TTF_GPU_TEXTENGINE_WINDING_COUNTER_CLOCKWISE;
298#define SDL_TTF_MAJOR_VERSION
300#define SDL_TTF_MINOR_VERSION
302#define SDL_TTF_MICRO_VERSION
309#define SDL_TTF_VERSION \
311 SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_MICRO_VERSION)
316#define SDL_TTF_VERSION_ATLEAST(X, Y, Z) \
317 ((SDL_TTF_MAJOR_VERSION >= X) && \
318 (SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION >= Y) && \
319 (SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION > Y || \
320 SDL_TTF_MICRO_VERSION >= Z))
354 TTF_GetFreeTypeVersion(major, minor, patch);
372 TTF_GetHarfBuzzVersion(major, minor, patch);
583 TTF_RemoveFallbackFont(
get(), fallback.
get());
858#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
890 TTF_SetFontWrapAlignment(
get(), align);
906 return TTF_GetFontWrapAlignment(
get());
1201 bool HasGlyph(Uint32 ch)
const {
return TTF_FontHasGlyph(
get(), ch); }
1219 return TTF_GetGlyphImage(
get(), ch, image_type);
1242 return TTF_GetGlyphImageForIndex(
get(), glyph_index, image_type);
1279 CheckError(TTF_GetGlyphMetrics(
get(), ch, minx, maxx, miny, maxy, advance));
1297 if (
int r; TTF_GetGlyphKerning(
get(), previous_ch, ch, &r))
return r;
1341 CheckError(TTF_GetStringSize(
get(), text.data(), text.size(), w, h));
1400 get(), text.data(), text.size(), wrap_width, w, h));
1427 int* measured_width,
1428 size_t* measured_length)
const
1472 return Surface{TTF_RenderText_Solid(
get(), text.data(), text.size(), fg)};
1509 int wrapLength)
const
1511 return Surface{TTF_RenderText_Solid_Wrapped(
1512 get(), text.data(), text.size(), fg, wrapLength)};
1543 return Surface{TTF_RenderGlyph_Solid(
get(), ch, fg)};
1582 TTF_RenderText_Shaded(
get(), text.data(), text.size(), fg, bg)};
1622 int wrap_width)
const
1624 return Surface{TTF_RenderText_Shaded_Wrapped(
1625 get(), text.data(), text.size(), fg, bg, wrap_width)};
1658 return Surface{TTF_RenderGlyph_Shaded(
get(), ch, fg, bg)};
1694 return Surface{TTF_RenderText_Blended(
get(), text.data(), text.size(), fg)};
1731 int wrap_width)
const
1733 return Surface{TTF_RenderText_Blended_Wrapped(
1734 get(), text.data(), text.size(), fg, wrap_width)};
1765 return Surface{TTF_RenderGlyph_Blended(
get(), ch, fg)};
1802 return Surface{TTF_RenderText_LCD(
get(), text.data(), text.size(), fg, bg)};
1842 int wrap_width)
const
1844 return Surface{TTF_RenderText_LCD_Wrapped(
1845 get(), text.data(), text.size(), fg, bg, wrap_width)};
1878 return Surface{TTF_RenderGlyph_LCD(
get(), ch, fg, bg)};
1945 TTF_CloseFont(
release(newResource));
1964 constexpr explicit Font(TTF_Font* resource = {})
1969 constexpr Font(
const Font& other) =
delete;
2040 void (*destroy)(TTF_TextEngine* engine))
2061 TTF_SetGPUTextEngineWinding(
get(), winding);
2080 return TTF_GetGPUTextEngineWinding(
get());
2131 void reset(TTF_TextEngine* newResource = {})
2133 auto prevValue =
release(newResource);
2159 constexpr TextEngine(
const TextEngine& other) =
delete;
2210namespace prop::Font {
2212constexpr auto CREATE_FILENAME_STRING = TTF_PROP_FONT_CREATE_FILENAME_STRING;
2214constexpr auto CREATE_IOSTREAM_POINTER = TTF_PROP_FONT_CREATE_IOSTREAM_POINTER;
2216constexpr auto CREATE_IOSTREAM_OFFSET_NUMBER =
2217 TTF_PROP_FONT_CREATE_IOSTREAM_OFFSET_NUMBER;
2219constexpr auto CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN =
2220 TTF_PROP_FONT_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN;
2222constexpr auto CREATE_SIZE_FLOAT = TTF_PROP_FONT_CREATE_SIZE_FLOAT;
2224constexpr auto CREATE_FACE_NUMBER = TTF_PROP_FONT_CREATE_FACE_NUMBER;
2226constexpr auto CREATE_HORIZONTAL_DPI_NUMBER =
2227 TTF_PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER;
2229constexpr auto CREATE_VERTICAL_DPI_NUMBER =
2230 TTF_PROP_FONT_CREATE_VERTICAL_DPI_NUMBER;
2232constexpr auto CREATE_EXISTING_FONT = TTF_PROP_FONT_CREATE_EXISTING_FONT;
2234constexpr auto OUTLINE_LINE_CAP_NUMBER = TTF_PROP_FONT_OUTLINE_LINE_CAP_NUMBER;
2236constexpr auto OUTLINE_LINE_JOIN_NUMBER =
2237 TTF_PROP_FONT_OUTLINE_LINE_JOIN_NUMBER;
2239constexpr auto OUTLINE_MITER_LIMIT_NUMBER =
2240 TTF_PROP_FONT_OUTLINE_MITER_LIMIT_NUMBER;
2251#define SDL_FONT_WEIGHT_THIN TTF_FONT_WEIGHT_THIN
2256#define SDL_FONT_WEIGHT_EXTRA_LIGHT TTF_FONT_WEIGHT_EXTRA_LIGHT
2261#define SDL_FONT_WEIGHT_LIGHT TTF_FONT_WEIGHT_LIGHT
2266#define SDL_FONT_WEIGHT_NORMAL TTF_FONT_WEIGHT_NORMAL
2271#define SDL_FONT_WEIGHT_MEDIUM TTF_FONT_WEIGHT_MEDIUM
2276#define SDL_FONT_WEIGHT_SEMI_BOLD TTF_FONT_WEIGHT_SEMI_BOLD
2281#define SDL_FONT_WEIGHT_BOLD TTF_FONT_WEIGHT_BOLD
2286#define SDL_FONT_WEIGHT_EXTRA_BOLD TTF_FONT_WEIGHT_EXTRA_BOLD
2291#define SDL_FONT_WEIGHT_BLACK TTF_FONT_WEIGHT_BLACK
2296#define SDL_FONT_WEIGHT_EXTRA_BLACK TTF_FONT_WEIGHT_EXTRA_BLACK
2314 return TTF_StringToTag(
string);
2334 TTF_TagToString(tag,
string, size);
2429 return TTF_GetGPUTextDrawData(
get());
2451 TTF_CreateText(engine.
get(), font.
get(), text.data(), text.size()))
2658 CheckError(TTF_SetTextColorFloat(
get(), c.r, c.g, c.b, c.a));
2696 GetColor(&c->r, &c->g, &c->b, &c->a);
2716 GetColor(&c->r, &c->g, &c->b, &c->a);
2739 void GetColor(Uint8* r, Uint8* g, Uint8* b, Uint8* a)
const
2764 void GetColor(
float* r,
float* g,
float* b,
float* a)
const
2828 return TTF_GetTextPosition(
get(), x, y);
2896 CheckError(TTF_SetTextWrapWhitespaceVisible(
get(), visible));
2914 return TTF_TextWrapWhitespaceVisible(
get());
2936 CheckError(TTF_SetTextString(
get(),
string.data(),
string.size()));
2963 TTF_InsertTextString(
get(), offset,
string.data(),
string.size()));
2985 CheckError(TTF_AppendTextString(
get(),
string.data(),
string.size()));
3133 CheckError(TTF_GetTextSubStringForLine(
get(), line, substring));
3169 auto data = TTF_GetTextSubStringsForRange(
get(), offset, length, &count);
3208 CheckError(TTF_GetTextSubStringForPoint(
get(), p.x, p.y, substring));
3229 CheckError(TTF_GetPreviousTextSubString(
get(), &substring, previous));
3249 CheckError(TTF_GetNextTextSubString(
get(), &substring, next));
3334 TTF_DestroyText(
release(newResource));
3353 constexpr explicit Text(TTF_Text* resource = {})
3358 constexpr Text(
const Text& other) =
delete;
3391 : m_text(std::move(text))
3404 constexpr operator bool()
const {
return m_text !=
nullptr; }
3415 return m_subString.offset == other.m_subString.offset;
3466 return TextEngine{TTF_CreateSurfaceTextEngine(),
3467 TTF_DestroySurfaceTextEngine};
3488 return TextEngine{TTF_CreateRendererTextEngine(renderer.
get()),
3489 TTF_DestroyRendererTextEngine};
3518 return TextEngine{TTF_CreateRendererTextEngineWithProperties(props.
get()),
3519 TTF_DestroyRendererTextEngine};
3522namespace prop::RendererTextEngine {
3524constexpr auto RENDERER = TTF_PROP_RENDERER_TEXT_ENGINE_RENDERER;
3526constexpr auto ATLAS_TEXTURE_SIZE =
3527 TTF_PROP_RENDERER_TEXT_ENGINE_ATLAS_TEXTURE_SIZE;
3550 return TextEngine{TTF_CreateGPUTextEngine(device), TTF_DestroyGPUTextEngine};
3579 return TextEngine{TTF_CreateGPUTextEngineWithProperties(props.
get()),
3580 TTF_DestroyGPUTextEngine};
3583namespace prop::GpuTextEngine {
3585constexpr auto DEVICE = TTF_PROP_GPU_TEXT_ENGINE_DEVICE;
3587constexpr auto ATLAS_TEXTURE_SIZE = TTF_PROP_GPU_TEXT_ENGINE_ATLAS_TEXTURE_SIZE;
3670#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
A SDL managed resource.
Definition SDL3pp_resource.h:17
constexpr TTF_Font * release(TTF_Font * newResource={})
Return contained resource and empties or replace value.
Definition SDL3pp_resource.h:60
constexpr Resource(T resource={})
Constructs the underlying resource.
Definition SDL3pp_resource.h:22
constexpr TTF_Font * get() const
Return contained resource;.
Definition SDL3pp_resource.h:57
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:43
Iterator for substrings.
Definition SDL3pp_ttf.h:3385
constexpr SubStringIterator()
Default constructor.
Definition SDL3pp_ttf.h:3398
constexpr SubStringIterator & operator--()
Decrement operator.
Definition SDL3pp_ttf.h:3434
constexpr const SubString & operator*() const
Retrieve SubString.
Definition SDL3pp_ttf.h:3407
constexpr const SubString * operator->() const
Retrieve SubString.
Definition SDL3pp_ttf.h:3410
constexpr bool operator==(const SubStringIterator &other) const
Comparison.
Definition SDL3pp_ttf.h:3413
constexpr SubStringIterator operator--(int)
Decrement operator.
Definition SDL3pp_ttf.h:3441
constexpr SubStringIterator operator++(int)
Increment operator.
Definition SDL3pp_ttf.h:3426
constexpr SubStringIterator & operator++()
Increment operator.
Definition SDL3pp_ttf.h:3419
#define SDL_assert_paranoid(condition)
An assertion test that is performed only when built with paranoid settings.
Definition SDL3pp_assert.h:374
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:283
bool WasInit(InitFlags flags)
Check if all of the specified subsystems which are currently initialized.
Definition SDL3pp_init.h:489
void QuitSubSystem(InitFlags flags)
Shut down specific SDL subsystems.
Definition SDL3pp_init.h:431
constexpr FontStyleFlags STYLE_NORMAL
No special style.
Definition SDL3pp_ttf.h:88
constexpr SubStringFlags SUBSTRING_LINE_END
This substring contains the end of line line_index
Definition SDL3pp_ttf.h:261
constexpr HintingFlags HINTING_LIGHT
Light hinting applies subtle adjustments to improve rendering.
Definition SDL3pp_ttf.h:129
TextEngine CreateSurfaceTextEngine()
Create a text engine for drawing text on SDL surfaces.
Definition SDL3pp_ttf.h:3464
constexpr HorizontalAlignment HORIZONTAL_ALIGN_CENTER
CENTER.
Definition SDL3pp_ttf.h:167
constexpr HorizontalAlignment HORIZONTAL_ALIGN_RIGHT
RIGHT.
Definition SDL3pp_ttf.h:170
TTF_GPUAtlasDrawSequence GPUAtlasDrawSequence
Draw sequence returned by TextBase.GetGPUDrawData.
Definition SDL3pp_ttf.h:2190
constexpr GPUTextEngineWinding GPU_TEXTENGINE_WINDING_COUNTER_CLOCKWISE
COUNTER_CLOCKWISE.
Definition SDL3pp_ttf.h:286
constexpr SubStringFlags SUBSTRING_TEXT_START
This substring contains the beginning of the text.
Definition SDL3pp_ttf.h:249
constexpr SubStringFlags SUBSTRING_LINE_START
This substring contains the beginning of line line_index
Definition SDL3pp_ttf.h:256
TextEngine CreateGPUTextEngine(SDL_GPUDevice *device)
Create a text engine for drawing text with the SDL GPU API.
Definition SDL3pp_ttf.h:3548
constexpr Direction DIRECTION_LTR
Left to Right.
Definition SDL3pp_ttf.h:194
constexpr ImageType IMAGE_COLOR
The color channels have image data.
Definition SDL3pp_ttf.h:221
Uint32 StringToTag(StringParam string)
Convert from a 4 character string to a 32-bit tag.
Definition SDL3pp_ttf.h:2312
Uint32 SubStringFlags
Flags for SubString.
Definition SDL3pp_ttf.h:243
TTF_HintingFlags HintingFlags
Hinting flags for TTF (TrueType Fonts)
Definition SDL3pp_ttf.h:119
constexpr ImageType IMAGE_INVALID
INVALID.
Definition SDL3pp_ttf.h:216
int TTF_Version()
This function gets the version of the dynamically linked SDL_ttf library.
Definition SDL3pp_ttf.h:333
void GetHarfBuzzVersion(int *major, int *minor, int *patch)
Query the version of the HarfBuzz library in use.
Definition SDL3pp_ttf.h:370
constexpr HintingFlags HINTING_INVALID
INVALID.
Definition SDL3pp_ttf.h:121
Uint32 FontStyleFlags
Font style flags for FontBase.
Definition SDL3pp_ttf.h:86
constexpr Direction DIRECTION_BTT
Bottom to Top.
Definition SDL3pp_ttf.h:200
constexpr HintingFlags HINTING_MONO
Monochrome hinting adjusts the font for better rendering at lower resolutions.
Definition SDL3pp_ttf.h:135
constexpr FontStyleFlags STYLE_ITALIC
Italic style.
Definition SDL3pp_ttf.h:92
void GetFreeTypeVersion(int *major, int *minor, int *patch)
Query the version of the FreeType library in use.
Definition SDL3pp_ttf.h:352
void TagToString(Uint32 tag, char *string, size_t size)
Convert from a 32-bit tag to a 4 character string.
Definition SDL3pp_ttf.h:2332
TTF_GPUTextEngineWinding GPUTextEngineWinding
The winding order of the vertices returned by TextBase.GetGPUDrawData.
Definition SDL3pp_ttf.h:278
constexpr FontStyleFlags STYLE_BOLD
Bold style.
Definition SDL3pp_ttf.h:90
constexpr FontStyleFlags STYLE_STRIKETHROUGH
Strikethrough text.
Definition SDL3pp_ttf.h:97
Font Copy() const
Create a copy of an existing font.
Definition SDL3pp_ttf.h:2244
TextEngine CreateGPUTextEngineWithProperties(PropertiesBase &props)
Create a text engine for drawing text with the SDL GPU API, with the specified properties.
Definition SDL3pp_ttf.h:3577
constexpr Direction DIRECTION_RTL
Right to Left.
Definition SDL3pp_ttf.h:196
TTF_ImageType ImageType
The type of data in a glyph image.
Definition SDL3pp_ttf.h:214
TextEngine CreateRendererTextEngineWithProperties(PropertiesBase &props)
Create a text engine for drawing text on an SDL renderer, with the specified properties.
Definition SDL3pp_ttf.h:3516
SDL::TtfInitFlag INIT_TTF
Flag to init TTF support.
constexpr HintingFlags HINTING_NORMAL
Normal hinting applies standard grid-fitting.
Definition SDL3pp_ttf.h:123
constexpr HorizontalAlignment HORIZONTAL_ALIGN_INVALID
INVALID.
Definition SDL3pp_ttf.h:161
constexpr Direction DIRECTION_INVALID
INVALID.
Definition SDL3pp_ttf.h:192
constexpr HintingFlags HINTING_NONE
No hinting, the font is rendered without any grid-fitting.
Definition SDL3pp_ttf.h:140
TTF_SubString SubString
The representation of a substring within text.
Definition SDL3pp_ttf.h:2205
constexpr ImageType IMAGE_ALPHA
The color channels are white.
Definition SDL3pp_ttf.h:218
TextEngine CreateRendererTextEngine(RendererBase &renderer)
Create a text engine for drawing text on an SDL renderer.
Definition SDL3pp_ttf.h:3486
constexpr GPUTextEngineWinding GPU_TEXTENGINE_WINDING_INVALID
INVALID.
Definition SDL3pp_ttf.h:280
TTF_TextData TextData
Internal data for TTF_Text.
Definition SDL3pp_ttf.h:380
constexpr FontStyleFlags STYLE_UNDERLINE
Underlined text.
Definition SDL3pp_ttf.h:94
constexpr SubStringFlags SUBSTRING_TEXT_END
This substring contains the end of the text.
Definition SDL3pp_ttf.h:263
constexpr SubStringFlags SUBSTRING_DIRECTION_MASK
The mask for the flow direction for this substring.
Definition SDL3pp_ttf.h:245
TTF_HorizontalAlignment HorizontalAlignment
The horizontal alignment used when rendering wrapped text.
Definition SDL3pp_ttf.h:159
constexpr Direction DIRECTION_TTB
Top to Bottom.
Definition SDL3pp_ttf.h:198
constexpr HintingFlags HINTING_LIGHT_SUBPIXEL
Light hinting with subpixel rendering for more precise font edges.
Definition SDL3pp_ttf.h:145
constexpr HorizontalAlignment HORIZONTAL_ALIGN_LEFT
LEFT.
Definition SDL3pp_ttf.h:164
TTF_Direction Direction
Direction flags.
Definition SDL3pp_ttf.h:190
constexpr ImageType IMAGE_SDF
The alpha channel has signed distance field information.
Definition SDL3pp_ttf.h:227
constexpr GPUTextEngineWinding GPU_TEXTENGINE_WINDING_CLOCKWISE
CLOCKWISE.
Definition SDL3pp_ttf.h:283
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:1621
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition SDL3pp_pixels.h:1816
The structure that defines a point (using floating point values).
Definition SDL3pp_rect.h:479
The internal structure containing font information.
Definition SDL3pp_ttf.h:391
void SetHinting(HintingFlags hinting)
Set a font's current hinter setting.
Definition SDL3pp_ttf.h:786
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:1729
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:1579
void GetDPI(int *hdpi, int *vdpi) const
Get font target resolutions, in dots per inch.
Definition SDL3pp_ttf.h:674
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:1692
void SetScript(Uint32 script)
Set the script to be used for text shaping by a font.
Definition SDL3pp_ttf.h:1130
bool GetKerning() const
Query whether or not kerning is enabled for a font.
Definition SDL3pp_ttf.h:1009
int GetDescent() const
Query the offset from the baseline to the bottom of a font.
Definition SDL3pp_ttf.h:946
void AddFallback(FontBase &fallback)
Add a fallback font.
Definition SDL3pp_ttf.h:561
bool IsFixedWidth() const
Query whether a font is fixed-width.
Definition SDL3pp_ttf.h:1026
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:1470
FontBase(StringParam file, float ptsize)
Create a font from a file, using a specified point size.
Definition SDL3pp_ttf.h:410
void SetSizeDPI(float ptsize, int hdpi, int vdpi)
Set font size dynamically with target resolutions, in dots per inch.
Definition SDL3pp_ttf.h:639
PropertiesRef GetProperties()
Get the properties associated with a font.
Definition SDL3pp_ttf.h:519
void SetOutline(int outline)
Set a font's current outline.
Definition SDL3pp_ttf.h:745
void SetWrapAlignment(HorizontalAlignment align)
Set a font's current wrap alignment option.
Definition SDL3pp_ttf.h:888
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:1394
int GetLineSkip() const
Query the spacing between lines of text for a font.
Definition SDL3pp_ttf.h:975
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:1541
bool HasGlyph(Uint32 ch) const
Check whether a glyph is provided by the font for a UNICODE codepoint.
Definition SDL3pp_ttf.h:1201
void RemoveFallback(FontBase &fallback)
Remove a fallback font.
Definition SDL3pp_ttf.h:581
void SetSize(float ptsize)
Set a font's size dynamically.
Definition SDL3pp_ttf.h:618
Uint32 GetGeneration() const
Get the font generation.
Definition SDL3pp_ttf.h:538
SurfaceRef GetGlyphImage(Uint32 ch, ImageType *image_type=nullptr) const
Get the pixel image for a UNICODE codepoint.
Definition SDL3pp_ttf.h:1217
HorizontalAlignment GetWrapAlignment() const
Query a font's current wrap alignment option.
Definition SDL3pp_ttf.h:904
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:1365
Point GetStringSize(std::string_view text) const
Calculate the dimensions of a rendered string of UTF-8 text.
Definition SDL3pp_ttf.h:1316
int GetWeight() const
Query a font's weight, in terms of the lightness/heaviness of the strokes.
Definition SDL3pp_ttf.h:870
int GetNumFaces() const
Query the number of faces of a font.
Definition SDL3pp_ttf.h:797
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:1763
SurfaceRef GetGlyphImageForIndex(Uint32 glyph_index, ImageType *image_type=nullptr) const
Get the pixel image for a character index.
Definition SDL3pp_ttf.h:1239
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:1272
bool GetSDF() const
Query whether Signed Distance Field rendering is enabled for a font.
Definition SDL3pp_ttf.h:856
void SetDirection(Direction direction)
Set the direction to be used for text shaping by a font.
Definition SDL3pp_ttf.h:1093
static Uint32 GetGlyphScript(Uint32 ch)
Get the script used by a 32-bit codepoint.
Definition SDL3pp_ttf.h:1166
void SetStyle(FontStyleFlags style)
Set a font's current style.
Definition SDL3pp_ttf.h:702
void SetLanguage(StringParam language_bcp47)
Set language to be used for text shaping by a font.
Definition SDL3pp_ttf.h:1185
const char * GetStyleName() const
Query a font's style name.
Definition SDL3pp_ttf.h:1075
int GetAscent() const
Query the offset from the baseline to the top of a font.
Definition SDL3pp_ttf.h:933
bool IsScalable() const
Query whether a font is scalable or not.
Definition SDL3pp_ttf.h:1041
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:1425
int GetOutline() const
Query a font's current outline.
Definition SDL3pp_ttf.h:761
void SetKerning(bool enabled)
Set if kerning is enabled for a font.
Definition SDL3pp_ttf.h:996
FontBase(PropertiesBase &props)
Create a font with the specified properties.
Definition SDL3pp_ttf.h:477
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:1507
FontBase(IOStreamBase &src, float ptsize)
Create a font from an IOStreamBase, using a specified point size.
Definition SDL3pp_ttf.h:431
float GetSize() const
Get the size of a font.
Definition SDL3pp_ttf.h:658
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:1339
void SetLineSkip(int lineskip)
Set the spacing between lines of text for a font.
Definition SDL3pp_ttf.h:962
const char * GetFamilyName() const
Query a font's family name.
Definition SDL3pp_ttf.h:1058
void ClearFallbacks()
Remove all fallback fonts.
Definition SDL3pp_ttf.h:600
int GetHeight() const
Query the total height of a font.
Definition SDL3pp_ttf.h:920
FontStyleFlags GetStyle() const
Query a font's current style.
Definition SDL3pp_ttf.h:723
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:1800
Uint32 GetScript() const
Get the script used for text shaping a font.
Definition SDL3pp_ttf.h:1149
void SetSDF(bool enabled)
Enable Signed Distance Field rendering for a font.
Definition SDL3pp_ttf.h:843
Direction GetDirection() const
Get the direction to be used for text shaping by a font.
Definition SDL3pp_ttf.h:1110
int GetGlyphKerning(Uint32 previous_ch, Uint32 ch) const
Query the kerning size between the glyphs of two UNICODE codepoints.
Definition SDL3pp_ttf.h:1295
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:1839
HintingFlags GetHinting() const
Query a font's current FreeType hinter setting.
Definition SDL3pp_ttf.h:819
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:1876
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:1656
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:1619
Handle to a non owned font.
Definition SDL3pp_ttf.h:1891
constexpr FontRef(FontRef &&other)
Move constructor.
Definition SDL3pp_ttf.h:1905
void reset(TTF_Font *newResource={})
Dispose of a previously-created font.
Definition SDL3pp_ttf.h:1943
constexpr ~FontRef()=default
Default constructor.
constexpr FontRef(const FontRef &other)
Copy constructor.
Definition SDL3pp_ttf.h:1897
FontRef & operator=(FontRef other)
Assignment operator.
Definition SDL3pp_ttf.h:1918
Handle to an owned font.
Definition SDL3pp_ttf.h:1958
constexpr Font(TTF_Font *resource={})
Constructs from the underlying resource.
Definition SDL3pp_ttf.h:1964
~Font()
Frees up resource when object goes out of scope.
Definition SDL3pp_ttf.h:1979
Font & operator=(Font other)
Assignment operator.
Definition SDL3pp_ttf.h:1984
constexpr Font(Font &&other)=default
Move constructor.
The read/write operation structure.
Definition SDL3pp_iostream.h:107
The structure that defines a point (using integers)
Definition SDL3pp_rect.h:41
Wrap properties id.
Definition SDL3pp_properties.h:203
Handle to a non owned properties.
Definition SDL3pp_properties.h:693
A structure representing rendering state.
Definition SDL3pp_render.h:157
Handle to a non owned surface.
Definition SDL3pp_surface.h:1814
Handle to an owned surface.
Definition SDL3pp_surface.h:1873
Text created with TextBase.TextBase()
Definition SDL3pp_ttf.h:2350
void GetColor(Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const
Get the color of a text object.
Definition SDL3pp_ttf.h:2739
OwnArray< SubString * > GetSubStrings() const
Get all substrings of a text object.
Definition SDL3pp_ttf.h:3147
bool IsWrapWhitespaceVisible() const
Return whether whitespace is shown when wrapping a text object.
Definition SDL3pp_ttf.h:2912
void GetSize(int *w, int *h) const
Get the size of a text object.
Definition SDL3pp_ttf.h:3057
void SetWrapWidth(int wrap_width)
Set whether wrapping is enabled on a text object.
Definition SDL3pp_ttf.h:2847
FontRef GetFont() const
Get the font used by a text object.
Definition SDL3pp_ttf.h:2544
int GetNumLines() const
The number of lines in the text, 0 if it's empty.
Definition SDL3pp_ttf.h:3277
void Update()
Update the layout of a text object.
Definition SDL3pp_ttf.h:3266
Point GetPosition() const
Get the position of a text object.
Definition SDL3pp_ttf.h:2802
void DrawSurface(Point p, SurfaceRef surface) const
Draw text to an SDL surface.
Definition SDL3pp_ttf.h:2372
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:3272
void SetEngine(TextEngineBase &engine)
Set the text engine used by a text object.
Definition SDL3pp_ttf.h:2486
void DeleteString(int offset, int length=-1)
Delete UTF-8 text from a text object.
Definition SDL3pp_ttf.h:3010
void GetSubStringForPoint(Point p, SubString *substring) const
Get the portion of a text string that is closest to a point.
Definition SDL3pp_ttf.h:3206
FColor GetColor() const
Get the color of a text object.
Definition SDL3pp_ttf.h:2672
SubStringIterator begin() const
Get iterator to first substring.
Definition SDL3pp_ttf.h:3642
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:3166
TextBase(TextEngineBase &engine, FontRef font, std::string_view text)
Create a text object from UTF-8 text and a text engine.
Definition SDL3pp_ttf.h:2449
int GetWrapWidth() const
Get whether wrapping is enabled on a text object.
Definition SDL3pp_ttf.h:2866
void GetColor(FColor *c) const
Get the color of a text object.
Definition SDL3pp_ttf.h:2713
void SetScript(Uint32 script)
Set the script to be used for text shaping a text object.
Definition SDL3pp_ttf.h:2595
void GetPreviousSubString(const SubString &substring, SubString *previous) const
Get the previous substring in a text object.
Definition SDL3pp_ttf.h:3226
SubStringIterator GetSubStringForLine(int line) const
Get iterator to substring of a text object that contains the given line.
Definition SDL3pp_ttf.h:3656
void GetNextSubString(const SubString &substring, SubString *next) const
Get the next substring in a text object.
Definition SDL3pp_ttf.h:3247
GPUAtlasDrawSequence * GetGPUDrawData() const
Get the geometry data needed for drawing the text.
Definition SDL3pp_ttf.h:2427
void AppendString(std::string_view string)
Append UTF-8 text to a text object.
Definition SDL3pp_ttf.h:2983
void GetSubString(int offset, SubString *substring) const
Get the substring of a text object that surrounds a text offset.
Definition SDL3pp_ttf.h:3081
SubStringIterator GetSubStringForPoint(Point p) const
Get the portion of a text string that is closest to a point.
Definition SDL3pp_ttf.h:3663
Direction GetDirection() const
Get the direction to be used for text shaping a text object.
Definition SDL3pp_ttf.h:2577
TextEngineRef GetEngine() const
Get the text engine used by a text object.
Definition SDL3pp_ttf.h:2504
bool SetPosition(Point p)
Set the position of a text object.
Definition SDL3pp_ttf.h:2786
void InsertString(int offset, std::string_view string)
Insert UTF-8 text into a text object.
Definition SDL3pp_ttf.h:2960
bool GetPosition(int *x, int *y) const
Get the position of a text object.
Definition SDL3pp_ttf.h:2826
void GetColor(Color *c) const
Get the color of a text object.
Definition SDL3pp_ttf.h:2693
void GetSubStringForLine(int line, SubString *substring) const
Get the substring of a text object that contains the given line.
Definition SDL3pp_ttf.h:3131
Point GetSize() const
Get the size of a text object.
Definition SDL3pp_ttf.h:3031
bool SetFont(FontBase &font)
Set the font used by a text object.
Definition SDL3pp_ttf.h:2529
PropertiesRef GetProperties() const
Get the properties associated with a text object.
Definition SDL3pp_ttf.h:2466
void GetColor(float *r, float *g, float *b, float *a) const
Get the color of a text object.
Definition SDL3pp_ttf.h:2764
void SetDirection(Direction direction)
Set the direction to be used for text shaping a text object.
Definition SDL3pp_ttf.h:2560
void SetColor(Color c)
Set the color of a text object.
Definition SDL3pp_ttf.h:2635
Uint32 GetScript() const
Get the script used for text shaping a text object.
Definition SDL3pp_ttf.h:2617
void SetString(std::string_view string)
Set the UTF-8 text used by a text object.
Definition SDL3pp_ttf.h:2934
SubStringIterator end() const
Get iterator to one past last substring.
Definition SDL3pp_ttf.h:3649
void SetWrapWhitespaceVisible(bool visible)
Set whether whitespace should be visible when wrapping a text object.
Definition SDL3pp_ttf.h:2894
void SetColor(FColor c)
Set the color of a text object.
Definition SDL3pp_ttf.h:2656
void DrawRenderer(FPoint p) const
Draw text to an SDL renderer.
Definition SDL3pp_ttf.h:2396
A text engine used to create text objects.
Definition SDL3pp_ttf.h:2030
void SetGPUWinding(GPUTextEngineWinding winding)
Sets the winding order of the vertices returned by TextBase.GetGPUDrawData for a particular GPU text ...
Definition SDL3pp_ttf.h:2059
void(* m_destroy)(TTF_TextEngine *engine)
Custom destroyer.
Definition SDL3pp_ttf.h:2035
constexpr TextEngineBase(TTF_TextEngine *engine, void(*destroy)(TTF_TextEngine *engine))
Create from engine and custom destroyer.
Definition SDL3pp_ttf.h:2039
GPUTextEngineWinding GetGPUWinding() const
Get the winding order of the vertices returned by TextBase.GetGPUDrawData for a particular GPU text e...
Definition SDL3pp_ttf.h:2078
Handle to a non owned textEngine.
Definition SDL3pp_ttf.h:2093
constexpr TextEngineRef(TextEngineRef &&other)
Move constructor.
Definition SDL3pp_ttf.h:2107
constexpr ~TextEngineRef()=default
Default constructor.
void reset(TTF_TextEngine *newResource={})
frees up TextEngineBase.
Definition SDL3pp_ttf.h:2131
TextEngineRef & operator=(TextEngineRef other)
Assignment operator.
Definition SDL3pp_ttf.h:2120
constexpr TextEngineRef(const TextEngineRef &other)
Copy constructor.
Definition SDL3pp_ttf.h:2099
Handle to an owned textEngine.
Definition SDL3pp_ttf.h:2148
~TextEngine()
Frees up resource when object goes out of scope.
Definition SDL3pp_ttf.h:2169
TextEngine & operator=(TextEngine other)
Assignment operator.
Definition SDL3pp_ttf.h:2174
constexpr TextEngine(TTF_TextEngine *resource={})
Constructs from the underlying resource.
Definition SDL3pp_ttf.h:2154
constexpr TextEngine(TextEngine &&other)=default
Move constructor.
Handle to a non owned text.
Definition SDL3pp_ttf.h:3289
TextRef & operator=(TextRef other)
Assignment operator.
Definition SDL3pp_ttf.h:3316
constexpr ~TextRef()=default
Default constructor.
void reset(TTF_Text *newResource={})
Destroy a text object created by a text engine.
Definition SDL3pp_ttf.h:3332
constexpr TextRef(TextRef &&other)
Move constructor.
Definition SDL3pp_ttf.h:3303
constexpr TextRef(const TextRef &other)
Copy constructor.
Definition SDL3pp_ttf.h:3295
Handle to an owned text.
Definition SDL3pp_ttf.h:3347
Text & operator=(Text other)
Assignment operator.
Definition SDL3pp_ttf.h:3373
constexpr Text(Text &&other)=default
Move constructor.
~Text()
Frees up resource when object goes out of scope.
Definition SDL3pp_ttf.h:3368
constexpr Text(TTF_Text *resource={})
Constructs from the underlying resource.
Definition SDL3pp_ttf.h:3353
Flag to init TTF.
Definition SDL3pp_ttf.h:39