Source code for SDL3_ttf

from sdl3.SDL import * # type: ignore
from sdl3 import SDL_POINTER

import ctypes, typing

LP_c_size_t: typing.TypeAlias = SDL_POINTER[ctypes.c_size_t]
LP_SDL_GPUDevice: typing.TypeAlias = SDL_POINTER[SDL_GPUDevice]
LP_TTF_ImageType: typing.TypeAlias = SDL_POINTER[TTF_ImageType]
LP_TTF_GPUAtlasDrawSequence: typing.TypeAlias = SDL_POINTER[TTF_GPUAtlasDrawSequence]
LP_c_float: typing.TypeAlias = SDL_POINTER[ctypes.c_float]
LP_TTF_TextEngine: typing.TypeAlias = SDL_POINTER[TTF_TextEngine]
LP_SDL_Renderer: typing.TypeAlias = SDL_POINTER[SDL_Renderer]
LP_TTF_Font: typing.TypeAlias = SDL_POINTER[TTF_Font]
LP_c_uint8: typing.TypeAlias = SDL_POINTER[ctypes.c_uint8]
LP_SDL_Surface: typing.TypeAlias = SDL_POINTER[SDL_Surface]
LP_c_int: typing.TypeAlias = SDL_POINTER[ctypes.c_int]
LP_SDL_IOStream: typing.TypeAlias = SDL_POINTER[SDL_IOStream]
LP_LP_TTF_SubString: typing.TypeAlias = SDL_POINTER[SDL_POINTER[TTF_SubString]]
LP_TTF_Text: typing.TypeAlias = SDL_POINTER[TTF_Text]
LP_TTF_SubString: typing.TypeAlias = SDL_POINTER[TTF_SubString]

