-
Notifications
You must be signed in to change notification settings - Fork 29
API TTF
Font loading, text shaping, measurement, and rendering functions.
- Functions: 125
- Functions with XML docs: 125
public static bool AddFallbackFont(IntPtr font, IntPtr fallback);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_AddFallbackFont(TTF_Font *font, TTF_Font *fallback);
Add a fallback font.
Add a font that will be used for glyphs that are not in the current font. The fallback font should have the same size and style as the current font.
If there are multiple fallback fonts, they are used in the order added.
This updates any TTF_Text objects using this font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to modify. |
fallback |
IntPtr |
the font to add as a fallback. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created both fonts.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.AddFallbackFont(System.IntPtr,System.IntPtr)
public static bool AppendTextString(IntPtr text, string string, UIntPtr length);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_AppendTextString(TTF_Text *text, const char *string, size_t length);
Append UTF-8 text to a text object. This function may cause the internal text representation to be rebuilt.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to modify. |
string |
string |
the UTF-8 text to insert. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.AppendTextString(System.IntPtr,System.String,System.UIntPtr)
public static void ClearFallbackFonts(IntPtr font);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_ClearFallbackFonts(TTF_Font *font);
Remove all fallback fonts.
This updates any TTF_Text objects using this font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to modify. |
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.ClearFallbackFonts(System.IntPtr)
public static void CloseFont(IntPtr font);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_CloseFont(TTF_Font *font);
Dispose of a previously-created font.
Call this when done with a font. This function will free any resources associated with it. It is safe to call this function on null, for example on the result of a failed call to TTF.OpenFont.
The font is not valid after being passed to this function. String pointers from functions that return information on this font, such as TTF.GetFontFamilyName and TTF.GetFontStyleName, are no longer valid after this call, as well.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to dispose of. |
Thread safety
This function should not be called while any other thread is using the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.CloseFont(System.IntPtr)
public static IntPtr CopyFont(IntPtr existingFont);SDL declaration
extern SDL_DECLSPEC TTF_Font * SDLCALL TTF_CopyFont(TTF_Font *existing_font);
Create a copy of an existing font.
The copy will be distinct from the original, but will share the font file and have the same size and style as the original.
When done with the returned TTF_Font, use TTF.CloseFont to dispose of it.
Parameters
| Name | Type | Description |
|---|---|---|
existingFont |
IntPtr |
the font to copy. |
Returns
a valid TTF_Font, or null on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the original font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.CopyFont(System.IntPtr)
public static IntPtr CreateGPUTextEngine(IntPtr device);SDL declaration
extern SDL_DECLSPEC TTF_TextEngine * SDLCALL TTF_CreateGPUTextEngine(SDL_GPUDevice *device);
Create a text engine for drawing text with the SDL GPU API.
Parameters
| Name | Type | Description |
|---|---|---|
device |
IntPtr |
the SDL_GPUDevice to use for creating textures and drawing text. |
Returns
a TTF_TextEngine object or null on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the device.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.CreateGPUTextEngine(System.IntPtr)
public static IntPtr CreateGPUTextEngineWithProperties(uint props);SDL declaration
extern SDL_DECLSPEC TTF_TextEngine * SDLCALL TTF_CreateGPUTextEngineWithProperties(SDL_PropertiesID props);
Create a text engine for drawing text with the SDL GPU API, with the specified properties.
These are the supported properties:
-
TTF.Props.GPUTextEngineDevice: the SDL_GPUDevice to use for creating textures and drawing text. -
TTF.Props.GPUTextEngineAtlasTextureSize: the size of the texture atlas
Parameters
| Name | Type | Description |
|---|---|---|
props |
uint |
the properties to use. |
Returns
a TTF_TextEngine object or null on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the device.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.CreateGPUTextEngineWithProperties(System.UInt32)
public static IntPtr CreateRendererTextEngine(IntPtr renderer);SDL declaration
extern SDL_DECLSPEC TTF_TextEngine * SDLCALL TTF_CreateRendererTextEngine(SDL_Renderer *renderer);
Create a text engine for drawing text on an SDL renderer.
Parameters
| Name | Type | Description |
|---|---|---|
renderer |
IntPtr |
the renderer to use for creating textures and drawing text. |
Returns
a TTF_TextEngine object or null on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the renderer.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.CreateRendererTextEngine(System.IntPtr)
public static IntPtr CreateRendererTextEngineWithProperties(uint props);SDL declaration
extern SDL_DECLSPEC TTF_TextEngine * SDLCALL TTF_CreateRendererTextEngineWithProperties(SDL_PropertiesID props);
Create a text engine for drawing text on an SDL renderer, with the specified properties.
These are the supported properties:
-
TTF.Props.RendererTextEngineRenderer: the renderer to use for creating textures and drawing text -
TTF.Props.RendererTextEngineAtlasTextureSize: the size of the texture atlas
Parameters
| Name | Type | Description |
|---|---|---|
props |
uint |
the properties to use. |
Returns
a TTF_TextEngine object or null on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the renderer.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.CreateRendererTextEngineWithProperties(System.UInt32)
public static IntPtr CreateSurfaceTextEngine();SDL declaration
extern SDL_DECLSPEC TTF_TextEngine * SDLCALL TTF_CreateSurfaceTextEngine(void);
Create a text engine for drawing text on SDL surfaces.
Returns
a TTF_TextEngine object or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.CreateSurfaceTextEngine
public static IntPtr CreateText(IntPtr engine, IntPtr font, string text, UIntPtr length);SDL declaration
extern SDL_DECLSPEC TTF_Text * SDLCALL TTF_CreateText(TTF_TextEngine *engine, TTF_Font *font, const char *text, size_t length);
Create a text object from UTF-8 text and a text engine.
Parameters
| Name | Type | Description |
|---|---|---|
engine |
IntPtr |
the text engine to use when creating the text object, may be null. |
font |
IntPtr |
the font to render with. |
text |
string |
the text to use, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
Returns
a TTF.TTFText object or null on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font and text engine.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.CreateText(System.IntPtr,System.IntPtr,System.String,System.UIntPtr)
public static bool DeleteTextString(IntPtr text, int offset, int length);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_DeleteTextString(TTF_Text *text, int offset, int length);
Delete UTF-8 text from a text object. This function may cause the internal text representation to be rebuilt.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to modify. |
offset |
int |
the offset, in bytes, from the beginning of the string if >= 0, the offset from the end of the string if < 0. Note that this does not do UTF-8 validation, so you should only delete at UTF-8 sequence boundaries. |
length |
int |
the length of text to delete, in bytes, or -1 for the remainder of the string. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.DeleteTextString(System.IntPtr,System.Int32,System.Int32)
public static void DestroyGPUTextEngine(IntPtr engine);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_DestroyGPUTextEngine(TTF_TextEngine *engine);
Destroy a text engine created for drawing text with the SDL GPU API.
All text created by this engine should be destroyed before calling this function.
Parameters
| Name | Type | Description |
|---|---|---|
engine |
IntPtr |
a TTF_TextEngine object created with TTF.CreateGPUTextEngine. |
Thread safety
This function should be called on the thread that created the engine.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.DestroyGPUTextEngine(System.IntPtr)
public static void DestroyRendererTextEngine(IntPtr engine);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_DestroyRendererTextEngine(TTF_TextEngine *engine);
Destroy a text engine created for drawing text on an SDL renderer.
All text created by this engine should be destroyed before calling this function.
Parameters
| Name | Type | Description |
|---|---|---|
engine |
IntPtr |
a TTF_TextEngine object created with TTF.CreateRendererTextEngine. |
Thread safety
This function should be called on the thread that created the engine.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.DestroyRendererTextEngine(System.IntPtr)
public static void DestroySurfaceTextEngine(IntPtr engine);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_DestroySurfaceTextEngine(TTF_TextEngine *engine);
Destroy a text engine created for drawing text on SDL surfaces.
All text created by this engine should be destroyed before calling this function.
Parameters
| Name | Type | Description |
|---|---|---|
engine |
IntPtr |
a TTF_TextEngine object created with TTF.CreateSurfaceTextEngine. |
Thread safety
This function should be called on the thread that created the engine.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.DestroySurfaceTextEngine(System.IntPtr)
public static void DestroyText(IntPtr text);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_DestroyText(TTF_Text *text);
Destroy a text object created by a text engine.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the text to destroy. |
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.DestroyText(System.IntPtr)
public static bool DrawRendererText(IntPtr text, float x, float y);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_DrawRendererText(TTF_Text *text, float x, float y);
Draw text to an SDL renderer.
text must have been created using a TTF_TextEngine from TTF.CreateRendererTextEngine, and will draw using the renderer passed to that function.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the text to draw. |
x |
float |
the x coordinate in pixels, positive from the left edge towards the right. |
y |
float |
the y coordinate in pixels, positive from the top edge towards the bottom. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.DrawRendererText(System.IntPtr,System.Single,System.Single)
public static bool DrawSurfaceText(IntPtr text, int x, int y, IntPtr surface);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_DrawSurfaceText(TTF_Text *text, int x, int y, SDL_Surface *surface);
Draw text to an SDL surface.
text must have been created using a TTF_TextEngine from TTF.CreateSurfaceTextEngine.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the text to draw. |
x |
int |
the x coordinate in pixels, positive from the left edge towards the right. |
y |
int |
the y coordinate in pixels, positive from the top edge towards the bottom. |
surface |
IntPtr |
the surface to draw on. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.DrawSurfaceText(System.IntPtr,System.Int32,System.Int32,System.IntPtr)
public static bool FontHasGlyph(IntPtr font, uint ch);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_FontHasGlyph(TTF_Font *font, Uint32 ch);
Check whether a glyph is provided by the font for a UNICODE codepoint.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
ch |
uint |
the codepoint to check. |
Returns
true if font provides a glyph for this character, false if not.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.FontHasGlyph(System.IntPtr,System.UInt32)
public static bool FontIsFixedWidth(IntPtr font);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_FontIsFixedWidth(const TTF_Font *font);
Query whether a font is fixed-width.
A "fixed-width" font means all glyphs are the same width across; a lowercase 'i' will be the same size across as a capital 'W', for example. This is common for terminals and text editors, and other apps that treat text as a grid. Most other things (WYSIWYG word processors, web pages, etc) are more likely to not be fixed-width in most cases.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
true if the font is fixed-width, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.FontIsFixedWidth(System.IntPtr)
public static bool FontIsScalable(IntPtr font);SDL declaration
extern SDL_DECLSPEC bool TTF_FontIsScalable(const TTF_Font *font);
Query whether a font is scalable or not.
Scalability lets us distinguish between outline and bitmap fonts.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
true if the font is scalable, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.FontIsScalable(System.IntPtr)
public static int GetFontAscent(IntPtr font);SDL declaration
extern SDL_DECLSPEC int SDLCALL TTF_GetFontAscent(const TTF_Font *font);
Query the offset from the baseline to the top of a font.
This is a positive value, relative to the baseline.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
the font's ascent.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontAscent(System.IntPtr)
public static int GetFontDescent(IntPtr font);SDL declaration
extern SDL_DECLSPEC int SDLCALL TTF_GetFontDescent(const TTF_Font *font);
Query the offset from the baseline to the bottom of a font.
This is a negative value, relative to the baseline.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
the font's descent.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontDescent(System.IntPtr)
public static TTF.Direction GetFontDirection(IntPtr font);SDL declaration
extern SDL_DECLSPEC TTF_Direction SDLCALL TTF_GetFontDirection(TTF_Font *font);
Get the direction to be used for text shaping by a font.
This defaults to TTF.Direction.Invalid if it hasn't been set.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
the direction to be used for text shaping.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontDirection(System.IntPtr)
public static bool GetFontDPI(IntPtr font, out int hdpi, out int vdpi);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetFontDPI(TTF_Font *font, int *hdpi, int *vdpi);
Get font target resolutions, in dots per inch.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
hdpi |
out int |
a pointer filled in with the target horizontal DPI. |
vdpi |
out int |
a pointer filled in with the target vertical DPI. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontDPI(System.IntPtr,System.Int32@,System.Int32@)
public static string GetFontFamilyName(IntPtr font);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL TTF_GetFontFamilyName(const TTF_Font *font);
Query a font's family name.
This string is dictated by the contents of the font file.
Note that the returned string is to internal storage, and should not be modified or free'd by the caller. The string becomes invalid, with the rest of the font, when font is handed to TTF.CloseFont.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
the font's family name.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontFamilyName(System.IntPtr)
public static uint GetFontGeneration(IntPtr font);SDL declaration
extern SDL_DECLSPEC Uint32 SDLCALL TTF_GetFontGeneration(TTF_Font *font);
Get the font generation.
The generation is incremented each time font properties change that require rebuilding glyphs, such as style, size, etc.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
the font generation or 0 on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontGeneration(System.IntPtr)
public static int GetFontHeight(IntPtr font);SDL declaration
extern SDL_DECLSPEC int SDLCALL TTF_GetFontHeight(const TTF_Font *font);
Query the total height of a font.
This is usually equal to point size.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
the font's height.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontHeight(System.IntPtr)
public static TTF.HintingFlags GetFontHinting(IntPtr font);SDL declaration
extern SDL_DECLSPEC TTF_HintingFlags SDLCALL TTF_GetFontHinting(const TTF_Font *font);
Query a font's current FreeType hinter setting.
The hinter setting is a single value:
TTF.HintingFlags.NormalTTF.HintingFlags.LightTTF.HintingFlags.MonoTTF.HintingFlags.None-
TTF.HintingFlags.LightSubpixel(available in SDL_ttf 3.0.0 and later)
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
the font's current hinter value.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontHinting(System.IntPtr)
public static bool GetFontKerning(IntPtr font);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetFontKerning(const TTF_Font *font);
Query whether or not kerning is enabled for a font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
true if kerning is enabled, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontKerning(System.IntPtr)
public static int GetFontLineSkip(IntPtr font);SDL declaration
extern SDL_DECLSPEC int SDLCALL TTF_GetFontLineSkip(const TTF_Font *font);
Query the spacing between lines of text for a font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
the font's recommended spacing.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontLineSkip(System.IntPtr)
public static int GetFontOutline(IntPtr font);SDL declaration
extern SDL_DECLSPEC int SDLCALL TTF_GetFontOutline(const TTF_Font *font);
Query a font's current outline.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
the font's current outline value.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontOutline(System.IntPtr)
public static uint GetFontProperties(IntPtr font);SDL declaration
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL TTF_GetFontProperties(TTF_Font *font);
Get the properties associated with a font.
The following read-write properties are provided by SDL:
-
TTF.Props.FontOutlineLineCapNumber: The FT_Stroker_LineCap value used when setting the font outline, defaults toFT_STROKER_LINECAP_ROUND. -
TTF.Props.FontOutlineLineJoinNumber: The FT_Stroker_LineJoin value used when setting the font outline, defaults toFT_STROKER_LINEJOIN_ROUND. -
TTF.Props.FontOutlineMiterLimitNumber: The FT_Fixed miter limit used when setting the font outline, defaults to 0.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
a valid property ID on success or 0 on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontProperties(System.IntPtr)
public static uint GetFontScript(IntPtr font);SDL declaration
extern SDL_DECLSPEC Uint32 SDLCALL TTF_GetFontScript(TTF_Font *font);
Get the script used for text shaping a font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
an ISO 15924 code or 0 if a script hasn't been set.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontScript(System.IntPtr)
public static bool GetFontSDF(IntPtr font);SDL declaration
extern SDL_DECLSPEC bool TTF_GetFontSDF(const TTF_Font *font);
Query whether Signed Distance Field rendering is enabled for a font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
true if enabled, false otherwise.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontSDF(System.IntPtr)
public static float GetFontSize(IntPtr font);SDL declaration
extern SDL_DECLSPEC float SDLCALL TTF_GetFontSize(TTF_Font *font);
Get the size of a font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
the size of the font, or 0.0f on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontSize(System.IntPtr)
public static TTF.FontStyleFlags GetFontStyle(IntPtr font);SDL declaration
extern SDL_DECLSPEC TTF_FontStyleFlags SDLCALL TTF_GetFontStyle(const TTF_Font *font);
Query a font's current style.
The font styles are a set of bit flags, OR'd together:
-
TTF.FontStyleFlags.Normal(is zero) TTF.FontStyleFlags.BoldTTF.FontStyleFlags.ItalicTTF.FontStyleFlags.UnderlineTTF.FontStyleFlags.Strikethrough
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
the current font style, as a set of bit flags.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontStyle(System.IntPtr)
public static string GetFontStyleName(IntPtr font);SDL declaration
extern SDL_DECLSPEC const char * SDLCALL TTF_GetFontStyleName(const TTF_Font *font);
Query a font's style name.
This string is dictated by the contents of the font file.
Note that the returned string is to internal storage, and should not be modified or free'd by the caller. The string becomes invalid, with the rest of the font, when font is handed to TTF.CloseFont.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
the font's style name.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontStyleName(System.IntPtr)
public static int GetFontWeight(in IntPtr font);SDL declaration
extern SDL_DECLSPEC int SDLCALL TTF_GetFontWeight(const TTF_Font *font);
Query a font's weight, in terms of the lightness/heaviness of the strokes.
Parameters
| Name | Type | Description |
|---|---|---|
font |
in IntPtr |
the font to query. |
Returns
the font's current weight.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.2.2.
XML member id: M:SDL3.TTF.GetFontWeight(System.IntPtr@)
public static TTF.HorizontalAlignment GetFontWrapAlignment(IntPtr font);SDL declaration
extern SDL_DECLSPEC TTF_HorizontalAlignment SDLCALL TTF_GetFontWrapAlignment(const TTF_Font *font);
Query a font's current wrap alignment option.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
the font's current wrap alignment option.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFontWrapAlignment(System.IntPtr)
public static void GetFreeTypeVersion(out int major, out int minor, out int patch);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_GetFreeTypeVersion(int *major, int *minor, int *patch);
Query the version of the FreeType library in use.
TTF.Init should be called before calling this function.
Parameters
| Name | Type | Description |
|---|---|---|
major |
out int |
to be filled in with the major version number. Can be null. |
minor |
out int |
to be filled in with the minor version number. Can be null.. |
patch |
out int |
to be filled in with the param version number. Can be null.. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetFreeTypeVersion(System.Int32@,System.Int32@,System.Int32@)
public static IntPtr GetGlyphImage(IntPtr font, uint ch, IntPtr imageType);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_GetGlyphImage(TTF_Font *font, Uint32 ch, TTF_ImageType *image_type);
Get the pixel image for a UNICODE codepoint.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
ch |
uint |
the codepoint to check. |
imageType |
IntPtr |
a pointer filled in with the glyph image type, may be null. |
Returns
an SDL.Surface containing the glyph, or null on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetGlyphImage(System.IntPtr,System.UInt32,System.IntPtr)
public static IntPtr GetGlyphImage(IntPtr font, uint ch, out TTF.ImageType imageType);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_GetGlyphImage(TTF_Font *font, Uint32 ch, TTF_ImageType *image_type);
Get the pixel image for a UNICODE codepoint.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
ch |
uint |
the codepoint to check. |
imageType |
out TTF.ImageType |
a pointer filled in with the glyph image type, may be null. |
Returns
an SDL.Surface containing the glyph, or null on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetGlyphImage(System.IntPtr,System.UInt32,SDL3.TTF.ImageType@)
public static IntPtr GetGlyphImageForIndex(IntPtr font, uint glyphIndex, IntPtr imageType);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_GetGlyphImageForIndex(TTF_Font *font, Uint32 glyph_index, TTF_ImageType *image_type);
Get the pixel image for a character index.
This is useful for text engine implementations, which can call this with the glyphIndex in a TTF_CopyOperation
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
glyphIndex |
uint |
the index of the glyph to return. |
imageType |
IntPtr |
a pointer filled in with the glyph image type, may be null. |
Returns
an SDL.Surface containing the glyph, or null on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetGlyphImageForIndex(System.IntPtr,System.UInt32,System.IntPtr)
public static IntPtr GetGlyphImageForIndex(IntPtr font, uint glyphIndex, out TTF.ImageType imageType);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_GetGlyphImageForIndex(TTF_Font *font, Uint32 glyph_index, TTF_ImageType *image_type);
Get the pixel image for a character index.
This is useful for text engine implementations, which can call this with the glyphIndex in a TTF_CopyOperation
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
glyphIndex |
uint |
the index of the glyph to return. |
imageType |
out TTF.ImageType |
a pointer filled in with the glyph image type, may be null. |
Returns
an SDL.Surface containing the glyph, or null on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetGlyphImageForIndex(System.IntPtr,System.UInt32,SDL3.TTF.ImageType@)
public static bool GetGlyphKerning(IntPtr font, uint previousCh, uint ch, out int kerning);SDL declaration
extern SDL_DECLSPEC bool TTF_GetGlyphKerning(TTF_Font *font, Uint32 previous_ch, Uint32 ch, int *kerning);
Query the kerning size between the glyphs of two UNICODE codepoints.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
previousCh |
uint |
the previous codepoint. |
ch |
uint |
the current codepoint. |
kerning |
out int |
a pointer filled in with the kerning size between the two glyphs, in pixels, may be null. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetGlyphKerning(System.IntPtr,System.UInt32,System.UInt32,System.Int32@)
public static bool GetGlyphMetrics(IntPtr font, uint ch, out int minx, out int maxx, out int miny, out int maxy, out int advance);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetGlyphMetrics(TTF_Font *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.
To understand what these metrics mean, here is a useful link:
https://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
ch |
uint |
the codepoint to check. |
minx |
out int |
a pointer filled in with the minimum x coordinate of the glyph from the left edge of its bounding box. This value may be negative. |
maxx |
out int |
a pointer filled in with the maximum x coordinate of the glyph from the left edge of its bounding box. |
miny |
out int |
a pointer filled in with the minimum y coordinate of the glyph from the bottom edge of its bounding box. This value may be negative. |
maxy |
out int |
a pointer filled in with the maximum y coordinate of the glyph from the bottom edge of its bounding box. |
advance |
out int |
a pointer filled in with the distance to the next glyph from the left edge of this glyph's bounding box. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetGlyphMetrics(System.IntPtr,System.UInt32,System.Int32@,System.Int32@,System.Int32@,System.Int32@,System.Int32@)
public static uint GetGlyphScript(uint ch);SDL declaration
extern SDL_DECLSPEC Uint32 SDLCALL TTF_GetGlyphScript(Uint32 ch);
Get the script used by a 32-bit codepoint.
Parameters
| Name | Type | Description |
|---|---|---|
ch |
uint |
the character code to check. |
Returns
an ISO 15924 code on success, or 0 on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetGlyphScript(System.UInt32)
public static IntPtr GetGPUTextDrawData(IntPtr text);SDL declaration
extern SDL_DECLSPEC TTF_GPUAtlasDrawSequence * SDLCALL TTF_GetGPUTextDrawData(TTF_Text *text);
Get the geometry data needed for drawing the text.
text must have been created using a TTF_TextEngine from TTF.CreateGPUTextEngine.
The positive X-axis is taken towards the right and the positive Y-axis is taken upwards for both the vertex and the texture coordinates, i.e, it follows the same convention used by the SDL_GPU API. If you want to use a different coordinate system you will need to transform the vertices yourself.
If the text looks blocky use linear filtering.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the text to draw. |
Returns
a null terminated linked list of TTF.GPUAtlasDrawSequence objects or null if the passed text is empty or in case of failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetGPUTextDrawData(System.IntPtr)
public static TTF.GPUTextEngineWinding GetGPUTextEngineWinding(IntPtr engine);SDL declaration
extern SDL_DECLSPEC TTF_GPUTextEngineWinding SDLCALL TTF_GetGPUTextEngineWinding(const TTF_TextEngine *engine);
Get the winding order of the vertices returned by TTF.GetGPUTextDrawData for a particular GPU text engine
Parameters
| Name | Type | Description |
|---|---|---|
engine |
IntPtr |
a TTF_TextEngine object created with TTF.CreateGPUTextEngine. |
Returns
the winding order used by the GPU text engine or TTF.GPUTextEngineWinding.Invalid in case of error.
Thread safety
This function should be called on the thread that created the engine.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetGPUTextEngineWinding(System.IntPtr)
public static void GetHarfBuzzVersion(out int major, out int minor, out int patch);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_GetHarfBuzzVersion(int *major, int *minor, int *patch);
Query the version of the HarfBuzz library in use.
If HarfBuzz is not available, the version reported is 0.0.0.
Parameters
| Name | Type | Description |
|---|---|---|
major |
out int |
to be filled in with the major version number. Can be null. |
minor |
out int |
to be filled in with the minor version number. Can be null.. |
patch |
out int |
to be filled in with the param version number. Can be null.. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetHarfBuzzVersion(System.Int32@,System.Int32@,System.Int32@)
public static bool GetNextTextSubString(IntPtr text, in TTF.SubString substring, out TTF.SubString next);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetNextTextSubString(TTF_Text *text, const TTF_SubString *substring, TTF_SubString *next);
Get the next substring in a text object
If called at the end of the text, this will return a zero length substring with the TTF.SubStringFlags.TextEnd flag set.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF_Text to query. |
substring |
in TTF.SubString |
the TTF.SubString to query. |
next |
out TTF.SubString |
a pointer filled in with the next substring. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetNextTextSubString(System.IntPtr,SDL3.TTF.SubString@,SDL3.TTF.SubString@)
public static int GetNumFontFaces(IntPtr font);SDL declaration
extern SDL_DECLSPEC int SDLCALL TTF_GetNumFontFaces(const TTF_Font *font);
Query the number of faces of a font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
Returns
the number of FreeType font faces.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetNumFontFaces(System.IntPtr)
public static bool GetPreviousTextSubString(IntPtr text, in TTF.SubString substring, out TTF.SubString previous);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetPreviousTextSubString(TTF_Text *text, const TTF_SubString *substring, TTF_SubString *previous);
Get the previous substring in a text object
If called at the start of the text, this will return a zero length substring with the TTF.SubStringFlags.TextStart flag set.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF_Text to query. |
substring |
in TTF.SubString |
the TTF.SubString to query. |
previous |
out TTF.SubString |
true on success or false on failure; call SDL.GetError for more information. |
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetPreviousTextSubString(System.IntPtr,SDL3.TTF.SubString@,SDL3.TTF.SubString@)
public static bool GetStringSize(IntPtr font, byte* text, UIntPtr length, out int w, out int h);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetStringSize(TTF_Font *font, const char *text, size_t length, int *w, int *h);
Calculate the dimensions of a rendered string of UTF-8 text.
This will report the width and height, in pixels, of the space that the specified string will take to fully render.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
text |
byte* |
text to calculate, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
w |
out int |
will be filled with width, in pixels, on return. |
h |
out int |
will be filled with height, in pixels, on return. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetStringSize(System.IntPtr,System.Byte*,System.UIntPtr,System.Int32@,System.Int32@)
public static bool GetStringSize(IntPtr font, IntPtr text, UIntPtr length, out int w, out int h);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetStringSize(TTF_Font *font, const char *text, size_t length, int *w, int *h);
Calculate the dimensions of a rendered string of UTF-8 text.
This will report the width and height, in pixels, of the space that the specified string will take to fully render.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
text |
IntPtr |
text to calculate, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
w |
out int |
will be filled with width, in pixels, on return. |
h |
out int |
will be filled with height, in pixels, on return. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetStringSize(System.IntPtr,System.IntPtr,System.UIntPtr,System.Int32@,System.Int32@)
public static bool GetStringSize(IntPtr font, string text, UIntPtr length, out int w, out int h);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetStringSize(TTF_Font *font, const char *text, size_t length, int *w, int *h);
Calculate the dimensions of a rendered string of UTF-8 text.
This will report the width and height, in pixels, of the space that the specified string will take to fully render.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
text |
string |
text to calculate, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
w |
out int |
will be filled with width, in pixels, on return. |
h |
out int |
will be filled with height, in pixels, on return. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetStringSize(System.IntPtr,System.String,System.UIntPtr,System.Int32@,System.Int32@)
public static bool GetStringSizeWrapped(IntPtr font, string text, UIntPtr length, int wrapWidth, out int w, out int h);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetStringSizeWrapped(TTF_Font *font, const char *text, size_t length, int wrap_width, int *w, int *h);
Calculate the dimensions of a rendered string of UTF-8 text.
This will report the width and height, in pixels, of the space that the specified string will take to fully render.
Text is wrapped to multiple lines on line endings and on word boundaries if it extends beyond wrapWidth in pixels.
If wrap_width is 0, this function will only wrap on newline characters.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
text |
string |
text to calculate, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
wrapWidth |
int |
the maximum width or 0 to wrap on newline characters. |
w |
out int |
will be filled with width, in pixels, on return. |
h |
out int |
will be filled with height, in pixels, on return. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetStringSizeWrapped(System.IntPtr,System.String,System.UIntPtr,System.Int32,System.Int32@,System.Int32@)
public static bool GetTextColor(IntPtr text, out byte r, out byte g, out byte b, out byte a);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetTextColor(TTF_Text *text, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
Get the color of a text object.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to query. |
r |
out byte |
a pointer filled in with the red color value in the range of 0-255, may be null. |
g |
out byte |
a pointer filled in with the green color value in the range of 0-255, may be null. |
b |
out byte |
a pointer filled in with the blue color value in the range of 0-255, may be null. |
a |
out byte |
a pointer filled in with the alpha value in the range of 0-255, may be null. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetTextColor(System.IntPtr,System.Byte@,System.Byte@,System.Byte@,System.Byte@)
public static bool GetTextColorFloat(IntPtr text, out float r, out float g, out float b, out float a);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetTextColorFloat(TTF_Text *text, float *r, float *g, float *b, float *a);
Get the color of a text object.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to query. |
r |
out float |
a pointer filled in with the red color value, normally in the range of 0-1, may be null. |
g |
out float |
a pointer filled in with the green color value, normally in the range of 0-1, may be null. |
b |
out float |
a pointer filled in with the blue color value, normally in the range of 0-1, may be null. |
a |
out float |
a pointer filled in with the alpha value in the range of 0-1, may be null. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetTextColorFloat(System.IntPtr,System.Single@,System.Single@,System.Single@,System.Single@)
public static TTF.Direction GetTextDirection(IntPtr text);SDL declaration
extern SDL_DECLSPEC TTF_Direction SDLCALL TTF_GetTextDirection(TTF_Text *text);
Get the direction to be used for text shaping a text object.
This defaults to the direction of the font used by the text object.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the text to query. |
Returns
the direction to be used for text shaping.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetTextDirection(System.IntPtr)
public static IntPtr GetTextEngine(IntPtr text);SDL declaration
extern SDL_DECLSPEC TTF_TextEngine * SDLCALL TTF_GetTextEngine(TTF_Text *text);
Get the text engine used by a text object.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to query. |
Returns
the TTF_TextEngine used by the text on success or null on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetTextEngine(System.IntPtr)
public static IntPtr GetTextFont(IntPtr text);SDL declaration
extern SDL_DECLSPEC TTF_Font * SDLCALL TTF_GetTextFont(TTF_Text *text);
Get the font used by a text object.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to query. |
Returns
the TTF_Font used by the text on success or null on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetTextFont(System.IntPtr)
public static bool GetTextPosition(IntPtr text, out int x, out int y);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetTextPosition(TTF_Text *text, int *x, int *y);
Get the position of a text object.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to query. |
x |
out int |
a pointer filled in with the x offset of the upper left corner of this text in pixels, may be null. |
y |
out int |
a pointer filled in with the y offset of the upper left corner of this text in pixels, may be null. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetTextPosition(System.IntPtr,System.Int32@,System.Int32@)
public static uint GetTextProperties(IntPtr text);SDL declaration
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL TTF_GetTextProperties(TTF_Text *text);
Get the properties associated with a text object.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to query. |
Returns
a valid property ID on success or 0 on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetTextProperties(System.IntPtr)
public static uint GetTextScript(IntPtr text);SDL declaration
extern SDL_DECLSPEC Uint32 SDLCALL TTF_GetTextScript(TTF_Text *text);
Get the script used for text shaping a text object.
This defaults to the script of the font used by the text object.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the text to query. |
Returns
an ISO 15924 code or 0 if a script hasn't been set on either the text object or the font.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetTextScript(System.IntPtr)
public static bool GetTextSize(IntPtr text, out int w, out int h);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetTextSize(TTF_Text *text, int *w, int *h);
Get the size of a text object.
The size of the text may change when the font or font style and size change.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to query. |
w |
out int |
a pointer filled in with the width of the text, in pixels, may be null. |
h |
out int |
a pointer filled in with the height of the text, in pixels, may be null. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: his function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetTextSize(System.IntPtr,System.Int32@,System.Int32@)
public static bool GetTextSubString(IntPtr text, int offset, out TTF.SubString substring);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetTextSubString(TTF_Text *text, int offset, TTF_SubString *substring);
Get the substring of a text object that surrounds a text offset.
If offset is less than 0, this will return a zero length substring at the beginning of the text with the TTF.SubStringFlags.TextStart flag set. If offset is greater than or equal to the length of the text string, this will return a zero length substring at the end of the text with the TTF.SubStringFlags.TextEnd flag set.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to query. |
offset |
int |
a byte offset into the text string. |
substring |
out TTF.SubString |
a pointer filled in with the substring containing the offset. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetTextSubString(System.IntPtr,System.Int32,SDL3.TTF.SubString@)
public static bool GetTextSubStringForLine(IntPtr text, int line, out TTF.SubString substring);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetTextSubStringForLine(TTF_Text *text, int line, TTF_SubString *substring);
Get the substring of a text object that contains the given line.
If line is less than 0, this will return a zero length substring at the beginning of the text with the TTF.SubStringFlags.TextStart flag set. If line is greater than or equal to Text.NumLines this will return a zero length substring at the end of the text with the TTF.SubStringFlags.TextEnd flag set.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to query. |
line |
int |
a zero-based line index, in the range [0 .. Text.NumLines-1]. |
substring |
out TTF.SubString |
a pointer filled in with the substring containing the offset. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetTextSubStringForLine(System.IntPtr,System.Int32,SDL3.TTF.SubString@)
public static bool GetTextSubStringForPoint(IntPtr text, int x, int y, out TTF.SubString substring);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetTextSubStringForPoint(TTF_Text *text, int x, int y, TTF_SubString *substring);
Get the portion of a text string that is closest to a point.
This will return the closest substring of text to the given point.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to query. |
x |
int |
the x coordinate relative to the left side of the text, may be outside the bounds of the text area. |
y |
int |
the y coordinate relative to the top side of the text, may be outside the bounds of the text area. |
substring |
out TTF.SubString |
a pointer filled in with the closest substring of text to the given point. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetTextSubStringForPoint(System.IntPtr,System.Int32,System.Int32,SDL3.TTF.SubString@)
public static TTF.SubString[] GetTextSubStringsForRange(IntPtr text, int offset, int length, out int count);SDL declaration
extern SDL_DECLSPEC TTF_SubString ** SDLCALL TTF_GetTextSubStringsForRange(TTF_Text *text, int offset, int length, int *count);
Get the substrings of a text object that contain a range of text.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to query. |
offset |
int |
a byte offset into the text string. |
length |
int |
the length of the range being queried, in bytes, or -1 for the remainder of the string. |
count |
out int |
a pointer filled in with the number of substrings returned, may be null. |
Returns
a null terminated array of substring pointers or null on failure; call SDL.GetError for more information. This is a single allocation that should be freed with SDL.Free when it is no longer needed.
XML member id: M:SDL3.TTF.GetTextSubStringsForRange(System.IntPtr,System.Int32,System.Int32,System.Int32@)
public static bool GetTextWrapWidth(IntPtr text, out int wrapWidth);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_GetTextWrapWidth(TTF_Text *text, int *wrap_width);
Get whether wrapping is enabled on a text object.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to query. |
wrapWidth |
out int |
a pointer filled in with the maximum width in pixels or 0 if the text is being wrapped on newline characters. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.GetTextWrapWidth(System.IntPtr,System.Int32@)
public static bool Init();SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_Init(void);
Initialize SDL_ttf.
You must successfully call this function before it is safe to call any other function in this library.
It is safe to call this more than once, and each successful TTF.Init call should be paired with a matching TTF.Quit call.
Returns
trueon success orfalseon failure; callSDL.GetErrorfor more information.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.Init
public static bool InsertTextString(IntPtr text, int offset, string string, UIntPtr length);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_InsertTextString(TTF_Text *text, int offset, const char *string, size_t length);
Insert UTF-8 text into a text object. This function may cause the internal text representation to be rebuilt.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to modify. |
offset |
int |
the offset, in bytes, from the beginning of the string if >= 0, the offset from the end of the string if < 0. Note that this does not do UTF-8 validation, so you should only insert at UTF-8 sequence boundaries. |
string |
string |
the UTF-8 text to insert. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.InsertTextString(System.IntPtr,System.Int32,System.String,System.UIntPtr)
public static bool MeasureString(IntPtr font, string text, UIntPtr length, int maxWidth, out int measuredWidth, out ulong measuredLength);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_MeasureString(TTF_Font *font, const char *text, size_t length, int max_width, int *measured_width, size_t *measured_length);
Calculate how much of a UTF-8 string will fit in a given width.
This reports the number of characters that can be rendered before reaching maxWidth.
This does not need to render the string to do this calculation.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to query. |
text |
string |
text to calculate, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
maxWidth |
int |
maximum width, in pixels, available for the string, or 0 for unbounded width. |
measuredWidth |
out int |
a pointer filled in with the width, in pixels, of the string that will fit, may be null. |
measuredLength |
out ulong |
a pointer filled in with the length, in bytes, of the string that will fit, may be null. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.MeasureString(System.IntPtr,System.String,System.UIntPtr,System.Int32,System.Int32@,System.UInt64@)
public static IntPtr OpenFont(string file, float ptsize);SDL declaration
extern SDL_DECLSPEC TTF_Font * SDLCALL TTF_OpenFont(const char *file, float ptsize);
Create a font from a file, using a specified point size.
Some .fon fonts will have several sizes embedded in the file, so the point size becomes the index of choosing which size. If the value is too high, the last indexed size will be the default.
When done with the returned TTF_Font, use TTF.CloseFont to dispose of it.
Parameters
| Name | Type | Description |
|---|---|---|
file |
string |
path to font file. |
ptsize |
float |
point size to use for the newly-opened font. |
Returns
a valid TTF_Font, or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.OpenFont(System.String,System.Single)
public static IntPtr OpenFontIO(IntPtr src, bool closeio, float ptsize);SDL declaration
extern SDL_DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIO(SDL_IOStream *src, bool closeio, float ptsize);
Create a font from an SDL_IOStream, using a specified point size.
Some .fon fonts will have several sizes embedded in the file, so the point size becomes the index of choosing which size. If the value is too high, the last indexed size will be the default.
If closeio is true, src will be automatically closed once the font is closed. Otherwise you should keep src open until the font is closed.
When done with the returned TTF_Font, use TTF.CloseFont to dispose of it.
Parameters
| Name | Type | Description |
|---|---|---|
src |
IntPtr |
an SDL_IOStream to provide a font file's data. |
closeio |
bool |
true to close src when the font is closed, false to leave it open. |
ptsize |
float |
point size to use for the newly-opened font. |
Returns
a valid TTF_Font, or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.OpenFontIO(System.IntPtr,System.Boolean,System.Single)
public static IntPtr OpenFontWithProperties(uint props);SDL declaration
extern SDL_DECLSPEC TTF_Font * SDLCALL TTF_OpenFontWithProperties(SDL_PropertiesID props);
Create a font with the specified properties.
These are the supported properties:
-
TTF.Props.FontCreateFilenameString: the font file to open, if an SDL_IOStream isn't being used. This is required ifTTF.Props.FontCreateIOStreamPointerandTTF.Props.FontCreateExistingFontaren't set. -
TTF.Props.FontCreateIOStreamPointer: an SDL_IOStream containing the font to be opened. This should not be closed until the font is closed. This is required ifTTF.Props.FontCreateFilenameStringandTTF.Props.FontCreateExistingFontaren't set. -
TTF.Props.FontCreateIOStreamOffsetNumber: the offset in the iostream for the beginning of the font, defaults to 0. -
TTF.Props.FontCreateIOStreamAutoCloseBoolean:trueif closing the font should also close the associated SDL_IOStream. -
TTF.Props.FontCreateSizeFloat: the point size of the font. Some .fon fonts will have several sizes embedded in the file, so the point size becomes the index of choosing which size. If the value is too high, the last indexed size will be the default. -
TTF.Props.FontCreateFaceNumber: the face index of the font, if the font contains multiple font faces. -
TTF.Props.FontCreateHorizontalDPINumber: the horizontal DPI to use for font rendering, defaults toTTF.Props.FontCreateVerticalDPINumberif set, or 72 otherwise. -
TTF.Props.FontCreateVerticalDPINumber: the vertical DPI to use for font rendering, defaults toTTF.Props.FontCreateHorizontalDPINumberif set, or 72 otherwise. -
TTF.Props.FontCreateExistingFont: an optional TTF_Font that, if set, if set, will be used as the font data source and the initial size and style of the new font.
Parameters
| Name | Type | Description |
|---|---|---|
props |
uint |
the properties to use. |
Returns
a valid TTF_Font, or null on failure; call SDL.GetError for more information.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.OpenFontWithProperties(System.UInt32)
public static void Quit();SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_Quit(void);
Deinitialize SDL_ttf.
You must call this when done with the library, to free internal resources. It is safe to call this when the library isn't initialized, as it will just return immediately.
Once you have as many quit calls as you have had successful calls to TTF.Init, the library will actually deinitialize.
Please note that this does not automatically close any fonts that are still open at the time of deinitialization, and it is possibly not safe to close them afterwards, as parts of the library will no longer be initialized deal with it. A well-written program should call TTF.CloseFont on any open fonts before calling this function!
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.Quit
public static void RemoveFallbackFont(IntPtr font, IntPtr fallback);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_RemoveFallbackFont(TTF_Font *font, TTF_Font *fallback);
Remove a fallback font.
This updates any TTF_Text objects using this font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to modify. |
fallback |
IntPtr |
the font to remove as a fallback. |
Thread safety
This function should be called on the thread that created both fonts.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RemoveFallbackFont(System.IntPtr,System.IntPtr)
public static IntPtr RenderGlyphBlended(IntPtr font, ulong ch, SDL.Color fg);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Blended(TTF_Font *font, Uint32 ch, SDL_Color fg);
Render a single UNICODE codepoint at high quality to a new ARGB surface.
This function will allocate a new 32-bit, ARGB surface, using alpha blending to dither the font with the given color. This function returns the new surface, or null if there was an error.
The glyph is rendered without any padding or centering in the X direction, and aligned normally in the Y direction.
You can render at other quality levels with TTF.RenderGlyphSolid, TTF.RenderGlyphShaded, and TTF.RenderGlyphLCD.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
ch |
ulong |
the codepoint to render. |
fg |
SDL.Color |
the foreground color for the text. |
Returns
a new 32-bit, ARGB surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderGlyphBlended(System.IntPtr,System.UInt64,SDL3.SDL.Color)
public static IntPtr RenderGlyphLCD(IntPtr font, uint ch, SDL.Color fg, SDL.Color bg);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_LCD(TTF_Font *font, Uint32 ch, SDL_Color fg, SDL_Color bg);
Render a single UNICODE codepoint at LCD subpixel quality to a new ARGB surface.
This function will allocate a new 32-bit, ARGB surface, and render alpha-blended text using FreeType's LCD subpixel rendering. This function returns the new surface, or null if there was an error.
The glyph is rendered without any padding or centering in the X direction, and aligned normally in the Y direction.
You can render at other quality levels with TTF.RenderGlyphSolid, TTF.RenderGlyphShaded, and TTF.RenderGlyphBlended.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
ch |
uint |
the codepoint to render. |
fg |
SDL.Color |
the foreground color for the text. |
bg |
SDL.Color |
the background color for the text. |
Returns
a new 32-bit, ARGB surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderGlyphLCD(System.IntPtr,System.UInt32,SDL3.SDL.Color,SDL3.SDL.Color)
public static IntPtr RenderGlyphShaded(IntPtr font, uint ch, SDL.Color fg, SDL.Color bg);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Shaded(TTF_Font *font, Uint32 ch, SDL_Color fg, SDL_Color bg);
Render a single UNICODE codepoint at high quality to a new 8-bit surface.
This function will allocate a new 8-bit, palettized surface. The surface's 0 pixel will be the specified background color, while other pixels have varying degrees of the foreground color. This function returns the new surface, or null if there was an error.
The glyph is rendered without any padding or centering in the X direction, and aligned normally in the Y direction.
You can render at other quality levels with TTF.RenderGlyphSolid, TTF.RenderGlyphBlended, and TTF.RenderGlyphLCD.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
ch |
uint |
the codepoint to render. |
fg |
SDL.Color |
the foreground color for the text. |
bg |
SDL.Color |
the background color for the text. |
Returns
a new 8-bit, palettized surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderGlyphShaded(System.IntPtr,System.UInt32,SDL3.SDL.Color,SDL3.SDL.Color)
public static IntPtr RenderGlyphSolid(IntPtr font, uint ch, SDL.Color fg);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Solid(TTF_Font *font, Uint32 ch, SDL_Color fg);
Render a single 32-bit glyph at fast quality to a new 8-bit surface.
This function will allocate a new 8-bit, palettized surface. The surface's 0 pixel will be the colorkey, giving a transparent background. The 1 pixel will be set to the text color.
The glyph is rendered without any padding or centering in the X direction, and aligned normally in the Y direction.
You can render at other quality levels with TTF.RenderGlyphShaded, TTF.RenderGlyphBlended, and TTF.RenderGlyphLCD.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
ch |
uint |
the character to render. |
fg |
SDL.Color |
the foreground color for the text. |
Returns
a new 8-bit, palettized surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderGlyphSolid(System.IntPtr,System.UInt32,SDL3.SDL.Color)
public static IntPtr RenderTextBlended(IntPtr font, byte* text, UIntPtr length, SDL.Color fg);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended(TTF_Font *font, const char *text, size_t length, SDL_Color fg);
Render UTF-8 text at high quality to a new ARGB surface.
This function will allocate a new 32-bit, ARGB surface, using alpha blending to dither the font with the given color. This function returns the new surface, or null if there was an error.
This will not word-wrap the string; you'll get a surface with a single line of text, as long as the string requires. You can use TTF.RenderTextBlendedWrapped instead if you need to wrap the output to multiple lines.
This will not wrap on newline characters.
You can render at other quality levels with TTF.RenderTextSolid, TTF.RenderTextShaded, and TTF.RenderTextLCD.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
text |
byte* |
text to render, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
fg |
SDL.Color |
the foreground color for the text. |
Returns
a new 32-bit, ARGB surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderTextBlended(System.IntPtr,System.Byte*,System.UIntPtr,SDL3.SDL.Color)
public static IntPtr RenderTextBlended(IntPtr font, IntPtr text, UIntPtr length, SDL.Color fg);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended(TTF_Font *font, const char *text, size_t length, SDL_Color fg);
Render UTF-8 text at high quality to a new ARGB surface.
This function will allocate a new 32-bit, ARGB surface, using alpha blending to dither the font with the given color. This function returns the new surface, or null if there was an error.
This will not word-wrap the string; you'll get a surface with a single line of text, as long as the string requires. You can use TTF.RenderTextBlendedWrapped instead if you need to wrap the output to multiple lines.
This will not wrap on newline characters.
You can render at other quality levels with TTF.RenderTextSolid, TTF.RenderTextShaded, and TTF.RenderTextLCD.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
text |
IntPtr |
text to render, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
fg |
SDL.Color |
the foreground color for the text. |
Returns
a new 32-bit, ARGB surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderTextBlended(System.IntPtr,System.IntPtr,System.UIntPtr,SDL3.SDL.Color)
public static IntPtr RenderTextBlended(IntPtr font, string text, UIntPtr length, SDL.Color fg);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended(TTF_Font *font, const char *text, size_t length, SDL_Color fg);
Render UTF-8 text at high quality to a new ARGB surface.
This function will allocate a new 32-bit, ARGB surface, using alpha blending to dither the font with the given color. This function returns the new surface, or null if there was an error.
This will not word-wrap the string; you'll get a surface with a single line of text, as long as the string requires. You can use TTF.RenderTextBlendedWrapped instead if you need to wrap the output to multiple lines.
This will not wrap on newline characters.
You can render at other quality levels with TTF.RenderTextSolid, TTF.RenderTextShaded, and TTF.RenderTextLCD.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
text |
string |
text to render, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
fg |
SDL.Color |
the foreground color for the text. |
Returns
a new 32-bit, ARGB surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderTextBlended(System.IntPtr,System.String,System.UIntPtr,SDL3.SDL.Color)
public static IntPtr RenderTextBlendedWrapped(IntPtr font, string text, UIntPtr length, SDL.Color fg, int wrapWidth);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, int wrap_width);
Render word-wrapped UTF-8 text at high quality to a new ARGB surface.
This function will allocate a new 32-bit, ARGB surface, using alpha blending to dither the font with the given color. This function returns the new surface, or null if there was an error.
Text is wrapped to multiple lines on line endings and on word boundaries if it extends beyond wrapWidth in pixels.
If wrap_width is 0, this function will only wrap on newline characters.
You can render at other quality levels with TTF.RenderTextSolidWrapped, TTF.RenderTextShadedWrapped, and TTF.RenderTextLCDWrapped.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
text |
string |
text to render, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
fg |
SDL.Color |
the foreground color for the text. |
wrapWidth |
int |
the maximum width of the text surface or 0 to wrap on newline characters. |
Returns
a new 32-bit, ARGB surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderTextBlendedWrapped(System.IntPtr,System.String,System.UIntPtr,SDL3.SDL.Color,System.Int32)
public static IntPtr RenderTextLCD(IntPtr font, string text, UIntPtr length, SDL.Color fg, SDL.Color bg);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_LCD(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg);
Render UTF-8 text at LCD subpixel quality to a new ARGB surface.
This function will allocate a new 32-bit, ARGB surface, and render alpha-blended text using FreeType's LCD subpixel rendering. This function returns the new surface, or null if there was an error.
This will not word-wrap the string; you'll get a surface with a single line of text, as long as the string requires. You can use TTF.RenderTextLCDWrapped instead if you need to wrap the output to multiple lines.
This will not wrap on newline characters.
You can render at other quality levels with TTF.RenderTextSolid, TTF.RenderTextShaded, and TTF.RenderTextBlended.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
text |
string |
text to render, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
fg |
SDL.Color |
the foreground color for the text. |
bg |
SDL.Color |
the background color for the text. |
Returns
a new 32-bit, ARGB surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderTextLCD(System.IntPtr,System.String,System.UIntPtr,SDL3.SDL.Color,SDL3.SDL.Color)
public static IntPtr RenderTextLCDWrapped(IntPtr font, string text, UIntPtr length, SDL.Color fg, SDL.Color bg, int wrapWidth);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_LCD_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg, int wrap_width);
Render word-wrapped UTF-8 text at LCD subpixel quality to a new ARGB surface.
This function will allocate a new 32-bit, ARGB surface, and render alpha-blended text using FreeType's LCD subpixel rendering. This function returns the new surface, or null if there was an error.
Text is wrapped to multiple lines on line endings and on word boundaries if it extends beyond wrapWidth in pixels.
If wrapWidth is 0, this function will only wrap on newline characters.
You can render at other quality levels with TTF.RenderTextSolidWrapped, TTF.RenderTextShadedWrapped, and TTF.RenderTextBlendedWrapped.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
text |
string |
text to render, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
fg |
SDL.Color |
the foreground color for the text. |
bg |
SDL.Color |
the background color for the text. |
wrapWidth |
int |
the maximum width of the text surface or 0 to wrap on newline characters. |
Returns
a new 32-bit, ARGB surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderTextLCDWrapped(System.IntPtr,System.String,System.UIntPtr,SDL3.SDL.Color,SDL3.SDL.Color,System.Int32)
public static IntPtr RenderTextShaded(IntPtr font, string text, UIntPtr length, SDL.Color fg, SDL.Color bg);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg);
Render UTF-8 text at high quality to a new 8-bit surface.
This function will allocate a new 8-bit, palettized surface. The surface's 0 pixel will be the specified background color, while other pixels have varying degrees of the foreground color. This function returns the new surface, or null if there was an error.
This will not word-wrap the string; you'll get a surface with a single line of text, as long as the string requires. You can use TTF.RenderTextShadedWrapped instead if you need to wrap the output to multiple lines.
This will not wrap on newline characters.
You can render at other quality levels with TTF.RenderTextSolid, TTF.RenderTextBlended, and TTF.RenderTextLCD.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
text |
string |
text to render, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
fg |
SDL.Color |
the foreground color for the text. |
bg |
SDL.Color |
the background color for the text. |
Returns
a new 8-bit, palettized surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderTextShaded(System.IntPtr,System.String,System.UIntPtr,SDL3.SDL.Color,SDL3.SDL.Color)
public static IntPtr RenderTextShadedWrapped(IntPtr font, string text, UIntPtr length, SDL.Color fg, SDL.Color bg, int wrapWidth);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, SDL_Color bg, int wrap_width);
Render word-wrapped UTF-8 text at high quality to a new 8-bit surface.
This function will allocate a new 8-bit, palettized surface. The surface's 0 pixel will be the specified background color, while other pixels have varying degrees of the foreground color. This function returns the new surface, or null if there was an error.
Text is wrapped to multiple lines on line endings and on word boundaries if it extends beyond wrapWidth in pixels.
If wrap_width is 0, this function will only wrap on newline characters.
You can render at other quality levels with TTF.RenderTextSolidWrapped, TTF.RenderTextBlendedWrapped, and TTF.RenderTextLCDWrapped.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
text |
string |
text to render, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
fg |
SDL.Color |
the foreground color for the text. |
bg |
SDL.Color |
the background color for the text. |
wrapWidth |
int |
the maximum width of the text surface or 0 to wrap on newline characters. |
Returns
a new 8-bit, palettized surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
XML member id: M:SDL3.TTF.RenderTextShadedWrapped(System.IntPtr,System.String,System.UIntPtr,SDL3.SDL.Color,SDL3.SDL.Color,System.Int32)
public static IntPtr RenderTextSolid(IntPtr font, byte* text, UIntPtr length, SDL.Color fg);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid(TTF_Font *font, const char *text, size_t length, SDL_Color fg);
Render UTF-8 text at fast quality to a new 8-bit surface.
This function will allocate a new 8-bit, palettized surface. The surface's 0 pixel will be the colorkey, giving a transparent background. The 1 pixel will be set to the text color.
This will not word-wrap the string; you'll get a surface with a single line of text, as long as the string requires. You can use TTF.RenderTextSolidWrapped instead if you need to wrap the output to multiple lines.
This will not wrap on newline characters.
You can render at other quality levels with TTF.RenderTextShaded, TTF_RenderText_Blended, and TTF.RenderTextLCD.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
text |
byte* |
text to render, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
fg |
SDL.Color |
the foreground color for the text. |
Returns
a new 8-bit, palettized surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderTextSolid(System.IntPtr,System.Byte*,System.UIntPtr,SDL3.SDL.Color)
public static IntPtr RenderTextSolid(IntPtr font, IntPtr text, UIntPtr length, SDL.Color fg);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid(TTF_Font *font, const char *text, size_t length, SDL_Color fg);
Render UTF-8 text at fast quality to a new 8-bit surface.
This function will allocate a new 8-bit, palettized surface. The surface's 0 pixel will be the colorkey, giving a transparent background. The 1 pixel will be set to the text color.
This will not word-wrap the string; you'll get a surface with a single line of text, as long as the string requires. You can use TTF.RenderTextSolidWrapped instead if you need to wrap the output to multiple lines.
This will not wrap on newline characters.
You can render at other quality levels with TTF.RenderTextShaded, TTF_RenderText_Blended, and TTF.RenderTextLCD.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
text |
IntPtr |
text to render, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
fg |
SDL.Color |
the foreground color for the text. |
Returns
a new 8-bit, palettized surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderTextSolid(System.IntPtr,System.IntPtr,System.UIntPtr,SDL3.SDL.Color)
public static IntPtr RenderTextSolid(IntPtr font, string text, UIntPtr length, SDL.Color fg);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid(TTF_Font *font, const char *text, size_t length, SDL_Color fg);
Render UTF-8 text at fast quality to a new 8-bit surface.
This function will allocate a new 8-bit, palettized surface. The surface's 0 pixel will be the colorkey, giving a transparent background. The 1 pixel will be set to the text color.
This will not word-wrap the string; you'll get a surface with a single line of text, as long as the string requires. You can use TTF.RenderTextSolidWrapped instead if you need to wrap the output to multiple lines.
This will not wrap on newline characters.
You can render at other quality levels with TTF.RenderTextShaded, TTF_RenderText_Blended, and TTF.RenderTextLCD.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
text |
string |
text to render, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
fg |
SDL.Color |
the foreground color for the text. |
Returns
a new 8-bit, palettized surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderTextSolid(System.IntPtr,System.String,System.UIntPtr,SDL3.SDL.Color)
public static IntPtr RenderTextSolidWrapped(IntPtr font, string text, UIntPtr length, SDL.Color fg, int wrapLength);SDL declaration
extern SDL_DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid_Wrapped(TTF_Font *font, const char *text, size_t length, SDL_Color fg, int wrapLength);
Render word-wrapped UTF-8 text at fast quality to a new 8-bit surface.
This function will allocate a new 8-bit, palettized surface. The surface's 0 pixel will be the colorkey, giving a transparent background. The 1 pixel will be set to the text color.
Text is wrapped to multiple lines on line endings and on word boundaries if it extends beyond wrapLength in pixels.
If wrapLength is 0, this function will only wrap on newline characters.
You can render at other quality levels with TTF.RenderTextShadedWrapped, TTF.RenderTextBlendedWrapped, and TTF_RenderText_LCD_Wrapped.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to render with. |
text |
string |
text to render, in UTF-8 encoding. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
fg |
SDL.Color |
the foreground color for the text. |
wrapLength |
int |
the maximum width of the text surface or 0 to wrap on newline characters. |
Returns
a new 8-bit, palettized surface, or null if there was an error.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.RenderTextSolidWrapped(System.IntPtr,System.String,System.UIntPtr,SDL3.SDL.Color,System.Int32)
public static bool SetFontDirection(IntPtr font, TTF.Direction direction);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetFontDirection(TTF_Font *font, TTF_Direction direction);
Set the direction to be used for text shaping by a font.
This function only supports left-to-right text shaping if SDL_ttf was not built with HarfBuzz support.
This updates any TTF_Text objects using this font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to modify. |
direction |
TTF.Direction |
the new direction for text to flow. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetFontDirection(System.IntPtr,SDL3.TTF.Direction)
public static void SetFontHinting(IntPtr font, TTF.HintingFlags hinting);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_SetFontHinting(TTF_Font *font, TTF_HintingFlags hinting);
Set a font's current hinter setting.
This updates any TTF.TTFText objects using this font, and clears already-generated glyphs, if any, from the cache.
The hinter setting is a single value:
TTF.HintingFlags.NormalTTF.HintingFlags.LightTTF.HintingFlags.MonoTTF.HintingFlags.None-
TTF.HintingFlags.LightSubpixel(available in SDL_ttf 3.0.0 and later)
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to set a new hinter setting on. |
hinting |
TTF.HintingFlags |
the new hinter setting. |
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetFontHinting(System.IntPtr,SDL3.TTF.HintingFlags)
public static void SetFontKerning(IntPtr font, bool enabled);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_SetFontKerning(TTF_Font *font, bool enabled);
Set if kerning is enabled for a font.
Newly-opened fonts default to allowing kerning. This is generally a good policy unless you have a strong reason to disable it, as it tends to produce better rendering (with kerning disabled, some fonts might render the word kerning as something that looks like keming for example).
This updates any TTF.TTFText objects using this font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to set kerning on. |
enabled |
bool |
true to enable kerning, false to disable. |
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetFontKerning(System.IntPtr,System.Boolean)
public static bool SetFontLanguage(IntPtr font, string languageBcp47);SDL declaration
extern SDL_DECLSPEC bool TTF_SetFontLanguage(TTF_Font *font, const char *language_bcp47);
Set language to be used for text shaping by a font.
If SDL_ttf was not built with HarfBuzz support, this function returns false.
This updates any TTF.TTFText objects using this font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to specify a language for. |
languageBcp47 |
string |
a null-terminated string containing the desired language's BCP47 code. Or null to reset the value. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetFontLanguage(System.IntPtr,System.String)
public static void SetFontLineSkip(IntPtr font, int lineskip);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_SetFontLineSkip(TTF_Font *font, int lineskip);
Set the spacing between lines of text for a font.
This updates any TTF.TTFText objects using this font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to modify. |
lineskip |
int |
the new line spacing for the font. |
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetFontLineSkip(System.IntPtr,System.Int32)
public static bool SetFontOutline(IntPtr font, int outline);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetFontOutline(TTF_Font *font, int outline);
Set a font's current outline.
This uses the font properties TTF.Props.FontOutlineLineCapNumber, TTF.Props.FontOutlineLineJoinNumber, and TTF.Props.FontOutlineMiterLimitNumber when setting the font outline.
This updates any TTF.TTFText objects using this font, and clears already-generated glyphs, if any, from the cache.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to set a new outline on. |
outline |
int |
positive outline value, 0 to default. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetFontOutline(System.IntPtr,System.Int32)
public static bool SetFontScript(IntPtr font, uint script);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetFontScript(TTF_Font *font, Uint32 script);
Set the script to be used for text shaping by a font.
This returns false if SDL_ttf isn't built with HarfBuzz support.
This updates any TTF.TTFText objects using this font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to modify. |
script |
uint |
an ISO 15924 code . |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function is not thread-safe.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetFontScript(System.IntPtr,System.UInt32)
public static bool SetFontSDF(IntPtr font, bool enabled);SDL declaration
extern SDL_DECLSPEC bool TTF_SetFontSDF(TTF_Font *font, bool enabled);
Enable Signed Distance Field rendering for a font.
SDF is a technique that helps fonts look sharp even when scaling and rotating, and requires special shader support for display.
This works with Blended APIs, and generates the raw signed distance values in the alpha channel of the resulting texture.
This updates any TTF.TTFText objects using this font, and clears already-generated glyphs, if any, from the cache.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to set SDF support on. |
enabled |
bool |
true to enable SDF, false to disable. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetFontSDF(System.IntPtr,System.Boolean)
public static bool SetFontSize(IntPtr font, float ptsize);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetFontSize(TTF_Font *font, float ptsize);
Set a font's size dynamically.
This updates any TTF.TTFText objects using this font, and clears already-generated glyphs, if any, from the cache.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to resize. |
ptsize |
float |
the new point size. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetFontSize(System.IntPtr,System.Single)
public static bool SetFontSizeDPI(IntPtr font, float ptsize, int hdpi, int vdpi);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetFontSizeDPI(TTF_Font *font, float ptsize, int hdpi, int vdpi);
Set font size dynamically with target resolutions, in dots per inch.
This updates any TTF.TTFText objects using this font, and clears already-generated glyphs, if any, from the cache.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to resize. |
ptsize |
float |
the new point size. |
hdpi |
int |
the target horizontal DPI. |
vdpi |
int |
the target vertical DPI. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetFontSizeDPI(System.IntPtr,System.Single,System.Int32,System.Int32)
public static void SetFontStyle(IntPtr font, TTF.FontStyleFlags style);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_SetFontStyle(TTF_Font *font, TTF_FontStyleFlags style);
Set a font's current style.
This updates any TTF_Text objects using this font, and clears already-generated glyphs, if any, from the cache.
The font styles are a set of bit flags, OR'd together:
-
TTF.FontStyleFlags.Normal(is zero) TTF.FontStyleFlags.BoldTTF.FontStyleFlags.ItalicTTF.FontStyleFlags.UnderlineTTF.FontStyleFlags.Strikethrough
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to set a new style on. |
style |
TTF.FontStyleFlags |
the new style values to set, OR'd together. |
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetFontStyle(System.IntPtr,SDL3.TTF.FontStyleFlags)
public static void SetFontWrapAlignment(IntPtr font, TTF.HorizontalAlignment align);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_SetFontWrapAlignment(TTF_Font *font, TTF_HorizontalAlignment align);
Set a font's current wrap alignment option.
This updates any TTF.TTFText objects using this font.
Parameters
| Name | Type | Description |
|---|---|---|
font |
IntPtr |
the font to set a new wrap alignment option on. |
align |
TTF.HorizontalAlignment |
he new wrap alignment option. |
Thread safety
This function should be called on the thread that created the font.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetFontWrapAlignment(System.IntPtr,SDL3.TTF.HorizontalAlignment)
public static void SetGPUTextEngineWinding(IntPtr engine, TTF.GPUTextEngineWinding winding);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_SetGPUTextEngineWinding(TTF_TextEngine *engine, TTF_GPUTextEngineWinding winding);
Sets the winding order of the vertices returned by TTF.GetGPUTextDrawData for a particular GPU text engine.
Parameters
| Name | Type | Description |
|---|---|---|
engine |
IntPtr |
a TTF_TextEngine object created with TTF.CreateGPUTextEngine. |
winding |
TTF.GPUTextEngineWinding |
the new winding order option. |
Thread safety
This function should be called on the thread that created the engine.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetGPUTextEngineWinding(System.IntPtr,SDL3.TTF.GPUTextEngineWinding)
public static bool SetTextColor(IntPtr text, byte r, byte g, byte b, byte a);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetTextColor(TTF_Text *text, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
Set the color of a text object.
The default text color is white (255, 255, 255, 255).
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to modify. |
r |
byte |
the red color value in the range of 0-255. |
g |
byte |
the green color value in the range of 0-255. |
b |
byte |
the blue color value in the range of 0-255. |
a |
byte |
the alpha value in the range of 0-255. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetTextColor(System.IntPtr,System.Byte,System.Byte,System.Byte,System.Byte)
public static bool SetTextColorFloat(IntPtr text, float r, float g, float b, float a);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetTextColorFloat(TTF_Text *text, float r, float g, float b, float a);
Set the color of a text object.
The default text color is white (1.0f, 1.0f, 1.0f, 1.0f).
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to modify. |
r |
float |
the red color value, normally in the range of 0-1. |
g |
float |
the green color value, normally in the range of 0-1. |
b |
float |
the blue color value, normally in the range of 0-1. |
a |
float |
the alpha value in the range of 0-1. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetTextColorFloat(System.IntPtr,System.Single,System.Single,System.Single,System.Single)
public static bool SetTextDirection(IntPtr text, TTF.Direction direction);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetTextDirection(TTF_Text *text, TTF_Direction direction);
Set the direction to be used for text shaping a text object.
This function only supports left-to-right text shaping if SDL_ttf was not built with HarfBuzz support.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the text to modify. |
direction |
TTF.Direction |
the new direction for text to flow. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetTextDirection(System.IntPtr,SDL3.TTF.Direction)
public static bool SetTextEngine(IntPtr text, IntPtr engine);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetTextEngine(TTF_Text *text, TTF_TextEngine *engine);
Set the text engine used by a text object. This function may cause the internal text representation to be rebuilt.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to modify. |
engine |
IntPtr |
the text engine to use for drawing. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetTextEngine(System.IntPtr,System.IntPtr)
public static bool SetTextFont(IntPtr text, IntPtr font);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetTextFont(TTF_Text *text, TTF_Font *font);
Set the font used by a text object.
When a text object has a font, any changes to the font will automatically regenerate the text. If you set the font to null, the text will continue to render but changes to the font will no longer affect the text.
This function may cause the internal text representation to be rebuilt.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to modify. |
font |
IntPtr |
the font to use, may be null. |
Returns
false if the pointer is null; otherwise, true. call SDL.GetError for more information
XML member id: M:SDL3.TTF.SetTextFont(System.IntPtr,System.IntPtr)
public static bool SetTextPosition(IntPtr text, int x, int y);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetTextPosition(TTF_Text *text, int x, int y);
Set the position of a text object.
This can be used to position multiple text objects within a single wrapping text area.
This function may cause the internal text representation to be rebuilt.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to modify. |
x |
int |
the x offset of the upper left corner of this text in pixels. |
y |
int |
the y offset of the upper left corner of this text in pixels. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetTextPosition(System.IntPtr,System.Int32,System.Int32)
public static bool SetTextScript(IntPtr text, uint script);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetTextScript(TTF_Text *text, Uint32 script);
Set the script to be used for text shaping a text object.
TThis returns false if SDL_ttf isn't built with HarfBuzz support.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
an ISO 15924 code . |
script |
uint |
a script tag in the format used by HarfBuzz. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetTextScript(System.IntPtr,System.UInt32)
public static bool SetTextString(IntPtr text, string string, UIntPtr length);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetTextString(TTF_Text *text, const char *string, size_t length);
Set the UTF-8 text used by a text object. This function may cause the internal text representation to be rebuilt.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to modify. |
string |
string |
the UTF-8 text to use, may be null. |
length |
UIntPtr |
the length of the text, in bytes, or 0 for null terminated text. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetTextString(System.IntPtr,System.String,System.UIntPtr)
public static bool SetTextWrapWhitespaceVisible(IntPtr text, bool visible);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetTextWrapWhitespaceVisible(TTF_Text *text, bool visible);
Set whether whitespace should be visible when wrapping a text object.
If the whitespace is visible, it will take up space for purposes of alignment and wrapping. This is good for editing, but looks better when centered or aligned if whitespace around line wrapping is hidden. This defaults false.
This function may cause the internal text representation to be rebuilt.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to modify. |
visible |
bool |
true to show whitespace when wrapping text, false to hide it. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetTextWrapWhitespaceVisible(System.IntPtr,System.Boolean)
public static bool SetTextWrapWidth(IntPtr text, int wrapWidth);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_SetTextWrapWidth(TTF_Text *text, int wrap_width);
Set whether wrapping is enabled on a text object. This function may cause the internal text representation to be rebuilt.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to modify. |
wrapWidth |
int |
the maximum width in pixels, 0 to wrap on newline characters. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.SetTextWrapWidth(System.IntPtr,System.Int32)
public static uint StringToTag(string string);SDL declaration
extern SDL_DECLSPEC Uint32 SDLCALL TTF_StringToTag(const char *string);
Convert from a 4 character string to a 32-bit tag.
Parameters
| Name | Type | Description |
|---|---|---|
string |
string |
the 4 character string to convert. |
Returns
the 32-bit representation of the string.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.StringToTag(System.String)
public static void TagToString(uint tag, out string string, UIntPtr size);SDL declaration
extern SDL_DECLSPEC void SDLCALL TTF_TagToString(Uint32 tag, char *string, size_t size);
Convert from a 32-bit tag to a 4 character string.
Parameters
| Name | Type | Description |
|---|---|---|
tag |
uint |
the 32-bit tag to convert. |
string |
out string |
a pointer filled in with the 4 character representation of the tag. |
size |
UIntPtr |
the size of the buffer pointed at by string, should be at least 4. |
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.TagToString(System.UInt32,System.String@,System.UIntPtr)
public static bool TextWrapWhitespaceVisible(IntPtr text);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_TextWrapWhitespaceVisible(TTF_Text *text);
Return whether whitespace is shown when wrapping a text object.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to query. |
Returns
true if whitespace is shown when wrapping text, or false otherwise.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.TextWrapWhitespaceVisible(System.IntPtr)
public static bool UpdateText(IntPtr text);SDL declaration
extern SDL_DECLSPEC bool SDLCALL TTF_UpdateText(TTF_Text *text);
Update the layout of a text object.
This is automatically done when the layout is requested or the text is rendered, but you can call this if you need more control over the timing of when the layout and text engine representation are updated.
Parameters
| Name | Type | Description |
|---|---|---|
text |
IntPtr |
the TTF.TTFText to update. |
Returns
true on success or false on failure; call SDL.GetError for more information.
Thread safety
This function should be called on the thread that created the text.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.UpdateText(System.IntPtr)
public static int Version();SDL declaration
extern SDL_DECLSPEC int SDLCALL TTF_Version(void);
This function gets the version of the dynamically linked SDL_ttf library.
Returns
SDL_ttf version.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.Version
public static int WasInit();SDL declaration
extern SDL_DECLSPEC int SDLCALL TTF_WasInit(void);
Check if SDL_ttf is initialized.
This reports the number of times the library has been initialized by a call to TTF.Init, without a paired deinitialization request from TTF.Quit.
In short: if it's greater than zero, the library is currently initialized and ready to work. If zero, it is not initialized.
Despite the return value being a signed integer, this function should not return a negative number.
Returns
the current number of initialization calls, that need to eventually be paired with this many calls to TTF.Quit.
Thread safety
It is safe to call this function from any thread.
Since: This function is available since SDL_ttf 3.0.0.
XML member id: M:SDL3.TTF.WasInit