5#include "SDL3pp_render.h"
6#include "SDL3pp_surface.h"
7#include "SDL3pp_version.h"
8#include "SDL3pp_video.h"
10#if defined(SDL3PP_ENABLE_TTF) || defined(SDL3PP_DOC)
12#include <SDL3_ttf/SDL_ttf.h>
60 constexpr explicit operator bool()
const {
return !!
value; }
96 constexpr explicit operator bool()
const {
return !!
value; }
115#define SDL_TTF_MAJOR_VERSION
117#define SDL_TTF_MINOR_VERSION
119#define SDL_TTF_MICRO_VERSION
126#define SDL_TTF_VERSION \
128 SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_MICRO_VERSION)
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))
152inline int Version() {
return TTF_Version(); }
191inline void Quit() { TTF_Quit(); }
215inline int WasInit() {
return TTF_WasInit(); }
236 TTF_GetFreeTypeVersion(major, minor, patch);
254 TTF_GetHarfBuzzVersion(major, minor, patch);
281 TTF_STYLE_STRIKETHROUGH;
297#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
329 TTF_HORIZONTAL_ALIGN_INVALID;
332 TTF_HORIZONTAL_ALIGN_LEFT;
335 TTF_HORIZONTAL_ALIGN_CENTER;
338 TTF_HORIZONTAL_ALIGN_RIGHT;
394 constexpr Font(std::nullptr_t =
nullptr) noexcept
395 : m_resource(
nullptr)
407 : m_resource(resource)
413 constexpr Font(
const Font& other)
noexcept =
default;
418 :
Font(other.release())
517 ~Font() { TTF_CloseFont(m_resource); }
522 std::swap(m_resource, other.m_resource);
532 constexpr FontRaw get() const noexcept {
return m_resource; }
538 m_resource =
nullptr;
546 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
716 void SetSizeDPI(
float ptsize,
int hdpi,
int vdpi);
748 void GetDPI(
int* hdpi,
int* vdpi)
const;
911 void SetSDF(
bool enabled);
926#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
1324 int* advance)
const;
1379 void GetStringSize(std::string_view text,
int* w,
int* h)
const;
1460 int* measured_width,
1461 size_t* measured_length)
const;
1530 int wrapLength)
const;
1631 int wrap_width)
const;
1729 int wrap_width)
const;
1829 int wrap_width)
const;
1891 :
Font(resource.get())
1951 return Font(std::move(file), ptsize);
1981 return Font(src, ptsize, closeio);
1985 : m_resource(
CheckError(TTF_OpenFont(file, ptsize)))
1990 : m_resource(
CheckError(TTF_OpenFontIO(src, closeio, ptsize)))
1995 : m_resource(
CheckError(TTF_OpenFontWithProperties(props)))
2043namespace prop::Font {
2045constexpr auto CREATE_FILENAME_STRING = TTF_PROP_FONT_CREATE_FILENAME_STRING;
2047constexpr auto CREATE_IOSTREAM_POINTER = TTF_PROP_FONT_CREATE_IOSTREAM_POINTER;
2049constexpr auto CREATE_IOSTREAM_OFFSET_NUMBER =
2050 TTF_PROP_FONT_CREATE_IOSTREAM_OFFSET_NUMBER;
2052constexpr auto CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN =
2053 TTF_PROP_FONT_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN;
2055constexpr auto CREATE_SIZE_FLOAT = TTF_PROP_FONT_CREATE_SIZE_FLOAT;
2057constexpr auto CREATE_FACE_NUMBER = TTF_PROP_FONT_CREATE_FACE_NUMBER;
2059constexpr auto CREATE_HORIZONTAL_DPI_NUMBER =
2060 TTF_PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER;
2062constexpr auto CREATE_VERTICAL_DPI_NUMBER =
2063 TTF_PROP_FONT_CREATE_VERTICAL_DPI_NUMBER;
2065#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
2067constexpr auto CREATE_EXISTING_FONT_POINTER =
2068 TTF_PROP_FONT_CREATE_EXISTING_FONT;
2072constexpr auto OUTLINE_LINE_CAP_NUMBER = TTF_PROP_FONT_OUTLINE_LINE_CAP_NUMBER;
2074constexpr auto OUTLINE_LINE_JOIN_NUMBER =
2075 TTF_PROP_FONT_OUTLINE_LINE_JOIN_NUMBER;
2077constexpr auto OUTLINE_MITER_LIMIT_NUMBER =
2078 TTF_PROP_FONT_OUTLINE_MITER_LIMIT_NUMBER;
2130 return {
CheckError(TTF_GetFontProperties(font))};
2155 return TTF_GetFontGeneration(font);
2187 CheckError(TTF_AddFallbackFont(font, fallback));
2213 TTF_RemoveFallbackFont(font, fallback);
2289 CheckError(TTF_SetFontSizeDPI(font, ptsize, hdpi, vdpi));
2333 CheckError(TTF_GetFontDPI(font, hdpi, vdpi));
2367 TTF_SetFontStyle(font, style);
2397 return TTF_GetFontStyle(font);
2428 CheckError(TTF_SetFontOutline(font, outline));
2478 TTF_SetFontHinting(font, hinting);
2526 return TTF_GetFontHinting(font);
2580#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
2598 TTF_FONT_WEIGHT_THIN;
2601 TTF_FONT_WEIGHT_EXTRA_LIGHT;
2604 TTF_FONT_WEIGHT_LIGHT;
2607 TTF_FONT_WEIGHT_NORMAL;
2610 TTF_FONT_WEIGHT_MEDIUM;
2613 TTF_FONT_WEIGHT_SEMI_BOLD;
2616 TTF_FONT_WEIGHT_BOLD;
2619 TTF_FONT_WEIGHT_EXTRA_BOLD;
2622 TTF_FONT_WEIGHT_BLACK;
2625 TTF_FONT_WEIGHT_EXTRA_BLACK;
2646 TTF_SetFontWrapAlignment(font, align);
2668 return TTF_GetFontWrapAlignment(font);
2741 TTF_SetFontLineSkip(font, lineskip);
2790 TTF_SetFontKerning(font, enabled);
2832 return TTF_FontIsFixedWidth(font);
2876 return TTF_GetFontFamilyName(font);
2902 return TTF_GetFontStyleName(font);
2929 CheckError(TTF_SetFontDirection(font, direction));
2952 return TTF_GetFontDirection(font);
2974 return TTF_StringToTag(
string);
2994 TTF_TagToString(tag,
string, size);
3088 CheckError(TTF_SetFontLanguage(font, language_bcp47));
3110 return TTF_FontHasGlyph(font, ch);
3166 CheckError(TTF_GetGlyphImageForIndex(font, glyph_index, image_type)));
3211 CheckError(TTF_GetGlyphMetrics(font, ch, minx, maxx, miny, maxy, advance));
3240 if (
int r; TTF_GetGlyphKerning(font, previous_ch, ch, &r))
return r;
3268 CheckError(TTF_GetStringSize(font, text.data(), text.size(), w, h));
3300 std::string_view text,
3306 TTF_GetStringSizeWrapped(font, text.data(), text.size(), wrap_width, w, h));
3341 std::string_view text,
3343 int* measured_width,
3344 size_t* measured_length)
3356 int* measured_width,
3357 size_t* measured_length)
const
3360 m_resource, text, max_width, measured_width, measured_length);
3398 return Surface{TTF_RenderText_Solid(font, text.data(), text.size(), fg)};
3439 std::string_view text,
3443 return Surface(TTF_RenderText_Solid_Wrapped(
3444 font, text.data(), text.size(), fg, wrapLength));
3449 int wrapLength)
const
3483 return Surface(TTF_RenderGlyph_Solid(font, ch, fg));
3526 std::string_view text,
3530 return Surface(TTF_RenderText_Shaded(font, text.data(), text.size(), fg, bg));
3575 std::string_view text,
3580 return Surface(TTF_RenderText_Shaded_Wrapped(
3581 font, text.data(), text.size(), fg, bg, wrap_width));
3587 int wrap_width)
const
3626 return Surface(TTF_RenderGlyph_Shaded(font, ch, fg, bg));
3670 return Surface(TTF_RenderText_Blended(font, text.data(), text.size(), fg));
3711 std::string_view text,
3715 return Surface(TTF_RenderText_Blended_Wrapped(
3716 font, text.data(), text.size(), fg, wrap_width));
3721 int wrap_width)
const
3755 return Surface(TTF_RenderGlyph_Blended(font, ch, fg));
3797 std::string_view text,
3801 return Surface(TTF_RenderText_LCD(font, text.data(), text.size(), fg, bg));
3845 std::string_view text,
3850 return Surface(TTF_RenderText_LCD_Wrapped(
3851 font, text.data(), text.size(), fg, bg, wrap_width));
3857 int wrap_width)
const
3896 return Surface(TTF_RenderGlyph_LCD(font, ch, fg, bg));
3914 TTF_SUBSTRING_DIRECTION_MASK;
3918 TTF_SUBSTRING_TEXT_START;
3928 TTF_SUBSTRING_TEXT_END;
3938 TTF_GPU_TEXTENGINE_WINDING_INVALID;
3941 TTF_GPU_TEXTENGINE_WINDING_CLOCKWISE;
3944 TTF_GPU_TEXTENGINE_WINDING_COUNTER_CLOCKWISE;
3971 : m_resource(
nullptr)
3983 : m_resource(resource)
4004 std::swap(m_resource, other.m_resource);
4019 auto r = m_resource;
4020 m_resource =
nullptr;
4028 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
4298 constexpr Text(std::nullptr_t =
nullptr) noexcept
4299 : m_resource(
nullptr)
4311 : m_resource(resource)
4322 :
Text(other.release())
4359 ~Text() { TTF_DestroyText(m_resource); }
4364 std::swap(m_resource, other.m_resource);
4379 auto r = m_resource;
4380 m_resource =
nullptr;
4388 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
4716 void GetColorFloat(
float* r,
float* g,
float* b,
float* a)
const;
4877 void SetString(std::string_view
string);
4900 void InsertString(
int offset, std::string_view
string);
4962 void GetSize(
int* w,
int* h)
const;
5175 const char*
GetText()
const {
return m_resource->text; }
5210 :
Text(resource.get())
5272 constexpr operator bool()
const {
return bool(m_text); }
5283 return m_subString.offset == other.m_subString.offset;
5364 CheckError(TTF_DrawSurfaceText(text, p.x, p.y, surface));
5390 TTF_DestroySurfaceTextEngine(engine);
5420 :
TextEngine(TTF_CreateRendererTextEngine(renderer))
5425 :
TextEngine(TTF_CreateRendererTextEngineWithProperties(props))
5459namespace prop::RendererTextEngine {
5461#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
5463constexpr auto RENDERER_POINTER = TTF_PROP_RENDERER_TEXT_ENGINE_RENDERER;
5465constexpr auto ATLAS_TEXTURE_SIZE_NUMBER =
5466 TTF_PROP_RENDERER_TEXT_ENGINE_ATLAS_TEXTURE_SIZE;
5494 CheckError(TTF_DrawRendererText(text, p.x, p.y));
5520 TTF_DestroyRendererTextEngine(engine);
5550 :
TextEngine(TTF_CreateGPUTextEngine(device))
5555 :
TextEngine(TTF_CreateGPUTextEngineWithProperties(props))
5588namespace prop::GpuTextEngine {
5590#if SDL_TTF_VERSION_ATLEAST(3, 2, 2)
5592constexpr auto DEVICE_POINTER = TTF_PROP_GPU_TEXT_ENGINE_DEVICE;
5594constexpr auto ATLAS_TEXTURE_SIZE_NUMBER =
5595 TTF_PROP_GPU_TEXT_ENGINE_ATLAS_TEXTURE_SIZE;
5629 return TTF_GetGPUTextDrawData(text);
5654 TTF_DestroyGPUTextEngine(engine);
5677 TTF_SetGPUTextEngineWinding(engine, winding);
5703 return TTF_GetGPUTextEngineWinding(engine);
5730 std::string_view text)
5732 return Text(engine, font, text);
5737 return Text(m_resource, font, text);
5741 : m_resource(TTF_CreateText(engine, font, text.data(), text.size()))
5759 return {
CheckError(TTF_GetTextProperties(text))};
5840 return TTF_SetTextFont(text, font);
5886 CheckError(TTF_SetTextDirection(text, direction));
5909 return TTF_GetTextDirection(text);
5963 return TTF_GetTextScript(text);
5987 CheckError(TTF_SetTextColor(text, c.r, c.g, c.b, c.a));
6011 CheckError(TTF_SetTextColorFloat(text, c.r, c.g, c.b, c.a));
6047 CheckError(TTF_GetTextColor(text, r, g, b, a));
6107 CheckError(TTF_GetTextColorFloat(text, r, g, b, a));
6163 CheckError(TTF_SetTextPosition(text, p.x, p.y));
6244 CheckError(TTF_SetTextWrapWidth(text, wrap_width));
6301 CheckError(TTF_SetTextWrapWhitespaceVisible(text, visible));
6324 return TTF_TextWrapWhitespaceVisible(text);
6352 CheckError(TTF_SetTextString(text,
string.data(),
string.size()));
6384 CheckError(TTF_InsertTextString(text, offset,
string.data(),
string.size()));
6412 CheckError(TTF_AppendTextString(text,
string.data(),
string.size()));
6445 CheckError(TTF_DeleteTextString(text, offset, length));
6528 CheckError(TTF_GetTextSubString(text, offset, substring));
6559 CheckError(TTF_GetTextSubStringForLine(text, line, substring));
6587 auto data = TTF_GetTextSubStringsForRange(text, offset, length, &count);
6618 CheckError(TTF_GetTextSubStringForPoint(text, p.x, p.y, substring));
6647 CheckError(TTF_GetPreviousTextSubString(text, &substring, previous));
6676 CheckError(TTF_GetNextTextSubString(text, &substring, next));
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