[docs] def TTF_Version() -> ctypes.c_int: """ This function gets the version of the dynamically linked SDL_ttf library. """
[docs] def TTF_GetFreeTypeVersion(major: LP_c_int, minor: LP_c_int, patch: LP_c_int) -> None: """ Query the version of the FreeType library in use. """
[docs] def TTF_GetHarfBuzzVersion(major: LP_c_int, minor: LP_c_int, patch: LP_c_int) -> None: """ Query the version of the HarfBuzz library in use. """
[docs] def TTF_Init() -> ctypes.c_bool: """ Initialize SDL_ttf. """
[docs] def TTF_OpenFont(file: ctypes.c_char_p, ptsize: ctypes.c_float) -> LP_TTF_Font: """ Create a font from a file, using a specified point size. """
[docs] def TTF_OpenFontIO(src: LP_SDL_IOStream, closeio: ctypes.c_bool, ptsize: ctypes.c_float) -> LP_TTF_Font: """ Create a font from an SDL_IOStream, using a specified point size. """
[docs] def TTF_OpenFontWithProperties(props: SDL_PropertiesID) -> LP_TTF_Font: """ Create a font with the specified properties. """
[docs] def TTF_CopyFont(existing_font: LP_TTF_Font) -> LP_TTF_Font: """ Create a copy of an existing font. """
[docs] def TTF_GetFontProperties(font: LP_TTF_Font) -> SDL_PropertiesID: """ Get the properties associated with a font. """
[docs] def TTF_GetFontGeneration(font: LP_TTF_Font) -> ctypes.c_uint32: """ Get the font generation. """
[docs] def TTF_AddFallbackFont(font: LP_TTF_Font, fallback: LP_TTF_Font) -> ctypes.c_bool: """ Add a fallback font. """
[docs] def TTF_RemoveFallbackFont(font: LP_TTF_Font, fallback: LP_TTF_Font) -> None: """ Remove a fallback font. """
[docs] def TTF_ClearFallbackFonts(font: LP_TTF_Font) -> None: """ Remove all fallback fonts. """
[docs] def TTF_SetFontSize(font: LP_TTF_Font, ptsize: ctypes.c_float) -> ctypes.c_bool: """ Set a font's size dynamically. """
[docs] def TTF_SetFontSizeDPI(font: LP_TTF_Font, ptsize: ctypes.c_float, hdpi: ctypes.c_int, vdpi: ctypes.c_int) -> ctypes.c_bool: """ Set font size dynamically with target resolutions, in dots per inch. """
[docs] def TTF_GetFontSize(font: LP_TTF_Font) -> ctypes.c_float: """ Get the size of a font. """
[docs] def TTF_GetFontDPI(font: LP_TTF_Font, hdpi: LP_c_int, vdpi: LP_c_int) -> ctypes.c_bool: """ Get font target resolutions, in dots per inch. """
[docs] def TTF_SetFontStyle(font: LP_TTF_Font, style: TTF_FontStyleFlags) -> None: """ Set a font's current style. """
[docs] def TTF_GetFontStyle(font: LP_TTF_Font) -> TTF_FontStyleFlags: """ Query a font's current style. """
[docs] def TTF_SetFontOutline(font: LP_TTF_Font, outline: ctypes.c_int) -> ctypes.c_bool: """ Set a font's current outline. """
[docs] def TTF_GetFontOutline(font: LP_TTF_Font) -> ctypes.c_int: """ Query a font's current outline. """
[docs] def TTF_SetFontHinting(font: LP_TTF_Font, hinting: TTF_HintingFlags) -> None: """ Set a font's current hinter setting. """
[docs] def TTF_GetNumFontFaces(font: LP_TTF_Font) -> ctypes.c_int: """ Query the number of faces of a font. """
[docs] def TTF_GetFontHinting(font: LP_TTF_Font) -> TTF_HintingFlags: """ Query a font's current FreeType hinter setting. """
[docs] def TTF_SetFontSDF(font: LP_TTF_Font, enabled: ctypes.c_bool) -> ctypes.c_bool: """ Enable Signed Distance Field rendering for a font. """
[docs] def TTF_GetFontSDF(font: LP_TTF_Font) -> ctypes.c_bool: """ Query whether Signed Distance Field rendering is enabled for a font. """
[docs] def TTF_GetFontWeight(font: LP_TTF_Font) -> ctypes.c_int: """ Query a font's weight, in terms of the lightness/heaviness of the strokes. """
[docs] def TTF_SetFontWrapAlignment(font: LP_TTF_Font, align: TTF_HorizontalAlignment) -> None: """ Set a font's current wrap alignment option. """
[docs] def TTF_GetFontWrapAlignment(font: LP_TTF_Font) -> TTF_HorizontalAlignment: """ Query a font's current wrap alignment option. """
[docs] def TTF_GetFontHeight(font: LP_TTF_Font) -> ctypes.c_int: """ Query the total height of a font. """
[docs] def TTF_GetFontAscent(font: LP_TTF_Font) -> ctypes.c_int: """ Query the offset from the baseline to the top of a font. """
[docs] def TTF_GetFontDescent(font: LP_TTF_Font) -> ctypes.c_int: """ Query the offset from the baseline to the bottom of a font. """
[docs] def TTF_SetFontLineSkip(font: LP_TTF_Font, lineskip: ctypes.c_int) -> None: """ Set the spacing between lines of text for a font. """
[docs] def TTF_GetFontLineSkip(font: LP_TTF_Font) -> ctypes.c_int: """ Query the spacing between lines of text for a font. """
[docs] def TTF_SetFontKerning(font: LP_TTF_Font, enabled: ctypes.c_bool) -> None: """ Set if kerning is enabled for a font. """
[docs] def TTF_GetFontKerning(font: LP_TTF_Font) -> ctypes.c_bool: """ Query whether or not kerning is enabled for a font. """
[docs] def TTF_FontIsFixedWidth(font: LP_TTF_Font) -> ctypes.c_bool: """ Query whether a font is fixed-width. """
[docs] def TTF_FontIsScalable(font: LP_TTF_Font) -> ctypes.c_bool: """ Query whether a font is scalable or not. """
[docs] def TTF_GetFontFamilyName(font: LP_TTF_Font) -> ctypes.c_char_p: """ Query a font's family name. """
[docs] def TTF_GetFontStyleName(font: LP_TTF_Font) -> ctypes.c_char_p: """ Query a font's style name. """
[docs] def TTF_SetFontDirection(font: LP_TTF_Font, direction: TTF_Direction) -> ctypes.c_bool: """ Set the direction to be used for text shaping by a font. """
[docs] def TTF_GetFontDirection(font: LP_TTF_Font) -> TTF_Direction: """ Get the direction to be used for text shaping by a font. """
[docs] def TTF_StringToTag(string: ctypes.c_char_p) -> ctypes.c_uint32: """ Convert from a 4 character string to a 32-bit tag. """
[docs] def TTF_TagToString(tag: ctypes.c_uint32, string: ctypes.c_char_p, size: ctypes.c_size_t) -> None: """ Convert from a 32-bit tag to a 4 character string. """
[docs] def TTF_SetFontScript(font: LP_TTF_Font, script: ctypes.c_uint32) -> ctypes.c_bool: """ Set the script to be used for text shaping by a font. """
[docs] def TTF_GetFontScript(font: LP_TTF_Font) -> ctypes.c_uint32: """ Get the script used for text shaping a font. """
[docs] def TTF_GetGlyphScript(ch: ctypes.c_uint32) -> ctypes.c_uint32: """ Get the script used by a 32-bit codepoint. """
[docs] def TTF_SetFontLanguage(font: LP_TTF_Font, language_bcp47: ctypes.c_char_p) -> ctypes.c_bool: """ Set language to be used for text shaping by a font. """
[docs] def TTF_FontHasGlyph(font: LP_TTF_Font, ch: ctypes.c_uint32) -> ctypes.c_bool: """ Check whether a glyph is provided by the font for a UNICODE codepoint. """
[docs] def TTF_GetGlyphImage(font: LP_TTF_Font, ch: ctypes.c_uint32, image_type: LP_TTF_ImageType) -> LP_SDL_Surface: """ Get the pixel image for a UNICODE codepoint. """
[docs] def TTF_GetGlyphImageForIndex(font: LP_TTF_Font, glyph_index: ctypes.c_uint32, image_type: LP_TTF_ImageType) -> LP_SDL_Surface: """ Get the pixel image for a character index. """
[docs] def TTF_GetGlyphMetrics(font: LP_TTF_Font, ch: ctypes.c_uint32, minx: LP_c_int, maxx: LP_c_int, miny: LP_c_int, maxy: LP_c_int, advance: LP_c_int) -> ctypes.c_bool: """ Query the metrics (dimensions) of a font's glyph for a UNICODE codepoint. """
[docs] def TTF_GetGlyphKerning(font: LP_TTF_Font, previous_ch: ctypes.c_uint32, ch: ctypes.c_uint32, kerning: LP_c_int) -> ctypes.c_bool: """ Query the kerning size between the glyphs of two UNICODE codepoints. """
[docs] def TTF_GetStringSize(font: LP_TTF_Font, text: ctypes.c_char_p, length: ctypes.c_size_t, w: LP_c_int, h: LP_c_int) -> ctypes.c_bool: """ Calculate the dimensions of a rendered string of UTF-8 text. """
[docs] def TTF_GetStringSizeWrapped(font: LP_TTF_Font, text: ctypes.c_char_p, length: ctypes.c_size_t, wrap_width: ctypes.c_int, w: LP_c_int, h: LP_c_int) -> ctypes.c_bool: """ Calculate the dimensions of a rendered string of UTF-8 text. """
[docs] def TTF_MeasureString(font: LP_TTF_Font, text: ctypes.c_char_p, length: ctypes.c_size_t, max_width: ctypes.c_int, measured_width: LP_c_int, measured_length: LP_c_size_t) -> ctypes.c_bool: """ Calculate how much of a UTF-8 string will fit in a given width. """
[docs] def TTF_RenderText_Solid(font: LP_TTF_Font, text: ctypes.c_char_p, length: ctypes.c_size_t, fg: SDL_Color) -> LP_SDL_Surface: """ Render UTF-8 text at fast quality to a new 8-bit surface. """
[docs] def TTF_RenderText_Solid_Wrapped(font: LP_TTF_Font, text: ctypes.c_char_p, length: ctypes.c_size_t, fg: SDL_Color, wrapLength: ctypes.c_int) -> LP_SDL_Surface: """ Render word-wrapped UTF-8 text at fast quality to a new 8-bit surface. """
[docs] def TTF_RenderGlyph_Solid(font: LP_TTF_Font, ch: ctypes.c_uint32, fg: SDL_Color) -> LP_SDL_Surface: """ Render a single 32-bit glyph at fast quality to a new 8-bit surface. """
[docs] def TTF_RenderText_Shaded(font: LP_TTF_Font, text: ctypes.c_char_p, length: ctypes.c_size_t, fg: SDL_Color, bg: SDL_Color) -> LP_SDL_Surface: """ Render UTF-8 text at high quality to a new 8-bit surface. """
[docs] def TTF_RenderText_Shaded_Wrapped(font: LP_TTF_Font, text: ctypes.c_char_p, length: ctypes.c_size_t, fg: SDL_Color, bg: SDL_Color, wrap_width: ctypes.c_int) -> LP_SDL_Surface: """ Render word-wrapped UTF-8 text at high quality to a new 8-bit surface. """
[docs] def TTF_RenderGlyph_Shaded(font: LP_TTF_Font, ch: ctypes.c_uint32, fg: SDL_Color, bg: SDL_Color) -> LP_SDL_Surface: """ Render a single UNICODE codepoint at high quality to a new 8-bit surface. """
[docs] def TTF_RenderText_Blended(font: LP_TTF_Font, text: ctypes.c_char_p, length: ctypes.c_size_t, fg: SDL_Color) -> LP_SDL_Surface: """ Render UTF-8 text at high quality to a new ARGB surface. """
[docs] def TTF_RenderText_Blended_Wrapped(font: LP_TTF_Font, text: ctypes.c_char_p, length: ctypes.c_size_t, fg: SDL_Color, wrap_width: ctypes.c_int) -> LP_SDL_Surface: """ Render word-wrapped UTF-8 text at high quality to a new ARGB surface. """
[docs] def TTF_RenderGlyph_Blended(font: LP_TTF_Font, ch: ctypes.c_uint32, fg: SDL_Color) -> LP_SDL_Surface: """ Render a single UNICODE codepoint at high quality to a new ARGB surface. """
[docs] def TTF_RenderText_LCD(font: LP_TTF_Font, text: ctypes.c_char_p, length: ctypes.c_size_t, fg: SDL_Color, bg: SDL_Color) -> LP_SDL_Surface: """ Render UTF-8 text at LCD subpixel quality to a new ARGB surface. """
[docs] def TTF_RenderText_LCD_Wrapped(font: LP_TTF_Font, text: ctypes.c_char_p, length: ctypes.c_size_t, fg: SDL_Color, bg: SDL_Color, wrap_width: ctypes.c_int) -> LP_SDL_Surface: """ Render word-wrapped UTF-8 text at LCD subpixel quality to a new ARGB surface. """
[docs] def TTF_RenderGlyph_LCD(font: LP_TTF_Font, ch: ctypes.c_uint32, fg: SDL_Color, bg: SDL_Color) -> LP_SDL_Surface: """ Render a single UNICODE codepoint at LCD subpixel quality to a new ARGB surface. """
[docs] def TTF_CreateSurfaceTextEngine() -> LP_TTF_TextEngine: """ Create a text engine for drawing text on SDL surfaces. """
[docs] def TTF_DrawSurfaceText(text: LP_TTF_Text, x: ctypes.c_int, y: ctypes.c_int, surface: LP_SDL_Surface) -> ctypes.c_bool: """ Draw text to an SDL surface. """
[docs] def TTF_DestroySurfaceTextEngine(engine: LP_TTF_TextEngine) -> None: """ Destroy a text engine created for drawing text on SDL surfaces. """
[docs] def TTF_CreateRendererTextEngine(renderer: LP_SDL_Renderer) -> LP_TTF_TextEngine: """ Create a text engine for drawing text on an SDL renderer. """
[docs] def TTF_CreateRendererTextEngineWithProperties(props: SDL_PropertiesID) -> LP_TTF_TextEngine: """ Create a text engine for drawing text on an SDL renderer, with the specified properties. """
[docs] def TTF_DrawRendererText(text: LP_TTF_Text, x: ctypes.c_float, y: ctypes.c_float) -> ctypes.c_bool: """ Draw text to an SDL renderer. """
[docs] def TTF_DestroyRendererTextEngine(engine: LP_TTF_TextEngine) -> None: """ Destroy a text engine created for drawing text on an SDL renderer. """
[docs] def TTF_CreateGPUTextEngine(device: LP_SDL_GPUDevice) -> LP_TTF_TextEngine: """ Create a text engine for drawing text with the SDL GPU API. """
[docs] def TTF_CreateGPUTextEngineWithProperties(props: SDL_PropertiesID) -> LP_TTF_TextEngine: """ Create a text engine for drawing text with the SDL GPU API, with the specified properties. """
[docs] def TTF_GetGPUTextDrawData(text: LP_TTF_Text) -> LP_TTF_GPUAtlasDrawSequence: """ Get the geometry data needed for drawing the text. """
[docs] def TTF_DestroyGPUTextEngine(engine: LP_TTF_TextEngine) -> None: """ Destroy a text engine created for drawing text with the SDL GPU API. """
[docs] def TTF_SetGPUTextEngineWinding(engine: LP_TTF_TextEngine, winding: TTF_GPUTextEngineWinding) -> None: """ Sets the winding order of the vertices returned by TTF_GetGPUTextDrawData for a particular GPU text engine. """
[docs] def TTF_GetGPUTextEngineWinding(engine: LP_TTF_TextEngine) -> TTF_GPUTextEngineWinding: """ Get the winding order of the vertices returned by TTF_GetGPUTextDrawData for a particular GPU text engine """
[docs] def TTF_CreateText(engine: LP_TTF_TextEngine, font: LP_TTF_Font, text: ctypes.c_char_p, length: ctypes.c_size_t) -> LP_TTF_Text: """ Create a text object from UTF-8 text and a text engine. """
[docs] def TTF_GetTextProperties(text: LP_TTF_Text) -> SDL_PropertiesID: """ Get the properties associated with a text object. """
[docs] def TTF_SetTextEngine(text: LP_TTF_Text, engine: LP_TTF_TextEngine) -> ctypes.c_bool: """ Set the text engine used by a text object. """
[docs] def TTF_GetTextEngine(text: LP_TTF_Text) -> LP_TTF_TextEngine: """ Get the text engine used by a text object. """
[docs] def TTF_SetTextFont(text: LP_TTF_Text, font: LP_TTF_Font) -> ctypes.c_bool: """ Set the font used by a text object. """
[docs] def TTF_GetTextFont(text: LP_TTF_Text) -> LP_TTF_Font: """ Get the font used by a text object. """
[docs] def TTF_SetTextDirection(text: LP_TTF_Text, direction: TTF_Direction) -> ctypes.c_bool: """ Set the direction to be used for text shaping a text object. """
[docs] def TTF_GetTextDirection(text: LP_TTF_Text) -> TTF_Direction: """ Get the direction to be used for text shaping a text object. """
[docs] def TTF_SetTextScript(text: LP_TTF_Text, script: ctypes.c_uint32) -> ctypes.c_bool: """ Set the script to be used for text shaping a text object. """
[docs] def TTF_GetTextScript(text: LP_TTF_Text) -> ctypes.c_uint32: """ Get the script used for text shaping a text object. """
[docs] def TTF_SetTextColor(text: LP_TTF_Text, r: ctypes.c_uint8, g: ctypes.c_uint8, b: ctypes.c_uint8, a: ctypes.c_uint8) -> ctypes.c_bool: """ Set the color of a text object. """
[docs] def TTF_SetTextColorFloat(text: LP_TTF_Text, r: ctypes.c_float, g: ctypes.c_float, b: ctypes.c_float, a: ctypes.c_float) -> ctypes.c_bool: """ Set the color of a text object. """
[docs] def TTF_GetTextColor(text: LP_TTF_Text, r: LP_c_uint8, g: LP_c_uint8, b: LP_c_uint8, a: LP_c_uint8) -> ctypes.c_bool: """ Get the color of a text object. """
[docs] def TTF_GetTextColorFloat(text: LP_TTF_Text, r: LP_c_float, g: LP_c_float, b: LP_c_float, a: LP_c_float) -> ctypes.c_bool: """ Get the color of a text object. """
[docs] def TTF_SetTextPosition(text: LP_TTF_Text, x: ctypes.c_int, y: ctypes.c_int) -> ctypes.c_bool: """ Set the position of a text object. """
[docs] def TTF_GetTextPosition(text: LP_TTF_Text, x: LP_c_int, y: LP_c_int) -> ctypes.c_bool: """ Get the position of a text object. """
[docs] def TTF_SetTextWrapWidth(text: LP_TTF_Text, wrap_width: ctypes.c_int) -> ctypes.c_bool: """ Set whether wrapping is enabled on a text object. """
[docs] def TTF_GetTextWrapWidth(text: LP_TTF_Text, wrap_width: LP_c_int) -> ctypes.c_bool: """ Get whether wrapping is enabled on a text object. """
[docs] def TTF_SetTextWrapWhitespaceVisible(text: LP_TTF_Text, visible: ctypes.c_bool) -> ctypes.c_bool: """ Set whether whitespace should be visible when wrapping a text object. """
[docs] def TTF_TextWrapWhitespaceVisible(text: LP_TTF_Text) -> ctypes.c_bool: """ Return whether whitespace is shown when wrapping a text object. """
[docs] def TTF_SetTextString(text: LP_TTF_Text, string: ctypes.c_char_p, length: ctypes.c_size_t) -> ctypes.c_bool: """ Set the UTF-8 text used by a text object. """
[docs] def TTF_InsertTextString(text: LP_TTF_Text, offset: ctypes.c_int, string: ctypes.c_char_p, length: ctypes.c_size_t) -> ctypes.c_bool: """ Insert UTF-8 text into a text object. """
[docs] def TTF_AppendTextString(text: LP_TTF_Text, string: ctypes.c_char_p, length: ctypes.c_size_t) -> ctypes.c_bool: """ Append UTF-8 text to a text object. """
[docs] def TTF_DeleteTextString(text: LP_TTF_Text, offset: ctypes.c_int, length: ctypes.c_int) -> ctypes.c_bool: """ Delete UTF-8 text from a text object. """
[docs] def TTF_GetTextSize(text: LP_TTF_Text, w: LP_c_int, h: LP_c_int) -> ctypes.c_bool: """ Get the size of a text object. """
[docs] def TTF_GetTextSubString(text: LP_TTF_Text, offset: ctypes.c_int, substring: LP_TTF_SubString) -> ctypes.c_bool: """ Get the substring of a text object that surrounds a text offset. """
[docs] def TTF_GetTextSubStringForLine(text: LP_TTF_Text, line: ctypes.c_int, substring: LP_TTF_SubString) -> ctypes.c_bool: """ Get the substring of a text object that contains the given line. """
[docs] def TTF_GetTextSubStringsForRange(text: LP_TTF_Text, offset: ctypes.c_int, length: ctypes.c_int, count: LP_c_int) -> LP_LP_TTF_SubString: """ Get the substrings of a text object that contain a range of text. """
[docs] def TTF_GetTextSubStringForPoint(text: LP_TTF_Text, x: ctypes.c_int, y: ctypes.c_int, substring: LP_TTF_SubString) -> ctypes.c_bool: """ Get the portion of a text string that is closest to a point. """
[docs] def TTF_GetPreviousTextSubString(text: LP_TTF_Text, substring: LP_TTF_SubString, previous: LP_TTF_SubString) -> ctypes.c_bool: """ Get the previous substring in a text object """
[docs] def TTF_GetNextTextSubString(text: LP_TTF_Text, substring: LP_TTF_SubString, next: LP_TTF_SubString) -> ctypes.c_bool: """ Get the next substring in a text object """
[docs] def TTF_UpdateText(text: LP_TTF_Text) -> ctypes.c_bool: """ Update the layout of a text object. """
[docs] def TTF_DestroyText(text: LP_TTF_Text) -> None: """ Destroy a text object created by a text engine. """
[docs] def TTF_CloseFont(font: LP_TTF_Font) -> None: """ Dispose of a previously-created font. """
[docs] def TTF_Quit() -> None: """ Deinitialize SDL_ttf. """
[docs] def TTF_WasInit() -> ctypes.c_int: """ Check if SDL_ttf is initialized. """