sdl3_ttf_sys/generated/
ttf.rs

1//! Header file for SDL_ttf library
2//!
3//! This library is a wrapper around the excellent FreeType 2.0 library,
4//! available at: <https://www.freetype.org/>
5
6use sdl3_sys::everything::*;
7
8/// * Printable format: "%d.%d.%d", MAJOR, MINOR, MICRO
9pub const SDL_TTF_MAJOR_VERSION: ::core::primitive::i32 = 3;
10
11pub const SDL_TTF_MINOR_VERSION: ::core::primitive::i32 = 2;
12
13pub const SDL_TTF_MICRO_VERSION: ::core::primitive::i32 = 2;
14
15/// * This is the version number macro for the current SDL_ttf version.
16pub const SDL_TTF_VERSION: ::core::primitive::i32 = SDL_VERSIONNUM(
17    SDL_TTF_MAJOR_VERSION,
18    SDL_TTF_MINOR_VERSION,
19    SDL_TTF_MICRO_VERSION,
20);
21
22/// * This macro will evaluate to true if compiled with SDL_ttf at least X.Y.Z.
23#[inline(always)]
24pub const fn SDL_TTF_VERSION_ATLEAST(
25    X: ::core::primitive::i32,
26    Y: ::core::primitive::i32,
27    Z: ::core::primitive::i32,
28) -> ::core::primitive::bool {
29    (((SDL_TTF_MAJOR_VERSION >= X)
30        && ((SDL_TTF_MAJOR_VERSION > X) || (SDL_TTF_MINOR_VERSION >= Y)))
31        && (((SDL_TTF_MAJOR_VERSION > X) || (SDL_TTF_MINOR_VERSION > Y))
32            || (SDL_TTF_MICRO_VERSION >= Z)))
33}
34
35unsafe extern "C" {
36    /// This function gets the version of the dynamically linked SDL_ttf library.
37    ///
38    /// ## Return value
39    /// Returns SDL_ttf version.
40    ///
41    /// ## Thread safety
42    /// It is safe to call this function from any thread.
43    ///
44    /// ## Availability
45    /// This function is available since SDL_ttf 3.0.0.
46    pub safe fn TTF_Version() -> ::core::ffi::c_int;
47}
48
49unsafe extern "C" {
50    /// Query the version of the FreeType library in use.
51    ///
52    /// [`TTF_Init()`] should be called before calling this function.
53    ///
54    /// ## Parameters
55    /// - `major`: to be filled in with the major version number. Can be NULL.
56    /// - `minor`: to be filled in with the minor version number. Can be NULL.
57    /// - `patch`: to be filled in with the param version number. Can be NULL.
58    ///
59    /// ## Thread safety
60    /// It is safe to call this function from any thread.
61    ///
62    /// ## Availability
63    /// This function is available since SDL_ttf 3.0.0.
64    ///
65    /// ## See also
66    /// - [`TTF_Init`]
67    pub fn TTF_GetFreeTypeVersion(
68        major: *mut ::core::ffi::c_int,
69        minor: *mut ::core::ffi::c_int,
70        patch: *mut ::core::ffi::c_int,
71    );
72}
73
74unsafe extern "C" {
75    /// Query the version of the HarfBuzz library in use.
76    ///
77    /// If HarfBuzz is not available, the version reported is 0.0.0.
78    ///
79    /// ## Parameters
80    /// - `major`: to be filled in with the major version number. Can be NULL.
81    /// - `minor`: to be filled in with the minor version number. Can be NULL.
82    /// - `patch`: to be filled in with the param version number. Can be NULL.
83    ///
84    /// ## Thread safety
85    /// It is safe to call this function from any thread.
86    ///
87    /// ## Availability
88    /// This function is available since SDL_ttf 3.0.0.
89    pub fn TTF_GetHarfBuzzVersion(
90        major: *mut ::core::ffi::c_int,
91        minor: *mut ::core::ffi::c_int,
92        patch: *mut ::core::ffi::c_int,
93    );
94}
95
96unsafe extern "C" {
97    /// Initialize SDL_ttf.
98    ///
99    /// You must successfully call this function before it is safe to call any
100    /// other function in this library.
101    ///
102    /// It is safe to call this more than once, and each successful [`TTF_Init()`] call
103    /// should be paired with a matching [`TTF_Quit()`] call.
104    ///
105    /// ## Return value
106    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
107    ///   information.
108    ///
109    /// ## Availability
110    /// This function is available since SDL_ttf 3.0.0.
111    ///
112    /// ## See also
113    /// - [`TTF_Quit`]
114    pub fn TTF_Init() -> ::core::primitive::bool;
115}
116
117unsafe extern "C" {
118    /// Create a font from a file, using a specified point size.
119    ///
120    /// Some .fon fonts will have several sizes embedded in the file, so the point
121    /// size becomes the index of choosing which size. If the value is too high,
122    /// the last indexed size will be the default.
123    ///
124    /// When done with the returned [`TTF_Font`], use [`TTF_CloseFont()`] to dispose of it.
125    ///
126    /// ## Parameters
127    /// - `file`: path to font file.
128    /// - `ptsize`: point size to use for the newly-opened font.
129    ///
130    /// ## Return value
131    /// Returns a valid [`TTF_Font`], or NULL on failure; call [`SDL_GetError()`] for more
132    ///   information.
133    ///
134    /// ## Thread safety
135    /// It is safe to call this function from any thread.
136    ///
137    /// ## Availability
138    /// This function is available since SDL_ttf 3.0.0.
139    ///
140    /// ## See also
141    /// - [`TTF_CloseFont`]
142    pub fn TTF_OpenFont(
143        file: *const ::core::ffi::c_char,
144        ptsize: ::core::ffi::c_float,
145    ) -> *mut TTF_Font;
146}
147
148unsafe extern "C" {
149    /// Create a font from an [`SDL_IOStream`], using a specified point size.
150    ///
151    /// Some .fon fonts will have several sizes embedded in the file, so the point
152    /// size becomes the index of choosing which size. If the value is too high,
153    /// the last indexed size will be the default.
154    ///
155    /// If `closeio` is true, `src` will be automatically closed once the font is
156    /// closed. Otherwise you should close `src` yourself after closing the font.
157    ///
158    /// When done with the returned [`TTF_Font`], use [`TTF_CloseFont()`] to dispose of it.
159    ///
160    /// ## Parameters
161    /// - `src`: an [`SDL_IOStream`] to provide a font file's data.
162    /// - `closeio`: true to close `src` when the font is closed, false to leave
163    ///   it open.
164    /// - `ptsize`: point size to use for the newly-opened font.
165    ///
166    /// ## Return value
167    /// Returns a valid [`TTF_Font`], or NULL on failure; call [`SDL_GetError()`] for more
168    ///   information.
169    ///
170    /// ## Thread safety
171    /// It is safe to call this function from any thread.
172    ///
173    /// ## Availability
174    /// This function is available since SDL_ttf 3.0.0.
175    ///
176    /// ## See also
177    /// - [`TTF_CloseFont`]
178    pub fn TTF_OpenFontIO(
179        src: *mut SDL_IOStream,
180        closeio: ::core::primitive::bool,
181        ptsize: ::core::ffi::c_float,
182    ) -> *mut TTF_Font;
183}
184
185unsafe extern "C" {
186    /// Create a font with the specified properties.
187    ///
188    /// These are the supported properties:
189    ///
190    /// - [`TTF_PROP_FONT_CREATE_FILENAME_STRING`]\: the font file to open, if an
191    ///   [`SDL_IOStream`] isn't being used. This is required if
192    ///   [`TTF_PROP_FONT_CREATE_IOSTREAM_POINTER`] and
193    ///   [`TTF_PROP_FONT_CREATE_EXISTING_FONT`] aren't set.
194    /// - [`TTF_PROP_FONT_CREATE_IOSTREAM_POINTER`]\: an [`SDL_IOStream`] containing the
195    ///   font to be opened. This should not be closed until the font is closed.
196    ///   This is required if [`TTF_PROP_FONT_CREATE_FILENAME_STRING`] and
197    ///   [`TTF_PROP_FONT_CREATE_EXISTING_FONT`] aren't set.
198    /// - [`TTF_PROP_FONT_CREATE_IOSTREAM_OFFSET_NUMBER`]\: the offset in the iostream
199    ///   for the beginning of the font, defaults to 0.
200    /// - [`TTF_PROP_FONT_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN`]\: true if closing the
201    ///   font should also close the associated [`SDL_IOStream`].
202    /// - [`TTF_PROP_FONT_CREATE_SIZE_FLOAT`]\: the point size of the font. Some .fon
203    ///   fonts will have several sizes embedded in the file, so the point size
204    ///   becomes the index of choosing which size. If the value is too high, the
205    ///   last indexed size will be the default.
206    /// - [`TTF_PROP_FONT_CREATE_FACE_NUMBER`]\: the face index of the font, if the
207    ///   font contains multiple font faces.
208    /// - [`TTF_PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER`]\: the horizontal DPI to use
209    ///   for font rendering, defaults to
210    ///   [`TTF_PROP_FONT_CREATE_VERTICAL_DPI_NUMBER`] if set, or 72 otherwise.
211    /// - [`TTF_PROP_FONT_CREATE_VERTICAL_DPI_NUMBER`]\: the vertical DPI to use for
212    ///   font rendering, defaults to [`TTF_PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER`]
213    ///   if set, or 72 otherwise.
214    /// - [`TTF_PROP_FONT_CREATE_EXISTING_FONT`]\: an optional [`TTF_Font`] that, if set,
215    ///   will be used as the font data source and the initial size and style of
216    ///   the new font.
217    ///
218    /// ## Parameters
219    /// - `props`: the properties to use.
220    ///
221    /// ## Return value
222    /// Returns a valid [`TTF_Font`], or NULL on failure; call [`SDL_GetError()`] for more
223    ///   information.
224    ///
225    /// ## Thread safety
226    /// It is safe to call this function from any thread.
227    ///
228    /// ## Availability
229    /// This function is available since SDL_ttf 3.0.0.
230    ///
231    /// ## See also
232    /// - [`TTF_CloseFont`]
233    pub fn TTF_OpenFontWithProperties(props: SDL_PropertiesID) -> *mut TTF_Font;
234}
235
236pub const TTF_PROP_FONT_CREATE_FILENAME_STRING: *const ::core::ffi::c_char =
237    c"SDL_ttf.font.create.filename".as_ptr();
238
239pub const TTF_PROP_FONT_CREATE_IOSTREAM_POINTER: *const ::core::ffi::c_char =
240    c"SDL_ttf.font.create.iostream".as_ptr();
241
242pub const TTF_PROP_FONT_CREATE_IOSTREAM_OFFSET_NUMBER: *const ::core::ffi::c_char =
243    c"SDL_ttf.font.create.iostream.offset".as_ptr();
244
245pub const TTF_PROP_FONT_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN: *const ::core::ffi::c_char =
246    c"SDL_ttf.font.create.iostream.autoclose".as_ptr();
247
248pub const TTF_PROP_FONT_CREATE_SIZE_FLOAT: *const ::core::ffi::c_char =
249    c"SDL_ttf.font.create.size".as_ptr();
250
251pub const TTF_PROP_FONT_CREATE_FACE_NUMBER: *const ::core::ffi::c_char =
252    c"SDL_ttf.font.create.face".as_ptr();
253
254pub const TTF_PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER: *const ::core::ffi::c_char =
255    c"SDL_ttf.font.create.hdpi".as_ptr();
256
257pub const TTF_PROP_FONT_CREATE_VERTICAL_DPI_NUMBER: *const ::core::ffi::c_char =
258    c"SDL_ttf.font.create.vdpi".as_ptr();
259
260pub const TTF_PROP_FONT_CREATE_EXISTING_FONT: *const ::core::ffi::c_char =
261    c"SDL_ttf.font.create.existing_font".as_ptr();
262
263unsafe extern "C" {
264    /// Create a copy of an existing font.
265    ///
266    /// The copy will be distinct from the original, but will share the font file
267    /// and have the same size and style as the original.
268    ///
269    /// When done with the returned [`TTF_Font`], use [`TTF_CloseFont()`] to dispose of it.
270    ///
271    /// ## Parameters
272    /// - `existing_font`: the font to copy.
273    ///
274    /// ## Return value
275    /// Returns a valid [`TTF_Font`], or NULL on failure; call [`SDL_GetError()`] for more
276    ///   information.
277    ///
278    /// ## Thread safety
279    /// This function should be called on the thread that created the
280    ///   original font.
281    ///
282    /// ## Availability
283    /// This function is available since SDL_ttf 3.0.0.
284    ///
285    /// ## See also
286    /// - [`TTF_CloseFont`]
287    pub fn TTF_CopyFont(existing_font: *mut TTF_Font) -> *mut TTF_Font;
288}
289
290unsafe extern "C" {
291    /// Get the properties associated with a font.
292    ///
293    /// The following read-write properties are provided by SDL:
294    ///
295    /// - [`TTF_PROP_FONT_OUTLINE_LINE_CAP_NUMBER`]\: The FT_Stroker_LineCap value
296    ///   used when setting the font outline, defaults to
297    ///   `FT_STROKER_LINECAP_ROUND`.
298    /// - [`TTF_PROP_FONT_OUTLINE_LINE_JOIN_NUMBER`]\: The FT_Stroker_LineJoin value
299    ///   used when setting the font outline, defaults to
300    ///   `FT_STROKER_LINEJOIN_ROUND`.
301    /// - [`TTF_PROP_FONT_OUTLINE_MITER_LIMIT_NUMBER`]\: The FT_Fixed miter limit used
302    ///   when setting the font outline, defaults to 0.
303    ///
304    /// ## Parameters
305    /// - `font`: the font to query.
306    ///
307    /// ## Return value
308    /// Returns a valid property ID on success or 0 on failure; call
309    ///   [`SDL_GetError()`] for more information.
310    ///
311    /// ## Thread safety
312    /// It is safe to call this function from any thread.
313    ///
314    /// ## Availability
315    /// This function is available since SDL_ttf 3.0.0.
316    pub fn TTF_GetFontProperties(font: *mut TTF_Font) -> SDL_PropertiesID;
317}
318
319pub const TTF_PROP_FONT_OUTLINE_LINE_CAP_NUMBER: *const ::core::ffi::c_char =
320    c"SDL_ttf.font.outline.line_cap".as_ptr();
321
322pub const TTF_PROP_FONT_OUTLINE_LINE_JOIN_NUMBER: *const ::core::ffi::c_char =
323    c"SDL_ttf.font.outline.line_join".as_ptr();
324
325pub const TTF_PROP_FONT_OUTLINE_MITER_LIMIT_NUMBER: *const ::core::ffi::c_char =
326    c"SDL_ttf.font.outline.miter_limit".as_ptr();
327
328unsafe extern "C" {
329    /// Get the font generation.
330    ///
331    /// The generation is incremented each time font properties change that require
332    /// rebuilding glyphs, such as style, size, etc.
333    ///
334    /// ## Parameters
335    /// - `font`: the font to query.
336    ///
337    /// ## Return value
338    /// Returns the font generation or 0 on failure; call [`SDL_GetError()`] for more
339    ///   information.
340    ///
341    /// ## Thread safety
342    /// This function should be called on the thread that created the
343    ///   font.
344    ///
345    /// ## Availability
346    /// This function is available since SDL_ttf 3.0.0.
347    pub fn TTF_GetFontGeneration(font: *mut TTF_Font) -> Uint32;
348}
349
350unsafe extern "C" {
351    /// Add a fallback font.
352    ///
353    /// Add a font that will be used for glyphs that are not in the current font.
354    /// The fallback font should have the same size and style as the current font.
355    ///
356    /// If there are multiple fallback fonts, they are used in the order added.
357    ///
358    /// This updates any [`TTF_Text`] objects using this font.
359    ///
360    /// ## Parameters
361    /// - `font`: the font to modify.
362    /// - `fallback`: the font to add as a fallback.
363    ///
364    /// ## Return value
365    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
366    ///   information.
367    ///
368    /// ## Thread safety
369    /// This function should be called on the thread that created
370    ///   both fonts.
371    ///
372    /// ## Availability
373    /// This function is available since SDL_ttf 3.0.0.
374    ///
375    /// ## See also
376    /// - [`TTF_ClearFallbackFonts`]
377    /// - [`TTF_RemoveFallbackFont`]
378    pub fn TTF_AddFallbackFont(
379        font: *mut TTF_Font,
380        fallback: *mut TTF_Font,
381    ) -> ::core::primitive::bool;
382}
383
384unsafe extern "C" {
385    /// Remove a fallback font.
386    ///
387    /// This updates any [`TTF_Text`] objects using this font.
388    ///
389    /// ## Parameters
390    /// - `font`: the font to modify.
391    /// - `fallback`: the font to remove as a fallback.
392    ///
393    /// ## Thread safety
394    /// This function should be called on the thread that created
395    ///   both fonts.
396    ///
397    /// ## Availability
398    /// This function is available since SDL_ttf 3.0.0.
399    ///
400    /// ## See also
401    /// - [`TTF_AddFallbackFont`]
402    /// - [`TTF_ClearFallbackFonts`]
403    pub fn TTF_RemoveFallbackFont(font: *mut TTF_Font, fallback: *mut TTF_Font);
404}
405
406unsafe extern "C" {
407    /// Remove all fallback fonts.
408    ///
409    /// This updates any [`TTF_Text`] objects using this font.
410    ///
411    /// ## Parameters
412    /// - `font`: the font to modify.
413    ///
414    /// ## Thread safety
415    /// This function should be called on the thread that created the
416    ///   font.
417    ///
418    /// ## Availability
419    /// This function is available since SDL_ttf 3.0.0.
420    ///
421    /// ## See also
422    /// - [`TTF_AddFallbackFont`]
423    /// - [`TTF_RemoveFallbackFont`]
424    pub fn TTF_ClearFallbackFonts(font: *mut TTF_Font);
425}
426
427unsafe extern "C" {
428    /// Set a font's size dynamically.
429    ///
430    /// This updates any [`TTF_Text`] objects using this font, and clears
431    /// already-generated glyphs, if any, from the cache.
432    ///
433    /// ## Parameters
434    /// - `font`: the font to resize.
435    /// - `ptsize`: the new point size.
436    ///
437    /// ## Return value
438    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
439    ///   information.
440    ///
441    /// ## Thread safety
442    /// This function should be called on the thread that created the
443    ///   font.
444    ///
445    /// ## Availability
446    /// This function is available since SDL_ttf 3.0.0.
447    ///
448    /// ## See also
449    /// - [`TTF_GetFontSize`]
450    pub fn TTF_SetFontSize(
451        font: *mut TTF_Font,
452        ptsize: ::core::ffi::c_float,
453    ) -> ::core::primitive::bool;
454}
455
456unsafe extern "C" {
457    /// Set font size dynamically with target resolutions, in dots per inch.
458    ///
459    /// This updates any [`TTF_Text`] objects using this font, and clears
460    /// already-generated glyphs, if any, from the cache.
461    ///
462    /// ## Parameters
463    /// - `font`: the font to resize.
464    /// - `ptsize`: the new point size.
465    /// - `hdpi`: the target horizontal DPI.
466    /// - `vdpi`: the target vertical DPI.
467    ///
468    /// ## Return value
469    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
470    ///   information.
471    ///
472    /// ## Thread safety
473    /// This function should be called on the thread that created the
474    ///   font.
475    ///
476    /// ## Availability
477    /// This function is available since SDL_ttf 3.0.0.
478    ///
479    /// ## See also
480    /// - [`TTF_GetFontSize`]
481    /// - [`TTF_GetFontSizeDPI`]
482    pub fn TTF_SetFontSizeDPI(
483        font: *mut TTF_Font,
484        ptsize: ::core::ffi::c_float,
485        hdpi: ::core::ffi::c_int,
486        vdpi: ::core::ffi::c_int,
487    ) -> ::core::primitive::bool;
488}
489
490unsafe extern "C" {
491    /// Get the size of a font.
492    ///
493    /// ## Parameters
494    /// - `font`: the font to query.
495    ///
496    /// ## Return value
497    /// Returns the size of the font, or 0.0f on failure; call [`SDL_GetError()`] for
498    ///   more information.
499    ///
500    /// ## Thread safety
501    /// This function should be called on the thread that created the
502    ///   font.
503    ///
504    /// ## Availability
505    /// This function is available since SDL_ttf 3.0.0.
506    ///
507    /// ## See also
508    /// - [`TTF_SetFontSize`]
509    /// - [`TTF_SetFontSizeDPI`]
510    pub fn TTF_GetFontSize(font: *mut TTF_Font) -> ::core::ffi::c_float;
511}
512
513unsafe extern "C" {
514    /// Get font target resolutions, in dots per inch.
515    ///
516    /// ## Parameters
517    /// - `font`: the font to query.
518    /// - `hdpi`: a pointer filled in with the target horizontal DPI.
519    /// - `vdpi`: a pointer filled in with the target vertical DPI.
520    ///
521    /// ## Return value
522    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
523    ///   information.
524    ///
525    /// ## Thread safety
526    /// This function should be called on the thread that created the
527    ///   font.
528    ///
529    /// ## Availability
530    /// This function is available since SDL_ttf 3.0.0.
531    ///
532    /// ## See also
533    /// - [`TTF_SetFontSizeDPI`]
534    pub fn TTF_GetFontDPI(
535        font: *mut TTF_Font,
536        hdpi: *mut ::core::ffi::c_int,
537        vdpi: *mut ::core::ffi::c_int,
538    ) -> ::core::primitive::bool;
539}
540
541/// Font style flags for [`TTF_Font`]
542///
543/// These are the flags which can be used to set the style of a font in
544/// SDL_ttf. A combination of these flags can be used with functions that set
545/// or query font style, such as [`TTF_SetFontStyle`] or [`TTF_GetFontStyle`].
546///
547/// ## Availability
548/// This datatype is available since SDL_ttf 3.0.0.
549///
550/// ## See also
551/// - [`TTF_SetFontStyle`]
552/// - [`TTF_GetFontStyle`]
553///
554/// ## Known values (`sdl3-sys`)
555/// | Associated constant | Global constant | Description |
556/// | ------------------- | --------------- | ----------- |
557/// | [`NORMAL`](TTF_FontStyleFlags::NORMAL) | [`TTF_STYLE_NORMAL`] | No special style |
558/// | [`BOLD`](TTF_FontStyleFlags::BOLD) | [`TTF_STYLE_BOLD`] | Bold style |
559/// | [`ITALIC`](TTF_FontStyleFlags::ITALIC) | [`TTF_STYLE_ITALIC`] | Italic style |
560/// | [`UNDERLINE`](TTF_FontStyleFlags::UNDERLINE) | [`TTF_STYLE_UNDERLINE`] | Underlined text |
561/// | [`STRIKETHROUGH`](TTF_FontStyleFlags::STRIKETHROUGH) | [`TTF_STYLE_STRIKETHROUGH`] | Strikethrough text |
562#[repr(transparent)]
563#[derive(Clone, Copy, Default, PartialEq, Eq, Hash)]
564pub struct TTF_FontStyleFlags(pub Uint32);
565
566impl ::core::cmp::PartialEq<Uint32> for TTF_FontStyleFlags {
567    #[inline(always)]
568    fn eq(&self, other: &Uint32) -> bool {
569        &self.0 == other
570    }
571}
572
573impl ::core::cmp::PartialEq<TTF_FontStyleFlags> for Uint32 {
574    #[inline(always)]
575    fn eq(&self, other: &TTF_FontStyleFlags) -> bool {
576        self == &other.0
577    }
578}
579
580impl From<TTF_FontStyleFlags> for Uint32 {
581    #[inline(always)]
582    fn from(value: TTF_FontStyleFlags) -> Self {
583        value.0
584    }
585}
586
587#[cfg(feature = "debug-impls")]
588impl ::core::fmt::Debug for TTF_FontStyleFlags {
589    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
590        let mut first = true;
591        let all_bits = 0;
592        write!(f, "TTF_FontStyleFlags(")?;
593        let all_bits = all_bits | Self::NORMAL.0;
594        if (Self::NORMAL != 0 || self.0 == 0) && *self & Self::NORMAL == Self::NORMAL {
595            if !first {
596                write!(f, " | ")?;
597            }
598            first = false;
599            write!(f, "NORMAL")?;
600        }
601        let all_bits = all_bits | Self::BOLD.0;
602        if (Self::BOLD != 0 || self.0 == 0) && *self & Self::BOLD == Self::BOLD {
603            if !first {
604                write!(f, " | ")?;
605            }
606            first = false;
607            write!(f, "BOLD")?;
608        }
609        let all_bits = all_bits | Self::ITALIC.0;
610        if (Self::ITALIC != 0 || self.0 == 0) && *self & Self::ITALIC == Self::ITALIC {
611            if !first {
612                write!(f, " | ")?;
613            }
614            first = false;
615            write!(f, "ITALIC")?;
616        }
617        let all_bits = all_bits | Self::UNDERLINE.0;
618        if (Self::UNDERLINE != 0 || self.0 == 0) && *self & Self::UNDERLINE == Self::UNDERLINE {
619            if !first {
620                write!(f, " | ")?;
621            }
622            first = false;
623            write!(f, "UNDERLINE")?;
624        }
625        let all_bits = all_bits | Self::STRIKETHROUGH.0;
626        if (Self::STRIKETHROUGH != 0 || self.0 == 0)
627            && *self & Self::STRIKETHROUGH == Self::STRIKETHROUGH
628        {
629            if !first {
630                write!(f, " | ")?;
631            }
632            first = false;
633            write!(f, "STRIKETHROUGH")?;
634        }
635
636        if self.0 & !all_bits != 0 {
637            if !first {
638                write!(f, " | ")?;
639            }
640            write!(f, "{:#x}", self.0)?;
641        } else if first {
642            write!(f, "0")?;
643        }
644        write!(f, ")")
645    }
646}
647
648impl ::core::ops::BitAnd for TTF_FontStyleFlags {
649    type Output = Self;
650
651    #[inline(always)]
652    fn bitand(self, rhs: Self) -> Self::Output {
653        Self(self.0 & rhs.0)
654    }
655}
656
657impl ::core::ops::BitAndAssign for TTF_FontStyleFlags {
658    #[inline(always)]
659    fn bitand_assign(&mut self, rhs: Self) {
660        self.0 &= rhs.0;
661    }
662}
663
664impl ::core::ops::BitOr for TTF_FontStyleFlags {
665    type Output = Self;
666
667    #[inline(always)]
668    fn bitor(self, rhs: Self) -> Self::Output {
669        Self(self.0 | rhs.0)
670    }
671}
672
673impl ::core::ops::BitOrAssign for TTF_FontStyleFlags {
674    #[inline(always)]
675    fn bitor_assign(&mut self, rhs: Self) {
676        self.0 |= rhs.0;
677    }
678}
679
680impl ::core::ops::BitXor for TTF_FontStyleFlags {
681    type Output = Self;
682
683    #[inline(always)]
684    fn bitxor(self, rhs: Self) -> Self::Output {
685        Self(self.0 ^ rhs.0)
686    }
687}
688
689impl ::core::ops::BitXorAssign for TTF_FontStyleFlags {
690    #[inline(always)]
691    fn bitxor_assign(&mut self, rhs: Self) {
692        self.0 ^= rhs.0;
693    }
694}
695
696impl ::core::ops::Not for TTF_FontStyleFlags {
697    type Output = Self;
698
699    #[inline(always)]
700    fn not(self) -> Self::Output {
701        Self(!self.0)
702    }
703}
704
705impl TTF_FontStyleFlags {
706    /// No special style
707    pub const NORMAL: Self = Self((0x00 as Uint32));
708    /// Bold style
709    pub const BOLD: Self = Self((0x01 as Uint32));
710    /// Italic style
711    pub const ITALIC: Self = Self((0x02 as Uint32));
712    /// Underlined text
713    pub const UNDERLINE: Self = Self((0x04 as Uint32));
714    /// Strikethrough text
715    pub const STRIKETHROUGH: Self = Self((0x08 as Uint32));
716}
717
718/// No special style
719pub const TTF_STYLE_NORMAL: TTF_FontStyleFlags = TTF_FontStyleFlags::NORMAL;
720/// Bold style
721pub const TTF_STYLE_BOLD: TTF_FontStyleFlags = TTF_FontStyleFlags::BOLD;
722/// Italic style
723pub const TTF_STYLE_ITALIC: TTF_FontStyleFlags = TTF_FontStyleFlags::ITALIC;
724/// Underlined text
725pub const TTF_STYLE_UNDERLINE: TTF_FontStyleFlags = TTF_FontStyleFlags::UNDERLINE;
726/// Strikethrough text
727pub const TTF_STYLE_STRIKETHROUGH: TTF_FontStyleFlags = TTF_FontStyleFlags::STRIKETHROUGH;
728
729#[cfg(feature = "metadata")]
730impl sdl3_sys::metadata::GroupMetadata for TTF_FontStyleFlags {
731    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
732        &crate::metadata::ttf::METADATA_TTF_FontStyleFlags;
733}
734
735unsafe extern "C" {
736    /// Set a font's current style.
737    ///
738    /// This updates any [`TTF_Text`] objects using this font, and clears
739    /// already-generated glyphs, if any, from the cache.
740    ///
741    /// The font styles are a set of bit flags, OR'd together:
742    ///
743    /// - [`TTF_STYLE_NORMAL`] (is zero)
744    /// - [`TTF_STYLE_BOLD`]
745    /// - [`TTF_STYLE_ITALIC`]
746    /// - [`TTF_STYLE_UNDERLINE`]
747    /// - [`TTF_STYLE_STRIKETHROUGH`]
748    ///
749    /// ## Parameters
750    /// - `font`: the font to set a new style on.
751    /// - `style`: the new style values to set, OR'd together.
752    ///
753    /// ## Thread safety
754    /// This function should be called on the thread that created the
755    ///   font.
756    ///
757    /// ## Availability
758    /// This function is available since SDL_ttf 3.0.0.
759    ///
760    /// ## See also
761    /// - [`TTF_GetFontStyle`]
762    pub fn TTF_SetFontStyle(font: *mut TTF_Font, style: TTF_FontStyleFlags);
763}
764
765unsafe extern "C" {
766    /// Query a font's current style.
767    ///
768    /// The font styles are a set of bit flags, OR'd together:
769    ///
770    /// - [`TTF_STYLE_NORMAL`] (is zero)
771    /// - [`TTF_STYLE_BOLD`]
772    /// - [`TTF_STYLE_ITALIC`]
773    /// - [`TTF_STYLE_UNDERLINE`]
774    /// - [`TTF_STYLE_STRIKETHROUGH`]
775    ///
776    /// ## Parameters
777    /// - `font`: the font to query.
778    ///
779    /// ## Return value
780    /// Returns the current font style, as a set of bit flags.
781    ///
782    /// ## Thread safety
783    /// It is safe to call this function from any thread.
784    ///
785    /// ## Availability
786    /// This function is available since SDL_ttf 3.0.0.
787    ///
788    /// ## See also
789    /// - [`TTF_SetFontStyle`]
790    pub fn TTF_GetFontStyle(font: *const TTF_Font) -> TTF_FontStyleFlags;
791}
792
793unsafe extern "C" {
794    /// Set a font's current outline.
795    ///
796    /// This uses the font properties [`TTF_PROP_FONT_OUTLINE_LINE_CAP_NUMBER`],
797    /// [`TTF_PROP_FONT_OUTLINE_LINE_JOIN_NUMBER`], and
798    /// [`TTF_PROP_FONT_OUTLINE_MITER_LIMIT_NUMBER`] when setting the font outline.
799    ///
800    /// This updates any [`TTF_Text`] objects using this font, and clears
801    /// already-generated glyphs, if any, from the cache.
802    ///
803    /// ## Parameters
804    /// - `font`: the font to set a new outline on.
805    /// - `outline`: positive outline value, 0 to default.
806    ///
807    /// ## Return value
808    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
809    ///   information.
810    ///
811    /// ## Thread safety
812    /// This function should be called on the thread that created the
813    ///   font.
814    ///
815    /// ## Availability
816    /// This function is available since SDL_ttf 3.0.0.
817    ///
818    /// ## See also
819    /// - [`TTF_GetFontOutline`]
820    pub fn TTF_SetFontOutline(
821        font: *mut TTF_Font,
822        outline: ::core::ffi::c_int,
823    ) -> ::core::primitive::bool;
824}
825
826unsafe extern "C" {
827    /// Query a font's current outline.
828    ///
829    /// ## Parameters
830    /// - `font`: the font to query.
831    ///
832    /// ## Return value
833    /// Returns the font's current outline value.
834    ///
835    /// ## Thread safety
836    /// It is safe to call this function from any thread.
837    ///
838    /// ## Availability
839    /// This function is available since SDL_ttf 3.0.0.
840    ///
841    /// ## See also
842    /// - [`TTF_SetFontOutline`]
843    pub fn TTF_GetFontOutline(font: *const TTF_Font) -> ::core::ffi::c_int;
844}
845
846/// Hinting flags for TTF (TrueType Fonts)
847///
848/// This enum specifies the level of hinting to be applied to the font
849/// rendering. The hinting level determines how much the font's outlines are
850/// adjusted for better alignment on the pixel grid.
851///
852/// ## Availability
853/// This enum is available since SDL_ttf 3.0.0.
854///
855/// ## See also
856/// - [`TTF_SetFontHinting`]
857/// - [`TTF_GetFontHinting`]
858///
859/// ## Known values (`sdl3-sys`)
860/// | Associated constant | Global constant | Description |
861/// | ------------------- | --------------- | ----------- |
862/// | [`INVALID`](TTF_HintingFlags::INVALID) | [`TTF_HINTING_INVALID`] | |
863/// | [`NORMAL`](TTF_HintingFlags::NORMAL) | [`TTF_HINTING_NORMAL`] | Normal hinting applies standard grid-fitting. |
864/// | [`LIGHT`](TTF_HintingFlags::LIGHT) | [`TTF_HINTING_LIGHT`] | Light hinting applies subtle adjustments to improve rendering. |
865/// | [`MONO`](TTF_HintingFlags::MONO) | [`TTF_HINTING_MONO`] | Monochrome hinting adjusts the font for better rendering at lower resolutions. |
866/// | [`NONE`](TTF_HintingFlags::NONE) | [`TTF_HINTING_NONE`] | No hinting, the font is rendered without any grid-fitting. |
867/// | [`LIGHT_SUBPIXEL`](TTF_HintingFlags::LIGHT_SUBPIXEL) | [`TTF_HINTING_LIGHT_SUBPIXEL`] | Light hinting with subpixel rendering for more precise font edges. |
868#[repr(transparent)]
869#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
870pub struct TTF_HintingFlags(pub ::core::ffi::c_int);
871
872impl ::core::cmp::PartialEq<::core::ffi::c_int> for TTF_HintingFlags {
873    #[inline(always)]
874    fn eq(&self, other: &::core::ffi::c_int) -> bool {
875        &self.0 == other
876    }
877}
878
879impl ::core::cmp::PartialEq<TTF_HintingFlags> for ::core::ffi::c_int {
880    #[inline(always)]
881    fn eq(&self, other: &TTF_HintingFlags) -> bool {
882        self == &other.0
883    }
884}
885
886impl From<TTF_HintingFlags> for ::core::ffi::c_int {
887    #[inline(always)]
888    fn from(value: TTF_HintingFlags) -> Self {
889        value.0
890    }
891}
892
893#[cfg(feature = "debug-impls")]
894impl ::core::fmt::Debug for TTF_HintingFlags {
895    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
896        #[allow(unreachable_patterns)]
897        f.write_str(match *self {
898            Self::INVALID => "TTF_HINTING_INVALID",
899            Self::NORMAL => "TTF_HINTING_NORMAL",
900            Self::LIGHT => "TTF_HINTING_LIGHT",
901            Self::MONO => "TTF_HINTING_MONO",
902            Self::NONE => "TTF_HINTING_NONE",
903            Self::LIGHT_SUBPIXEL => "TTF_HINTING_LIGHT_SUBPIXEL",
904
905            _ => return write!(f, "TTF_HintingFlags({})", self.0),
906        })
907    }
908}
909
910impl TTF_HintingFlags {
911    pub const INVALID: Self = Self((-1_i32 as ::core::ffi::c_int));
912    /// Normal hinting applies standard grid-fitting.
913    pub const NORMAL: Self = Self((0_i32 as ::core::ffi::c_int));
914    /// Light hinting applies subtle adjustments to improve rendering.
915    pub const LIGHT: Self = Self((1_i32 as ::core::ffi::c_int));
916    /// Monochrome hinting adjusts the font for better rendering at lower resolutions.
917    pub const MONO: Self = Self((2_i32 as ::core::ffi::c_int));
918    /// No hinting, the font is rendered without any grid-fitting.
919    pub const NONE: Self = Self((3_i32 as ::core::ffi::c_int));
920    /// Light hinting with subpixel rendering for more precise font edges.
921    pub const LIGHT_SUBPIXEL: Self = Self((4_i32 as ::core::ffi::c_int));
922}
923
924pub const TTF_HINTING_INVALID: TTF_HintingFlags = TTF_HintingFlags::INVALID;
925/// Normal hinting applies standard grid-fitting.
926pub const TTF_HINTING_NORMAL: TTF_HintingFlags = TTF_HintingFlags::NORMAL;
927/// Light hinting applies subtle adjustments to improve rendering.
928pub const TTF_HINTING_LIGHT: TTF_HintingFlags = TTF_HintingFlags::LIGHT;
929/// Monochrome hinting adjusts the font for better rendering at lower resolutions.
930pub const TTF_HINTING_MONO: TTF_HintingFlags = TTF_HintingFlags::MONO;
931/// No hinting, the font is rendered without any grid-fitting.
932pub const TTF_HINTING_NONE: TTF_HintingFlags = TTF_HintingFlags::NONE;
933/// Light hinting with subpixel rendering for more precise font edges.
934pub const TTF_HINTING_LIGHT_SUBPIXEL: TTF_HintingFlags = TTF_HintingFlags::LIGHT_SUBPIXEL;
935
936#[cfg(feature = "metadata")]
937impl sdl3_sys::metadata::GroupMetadata for TTF_HintingFlags {
938    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
939        &crate::metadata::ttf::METADATA_TTF_HintingFlags;
940}
941
942unsafe extern "C" {
943    /// Set a font's current hinter setting.
944    ///
945    /// This updates any [`TTF_Text`] objects using this font, and clears
946    /// already-generated glyphs, if any, from the cache.
947    ///
948    /// The hinter setting is a single value:
949    ///
950    /// - [`TTF_HINTING_NORMAL`]
951    /// - [`TTF_HINTING_LIGHT`]
952    /// - [`TTF_HINTING_MONO`]
953    /// - [`TTF_HINTING_NONE`]
954    /// - [`TTF_HINTING_LIGHT_SUBPIXEL`] (available in SDL_ttf 3.0.0 and later)
955    ///
956    /// ## Parameters
957    /// - `font`: the font to set a new hinter setting on.
958    /// - `hinting`: the new hinter setting.
959    ///
960    /// ## Thread safety
961    /// This function should be called on the thread that created the
962    ///   font.
963    ///
964    /// ## Availability
965    /// This function is available since SDL_ttf 3.0.0.
966    ///
967    /// ## See also
968    /// - [`TTF_GetFontHinting`]
969    pub fn TTF_SetFontHinting(font: *mut TTF_Font, hinting: TTF_HintingFlags);
970}
971
972unsafe extern "C" {
973    /// Query the number of faces of a font.
974    ///
975    /// ## Parameters
976    /// - `font`: the font to query.
977    ///
978    /// ## Return value
979    /// Returns the number of FreeType font faces.
980    ///
981    /// ## Thread safety
982    /// It is safe to call this function from any thread.
983    ///
984    /// ## Availability
985    /// This function is available since SDL_ttf 3.0.0.
986    pub fn TTF_GetNumFontFaces(font: *const TTF_Font) -> ::core::ffi::c_int;
987}
988
989unsafe extern "C" {
990    /// Query a font's current FreeType hinter setting.
991    ///
992    /// The hinter setting is a single value:
993    ///
994    /// - [`TTF_HINTING_NORMAL`]
995    /// - [`TTF_HINTING_LIGHT`]
996    /// - [`TTF_HINTING_MONO`]
997    /// - [`TTF_HINTING_NONE`]
998    /// - [`TTF_HINTING_LIGHT_SUBPIXEL`] (available in SDL_ttf 3.0.0 and later)
999    ///
1000    /// ## Parameters
1001    /// - `font`: the font to query.
1002    ///
1003    /// ## Return value
1004    /// Returns the font's current hinter value, or [`TTF_HINTING_INVALID`] if the
1005    ///   font is invalid.
1006    ///
1007    /// ## Thread safety
1008    /// It is safe to call this function from any thread.
1009    ///
1010    /// ## Availability
1011    /// This function is available since SDL_ttf 3.0.0.
1012    ///
1013    /// ## See also
1014    /// - [`TTF_SetFontHinting`]
1015    pub fn TTF_GetFontHinting(font: *const TTF_Font) -> TTF_HintingFlags;
1016}
1017
1018unsafe extern "C" {
1019    /// Enable Signed Distance Field rendering for a font.
1020    ///
1021    /// SDF is a technique that helps fonts look sharp even when scaling and
1022    /// rotating, and requires special shader support for display.
1023    ///
1024    /// This works with Blended APIs, and generates the raw signed distance values
1025    /// in the alpha channel of the resulting texture.
1026    ///
1027    /// This updates any [`TTF_Text`] objects using this font, and clears
1028    /// already-generated glyphs, if any, from the cache.
1029    ///
1030    /// ## Parameters
1031    /// - `font`: the font to set SDF support on.
1032    /// - `enabled`: true to enable SDF, false to disable.
1033    ///
1034    /// ## Return value
1035    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1036    ///   information.
1037    ///
1038    /// ## Thread safety
1039    /// This function should be called on the thread that created the
1040    ///   font.
1041    ///
1042    /// ## Availability
1043    /// This function is available since SDL_ttf 3.0.0.
1044    ///
1045    /// ## See also
1046    /// - [`TTF_GetFontSDF`]
1047    pub fn TTF_SetFontSDF(
1048        font: *mut TTF_Font,
1049        enabled: ::core::primitive::bool,
1050    ) -> ::core::primitive::bool;
1051}
1052
1053unsafe extern "C" {
1054    /// Query whether Signed Distance Field rendering is enabled for a font.
1055    ///
1056    /// ## Parameters
1057    /// - `font`: the font to query.
1058    ///
1059    /// ## Return value
1060    /// Returns true if enabled, false otherwise.
1061    ///
1062    /// ## Thread safety
1063    /// It is safe to call this function from any thread.
1064    ///
1065    /// ## Availability
1066    /// This function is available since SDL_ttf 3.0.0.
1067    ///
1068    /// ## See also
1069    /// - [`TTF_SetFontSDF`]
1070    pub fn TTF_GetFontSDF(font: *const TTF_Font) -> ::core::primitive::bool;
1071}
1072
1073unsafe extern "C" {
1074    /// Query a font's weight, in terms of the lightness/heaviness of the strokes.
1075    ///
1076    /// ## Parameters
1077    /// - `font`: the font to query.
1078    ///
1079    /// ## Return value
1080    /// Returns the font's current weight.
1081    ///
1082    /// ## Thread safety
1083    /// This function should be called on the thread that created the
1084    ///   font.
1085    ///
1086    /// ## Availability
1087    /// This function is available since SDL_ttf 3.4.0.
1088    pub fn TTF_GetFontWeight(font: *const TTF_Font) -> ::core::ffi::c_int;
1089}
1090
1091/// Thin (100) named font weight value
1092pub const TTF_FONT_WEIGHT_THIN: ::core::primitive::i32 = 100;
1093
1094/// ExtraLight (200) named font weight value
1095pub const TTF_FONT_WEIGHT_EXTRA_LIGHT: ::core::primitive::i32 = 200;
1096
1097/// Light (300) named font weight value
1098pub const TTF_FONT_WEIGHT_LIGHT: ::core::primitive::i32 = 300;
1099
1100/// Normal (400) named font weight value
1101pub const TTF_FONT_WEIGHT_NORMAL: ::core::primitive::i32 = 400;
1102
1103/// Medium (500) named font weight value
1104pub const TTF_FONT_WEIGHT_MEDIUM: ::core::primitive::i32 = 500;
1105
1106/// SemiBold (600) named font weight value
1107pub const TTF_FONT_WEIGHT_SEMI_BOLD: ::core::primitive::i32 = 600;
1108
1109/// Bold (700) named font weight value
1110pub const TTF_FONT_WEIGHT_BOLD: ::core::primitive::i32 = 700;
1111
1112/// ExtraBold (800) named font weight value
1113pub const TTF_FONT_WEIGHT_EXTRA_BOLD: ::core::primitive::i32 = 800;
1114
1115/// Black (900) named font weight value
1116pub const TTF_FONT_WEIGHT_BLACK: ::core::primitive::i32 = 900;
1117
1118/// ExtraBlack (950) named font weight value
1119pub const TTF_FONT_WEIGHT_EXTRA_BLACK: ::core::primitive::i32 = 950;
1120
1121/// The horizontal alignment used when rendering wrapped text.
1122///
1123/// ## Availability
1124/// This enum is available since SDL_ttf 3.0.0.
1125///
1126/// ## Known values (`sdl3-sys`)
1127/// | Associated constant | Global constant | Description |
1128/// | ------------------- | --------------- | ----------- |
1129/// | [`INVALID`](TTF_HorizontalAlignment::INVALID) | [`TTF_HORIZONTAL_ALIGN_INVALID`] | |
1130/// | [`LEFT`](TTF_HorizontalAlignment::LEFT) | [`TTF_HORIZONTAL_ALIGN_LEFT`] | |
1131/// | [`CENTER`](TTF_HorizontalAlignment::CENTER) | [`TTF_HORIZONTAL_ALIGN_CENTER`] | |
1132/// | [`RIGHT`](TTF_HorizontalAlignment::RIGHT) | [`TTF_HORIZONTAL_ALIGN_RIGHT`] | |
1133#[repr(transparent)]
1134#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
1135pub struct TTF_HorizontalAlignment(pub ::core::ffi::c_int);
1136
1137impl ::core::cmp::PartialEq<::core::ffi::c_int> for TTF_HorizontalAlignment {
1138    #[inline(always)]
1139    fn eq(&self, other: &::core::ffi::c_int) -> bool {
1140        &self.0 == other
1141    }
1142}
1143
1144impl ::core::cmp::PartialEq<TTF_HorizontalAlignment> for ::core::ffi::c_int {
1145    #[inline(always)]
1146    fn eq(&self, other: &TTF_HorizontalAlignment) -> bool {
1147        self == &other.0
1148    }
1149}
1150
1151impl From<TTF_HorizontalAlignment> for ::core::ffi::c_int {
1152    #[inline(always)]
1153    fn from(value: TTF_HorizontalAlignment) -> Self {
1154        value.0
1155    }
1156}
1157
1158#[cfg(feature = "debug-impls")]
1159impl ::core::fmt::Debug for TTF_HorizontalAlignment {
1160    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
1161        #[allow(unreachable_patterns)]
1162        f.write_str(match *self {
1163            Self::INVALID => "TTF_HORIZONTAL_ALIGN_INVALID",
1164            Self::LEFT => "TTF_HORIZONTAL_ALIGN_LEFT",
1165            Self::CENTER => "TTF_HORIZONTAL_ALIGN_CENTER",
1166            Self::RIGHT => "TTF_HORIZONTAL_ALIGN_RIGHT",
1167
1168            _ => return write!(f, "TTF_HorizontalAlignment({})", self.0),
1169        })
1170    }
1171}
1172
1173impl TTF_HorizontalAlignment {
1174    pub const INVALID: Self = Self((-1_i32 as ::core::ffi::c_int));
1175    pub const LEFT: Self = Self((0_i32 as ::core::ffi::c_int));
1176    pub const CENTER: Self = Self((1_i32 as ::core::ffi::c_int));
1177    pub const RIGHT: Self = Self((2_i32 as ::core::ffi::c_int));
1178}
1179
1180pub const TTF_HORIZONTAL_ALIGN_INVALID: TTF_HorizontalAlignment = TTF_HorizontalAlignment::INVALID;
1181pub const TTF_HORIZONTAL_ALIGN_LEFT: TTF_HorizontalAlignment = TTF_HorizontalAlignment::LEFT;
1182pub const TTF_HORIZONTAL_ALIGN_CENTER: TTF_HorizontalAlignment = TTF_HorizontalAlignment::CENTER;
1183pub const TTF_HORIZONTAL_ALIGN_RIGHT: TTF_HorizontalAlignment = TTF_HorizontalAlignment::RIGHT;
1184
1185#[cfg(feature = "metadata")]
1186impl sdl3_sys::metadata::GroupMetadata for TTF_HorizontalAlignment {
1187    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
1188        &crate::metadata::ttf::METADATA_TTF_HorizontalAlignment;
1189}
1190
1191unsafe extern "C" {
1192    /// Set a font's current wrap alignment option.
1193    ///
1194    /// This updates any [`TTF_Text`] objects using this font.
1195    ///
1196    /// ## Parameters
1197    /// - `font`: the font to set a new wrap alignment option on.
1198    /// - `align`: the new wrap alignment option.
1199    ///
1200    /// ## Thread safety
1201    /// This function should be called on the thread that created the
1202    ///   font.
1203    ///
1204    /// ## Availability
1205    /// This function is available since SDL_ttf 3.0.0.
1206    ///
1207    /// ## See also
1208    /// - [`TTF_GetFontWrapAlignment`]
1209    pub fn TTF_SetFontWrapAlignment(font: *mut TTF_Font, align: TTF_HorizontalAlignment);
1210}
1211
1212unsafe extern "C" {
1213    /// Query a font's current wrap alignment option.
1214    ///
1215    /// ## Parameters
1216    /// - `font`: the font to query.
1217    ///
1218    /// ## Return value
1219    /// Returns the font's current wrap alignment option.
1220    ///
1221    /// ## Thread safety
1222    /// It is safe to call this function from any thread.
1223    ///
1224    /// ## Availability
1225    /// This function is available since SDL_ttf 3.0.0.
1226    ///
1227    /// ## See also
1228    /// - [`TTF_SetFontWrapAlignment`]
1229    pub fn TTF_GetFontWrapAlignment(font: *const TTF_Font) -> TTF_HorizontalAlignment;
1230}
1231
1232unsafe extern "C" {
1233    /// Query the total height of a font.
1234    ///
1235    /// This is usually equal to point size.
1236    ///
1237    /// ## Parameters
1238    /// - `font`: the font to query.
1239    ///
1240    /// ## Return value
1241    /// Returns the font's height.
1242    ///
1243    /// ## Thread safety
1244    /// It is safe to call this function from any thread.
1245    ///
1246    /// ## Availability
1247    /// This function is available since SDL_ttf 3.0.0.
1248    pub fn TTF_GetFontHeight(font: *const TTF_Font) -> ::core::ffi::c_int;
1249}
1250
1251unsafe extern "C" {
1252    /// Query the offset from the baseline to the top of a font.
1253    ///
1254    /// This is a positive value, relative to the baseline.
1255    ///
1256    /// ## Parameters
1257    /// - `font`: the font to query.
1258    ///
1259    /// ## Return value
1260    /// Returns the font's ascent.
1261    ///
1262    /// ## Thread safety
1263    /// It is safe to call this function from any thread.
1264    ///
1265    /// ## Availability
1266    /// This function is available since SDL_ttf 3.0.0.
1267    pub fn TTF_GetFontAscent(font: *const TTF_Font) -> ::core::ffi::c_int;
1268}
1269
1270unsafe extern "C" {
1271    /// Query the offset from the baseline to the bottom of a font.
1272    ///
1273    /// This is a negative value, relative to the baseline.
1274    ///
1275    /// ## Parameters
1276    /// - `font`: the font to query.
1277    ///
1278    /// ## Return value
1279    /// Returns the font's descent.
1280    ///
1281    /// ## Thread safety
1282    /// It is safe to call this function from any thread.
1283    ///
1284    /// ## Availability
1285    /// This function is available since SDL_ttf 3.0.0.
1286    pub fn TTF_GetFontDescent(font: *const TTF_Font) -> ::core::ffi::c_int;
1287}
1288
1289unsafe extern "C" {
1290    /// Set the spacing between lines of text for a font.
1291    ///
1292    /// This updates any [`TTF_Text`] objects using this font.
1293    ///
1294    /// ## Parameters
1295    /// - `font`: the font to modify.
1296    /// - `lineskip`: the new line spacing for the font.
1297    ///
1298    /// ## Thread safety
1299    /// This function should be called on the thread that created the
1300    ///   font.
1301    ///
1302    /// ## Availability
1303    /// This function is available since SDL_ttf 3.0.0.
1304    ///
1305    /// ## See also
1306    /// - [`TTF_GetFontLineSkip`]
1307    pub fn TTF_SetFontLineSkip(font: *mut TTF_Font, lineskip: ::core::ffi::c_int);
1308}
1309
1310unsafe extern "C" {
1311    /// Query the spacing between lines of text for a font.
1312    ///
1313    /// ## Parameters
1314    /// - `font`: the font to query.
1315    ///
1316    /// ## Return value
1317    /// Returns the font's recommended spacing.
1318    ///
1319    /// ## Thread safety
1320    /// It is safe to call this function from any thread.
1321    ///
1322    /// ## Availability
1323    /// This function is available since SDL_ttf 3.0.0.
1324    ///
1325    /// ## See also
1326    /// - [`TTF_SetFontLineSkip`]
1327    pub fn TTF_GetFontLineSkip(font: *const TTF_Font) -> ::core::ffi::c_int;
1328}
1329
1330unsafe extern "C" {
1331    /// Set if kerning is enabled for a font.
1332    ///
1333    /// Newly-opened fonts default to allowing kerning. This is generally a good
1334    /// policy unless you have a strong reason to disable it, as it tends to
1335    /// produce better rendering (with kerning disabled, some fonts might render
1336    /// the word `kerning` as something that looks like `keming` for example).
1337    ///
1338    /// This updates any [`TTF_Text`] objects using this font.
1339    ///
1340    /// ## Parameters
1341    /// - `font`: the font to set kerning on.
1342    /// - `enabled`: true to enable kerning, false to disable.
1343    ///
1344    /// ## Thread safety
1345    /// This function should be called on the thread that created the
1346    ///   font.
1347    ///
1348    /// ## Availability
1349    /// This function is available since SDL_ttf 3.0.0.
1350    ///
1351    /// ## See also
1352    /// - [`TTF_GetFontKerning`]
1353    pub fn TTF_SetFontKerning(font: *mut TTF_Font, enabled: ::core::primitive::bool);
1354}
1355
1356unsafe extern "C" {
1357    /// Query whether or not kerning is enabled for a font.
1358    ///
1359    /// ## Parameters
1360    /// - `font`: the font to query.
1361    ///
1362    /// ## Return value
1363    /// Returns true if kerning is enabled, false otherwise.
1364    ///
1365    /// ## Thread safety
1366    /// It is safe to call this function from any thread.
1367    ///
1368    /// ## Availability
1369    /// This function is available since SDL_ttf 3.0.0.
1370    ///
1371    /// ## See also
1372    /// - [`TTF_SetFontKerning`]
1373    pub fn TTF_GetFontKerning(font: *const TTF_Font) -> ::core::primitive::bool;
1374}
1375
1376unsafe extern "C" {
1377    /// Query whether a font is fixed-width.
1378    ///
1379    /// A "fixed-width" font means all glyphs are the same width across; a
1380    /// lowercase 'i' will be the same size across as a capital 'W', for example.
1381    /// This is common for terminals and text editors, and other apps that treat
1382    /// text as a grid. Most other things (WYSIWYG word processors, web pages, etc)
1383    /// are more likely to not be fixed-width in most cases.
1384    ///
1385    /// ## Parameters
1386    /// - `font`: the font to query.
1387    ///
1388    /// ## Return value
1389    /// Returns true if the font is fixed-width, false otherwise.
1390    ///
1391    /// ## Thread safety
1392    /// It is safe to call this function from any thread.
1393    ///
1394    /// ## Availability
1395    /// This function is available since SDL_ttf 3.0.0.
1396    pub fn TTF_FontIsFixedWidth(font: *const TTF_Font) -> ::core::primitive::bool;
1397}
1398
1399unsafe extern "C" {
1400    /// Query whether a font is scalable or not.
1401    ///
1402    /// Scalability lets us distinguish between outline and bitmap fonts.
1403    ///
1404    /// ## Parameters
1405    /// - `font`: the font to query.
1406    ///
1407    /// ## Return value
1408    /// Returns true if the font is scalable, false otherwise.
1409    ///
1410    /// ## Thread safety
1411    /// It is safe to call this function from any thread.
1412    ///
1413    /// ## Availability
1414    /// This function is available since SDL_ttf 3.0.0.
1415    ///
1416    /// ## See also
1417    /// - [`TTF_SetFontSDF`]
1418    pub fn TTF_FontIsScalable(font: *const TTF_Font) -> ::core::primitive::bool;
1419}
1420
1421unsafe extern "C" {
1422    /// Query a font's family name.
1423    ///
1424    /// This string is dictated by the contents of the font file.
1425    ///
1426    /// Note that the returned string is to internal storage, and should not be
1427    /// modified or free'd by the caller. The string becomes invalid, with the rest
1428    /// of the font, when `font` is handed to [`TTF_CloseFont()`].
1429    ///
1430    /// ## Parameters
1431    /// - `font`: the font to query.
1432    ///
1433    /// ## Return value
1434    /// Returns the font's family name.
1435    ///
1436    /// ## Thread safety
1437    /// It is safe to call this function from any thread.
1438    ///
1439    /// ## Availability
1440    /// This function is available since SDL_ttf 3.0.0.
1441    pub fn TTF_GetFontFamilyName(font: *const TTF_Font) -> *const ::core::ffi::c_char;
1442}
1443
1444unsafe extern "C" {
1445    /// Query a font's style name.
1446    ///
1447    /// This string is dictated by the contents of the font file.
1448    ///
1449    /// Note that the returned string is to internal storage, and should not be
1450    /// modified or free'd by the caller. The string becomes invalid, with the rest
1451    /// of the font, when `font` is handed to [`TTF_CloseFont()`].
1452    ///
1453    /// ## Parameters
1454    /// - `font`: the font to query.
1455    ///
1456    /// ## Return value
1457    /// Returns the font's style name.
1458    ///
1459    /// ## Thread safety
1460    /// It is safe to call this function from any thread.
1461    ///
1462    /// ## Availability
1463    /// This function is available since SDL_ttf 3.0.0.
1464    pub fn TTF_GetFontStyleName(font: *const TTF_Font) -> *const ::core::ffi::c_char;
1465}
1466
1467/// Direction flags
1468///
1469/// The values here are chosen to match
1470/// [hb_direction_t](https://harfbuzz.github.io/harfbuzz-hb-common.html#hb-direction-t)
1471/// .
1472///
1473/// ## Availability
1474/// This enum is available since SDL_ttf 3.0.0.
1475///
1476/// ## See also
1477/// - [`TTF_SetFontDirection`]
1478///
1479/// ## Known values (`sdl3-sys`)
1480/// | Associated constant | Global constant | Description |
1481/// | ------------------- | --------------- | ----------- |
1482/// | [`INVALID`](TTF_Direction::INVALID) | [`TTF_DIRECTION_INVALID`] | |
1483/// | [`LTR`](TTF_Direction::LTR) | [`TTF_DIRECTION_LTR`] | Left to Right |
1484/// | [`RTL`](TTF_Direction::RTL) | [`TTF_DIRECTION_RTL`] | Right to Left |
1485/// | [`TTB`](TTF_Direction::TTB) | [`TTF_DIRECTION_TTB`] | Top to Bottom |
1486/// | [`BTT`](TTF_Direction::BTT) | [`TTF_DIRECTION_BTT`] | Bottom to Top |
1487#[repr(transparent)]
1488#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
1489pub struct TTF_Direction(pub ::core::primitive::u32);
1490
1491impl ::core::cmp::PartialEq<::core::primitive::u32> for TTF_Direction {
1492    #[inline(always)]
1493    fn eq(&self, other: &::core::primitive::u32) -> bool {
1494        &self.0 == other
1495    }
1496}
1497
1498impl ::core::cmp::PartialEq<TTF_Direction> for ::core::primitive::u32 {
1499    #[inline(always)]
1500    fn eq(&self, other: &TTF_Direction) -> bool {
1501        self == &other.0
1502    }
1503}
1504
1505impl From<TTF_Direction> for ::core::primitive::u32 {
1506    #[inline(always)]
1507    fn from(value: TTF_Direction) -> Self {
1508        value.0
1509    }
1510}
1511
1512#[cfg(feature = "debug-impls")]
1513impl ::core::fmt::Debug for TTF_Direction {
1514    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
1515        #[allow(unreachable_patterns)]
1516        f.write_str(match *self {
1517            Self::INVALID => "TTF_DIRECTION_INVALID",
1518            Self::LTR => "TTF_DIRECTION_LTR",
1519            Self::RTL => "TTF_DIRECTION_RTL",
1520            Self::TTB => "TTF_DIRECTION_TTB",
1521            Self::BTT => "TTF_DIRECTION_BTT",
1522
1523            _ => return write!(f, "TTF_Direction({})", self.0),
1524        })
1525    }
1526}
1527
1528impl TTF_Direction {
1529    pub const INVALID: Self = Self((0 as ::core::primitive::u32));
1530    /// Left to Right
1531    pub const LTR: Self = Self((4 as ::core::primitive::u32));
1532    /// Right to Left
1533    pub const RTL: Self = Self((5 as ::core::primitive::u32));
1534    /// Top to Bottom
1535    pub const TTB: Self = Self((6 as ::core::primitive::u32));
1536    /// Bottom to Top
1537    pub const BTT: Self = Self((7 as ::core::primitive::u32));
1538}
1539
1540pub const TTF_DIRECTION_INVALID: TTF_Direction = TTF_Direction::INVALID;
1541/// Left to Right
1542pub const TTF_DIRECTION_LTR: TTF_Direction = TTF_Direction::LTR;
1543/// Right to Left
1544pub const TTF_DIRECTION_RTL: TTF_Direction = TTF_Direction::RTL;
1545/// Top to Bottom
1546pub const TTF_DIRECTION_TTB: TTF_Direction = TTF_Direction::TTB;
1547/// Bottom to Top
1548pub const TTF_DIRECTION_BTT: TTF_Direction = TTF_Direction::BTT;
1549
1550#[cfg(feature = "metadata")]
1551impl sdl3_sys::metadata::GroupMetadata for TTF_Direction {
1552    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
1553        &crate::metadata::ttf::METADATA_TTF_Direction;
1554}
1555
1556unsafe extern "C" {
1557    /// Set the direction to be used for text shaping by a font.
1558    ///
1559    /// This function only supports left-to-right text shaping if SDL_ttf was not
1560    /// built with HarfBuzz support.
1561    ///
1562    /// This updates any [`TTF_Text`] objects using this font.
1563    ///
1564    /// ## Parameters
1565    /// - `font`: the font to modify.
1566    /// - `direction`: the new direction for text to flow.
1567    ///
1568    /// ## Return value
1569    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1570    ///   information.
1571    ///
1572    /// ## Thread safety
1573    /// This function should be called on the thread that created the
1574    ///   font.
1575    ///
1576    /// ## Availability
1577    /// This function is available since SDL_ttf 3.0.0.
1578    pub fn TTF_SetFontDirection(
1579        font: *mut TTF_Font,
1580        direction: TTF_Direction,
1581    ) -> ::core::primitive::bool;
1582}
1583
1584unsafe extern "C" {
1585    /// Get the direction to be used for text shaping by a font.
1586    ///
1587    /// This defaults to [`TTF_DIRECTION_INVALID`] if it hasn't been set.
1588    ///
1589    /// ## Parameters
1590    /// - `font`: the font to query.
1591    ///
1592    /// ## Return value
1593    /// Returns the direction to be used for text shaping.
1594    ///
1595    /// ## Thread safety
1596    /// This function should be called on the thread that created the
1597    ///   font.
1598    ///
1599    /// ## Availability
1600    /// This function is available since SDL_ttf 3.0.0.
1601    pub fn TTF_GetFontDirection(font: *mut TTF_Font) -> TTF_Direction;
1602}
1603
1604unsafe extern "C" {
1605    /// Convert from a 4 character string to a 32-bit tag.
1606    ///
1607    /// ## Parameters
1608    /// - `string`: the 4 character string to convert.
1609    ///
1610    /// ## Return value
1611    /// Returns the 32-bit representation of the string.
1612    ///
1613    /// ## Thread safety
1614    /// It is safe to call this function from any thread.
1615    ///
1616    /// ## Availability
1617    /// This function is available since SDL_ttf 3.0.0.
1618    ///
1619    /// ## See also
1620    /// - [`TTF_TagToString`]
1621    pub fn TTF_StringToTag(string: *const ::core::ffi::c_char) -> Uint32;
1622}
1623
1624unsafe extern "C" {
1625    /// Convert from a 32-bit tag to a 4 character string.
1626    ///
1627    /// ## Parameters
1628    /// - `tag`: the 32-bit tag to convert.
1629    /// - `string`: a pointer filled in with the 4 character representation of
1630    ///   the tag.
1631    /// - `size`: the size of the buffer pointed at by string, should be at least
1632    ///   4.
1633    ///
1634    /// ## Thread safety
1635    /// It is safe to call this function from any thread.
1636    ///
1637    /// ## Availability
1638    /// This function is available since SDL_ttf 3.0.0.
1639    ///
1640    /// ## See also
1641    /// - [`TTF_TagToString`]
1642    pub fn TTF_TagToString(
1643        tag: Uint32,
1644        string: *mut ::core::ffi::c_char,
1645        size: ::core::primitive::usize,
1646    );
1647}
1648
1649unsafe extern "C" {
1650    /// Set the script to be used for text shaping by a font.
1651    ///
1652    /// This returns false if SDL_ttf isn't built with HarfBuzz support.
1653    ///
1654    /// This updates any [`TTF_Text`] objects using this font.
1655    ///
1656    /// ## Parameters
1657    /// - `font`: the font to modify.
1658    /// - `script`: an
1659    ///   [ISO 15924 code](https://unicode.org/iso15924/iso15924-codes.html)
1660    ///   .
1661    ///
1662    /// ## Return value
1663    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1664    ///   information.
1665    ///
1666    /// ## Thread safety
1667    /// This function should be called on the thread that created the
1668    ///   font.
1669    ///
1670    /// ## Availability
1671    /// This function is available since SDL_ttf 3.0.0.
1672    ///
1673    /// ## See also
1674    /// - [`TTF_StringToTag`]
1675    pub fn TTF_SetFontScript(font: *mut TTF_Font, script: Uint32) -> ::core::primitive::bool;
1676}
1677
1678unsafe extern "C" {
1679    /// Get the script used for text shaping a font.
1680    ///
1681    /// ## Parameters
1682    /// - `font`: the font to query.
1683    ///
1684    /// ## Return value
1685    /// Returns an
1686    ///   [ISO 15924 code](https://unicode.org/iso15924/iso15924-codes.html)
1687    ///   or 0 if a script hasn't been set.
1688    ///
1689    /// ## Thread safety
1690    /// This function should be called on the thread that created the
1691    ///   font.
1692    ///
1693    /// ## Availability
1694    /// This function is available since SDL_ttf 3.0.0.
1695    ///
1696    /// ## See also
1697    /// - [`TTF_TagToString`]
1698    pub fn TTF_GetFontScript(font: *mut TTF_Font) -> Uint32;
1699}
1700
1701unsafe extern "C" {
1702    /// Get the script used by a 32-bit codepoint.
1703    ///
1704    /// ## Parameters
1705    /// - `ch`: the character code to check.
1706    ///
1707    /// ## Return value
1708    /// Returns an
1709    ///   [ISO 15924 code](https://unicode.org/iso15924/iso15924-codes.html)
1710    ///   on success, or 0 on failure; call [`SDL_GetError()`] for more
1711    ///   information.
1712    ///
1713    /// ## Thread safety
1714    /// This function is thread-safe.
1715    ///
1716    /// ## Availability
1717    /// This function is available since SDL_ttf 3.0.0.
1718    ///
1719    /// ## See also
1720    /// - [`TTF_TagToString`]
1721    pub fn TTF_GetGlyphScript(ch: Uint32) -> Uint32;
1722}
1723
1724unsafe extern "C" {
1725    /// Set language to be used for text shaping by a font.
1726    ///
1727    /// If SDL_ttf was not built with HarfBuzz support, this function returns
1728    /// false.
1729    ///
1730    /// This updates any [`TTF_Text`] objects using this font.
1731    ///
1732    /// ## Parameters
1733    /// - `font`: the font to specify a language for.
1734    /// - `language_bcp47`: a null-terminated string containing the desired
1735    ///   language's BCP47 code. Or null to reset the value.
1736    ///
1737    /// ## Return value
1738    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1739    ///   information.
1740    ///
1741    /// ## Thread safety
1742    /// This function should be called on the thread that created the
1743    ///   font.
1744    ///
1745    /// ## Availability
1746    /// This function is available since SDL_ttf 3.0.0.
1747    pub fn TTF_SetFontLanguage(
1748        font: *mut TTF_Font,
1749        language_bcp47: *const ::core::ffi::c_char,
1750    ) -> ::core::primitive::bool;
1751}
1752
1753unsafe extern "C" {
1754    /// Check whether a glyph is provided by the font for a UNICODE codepoint.
1755    ///
1756    /// ## Parameters
1757    /// - `font`: the font to query.
1758    /// - `ch`: the codepoint to check.
1759    ///
1760    /// ## Return value
1761    /// Returns true if font provides a glyph for this character, false if not.
1762    ///
1763    /// ## Thread safety
1764    /// This function should be called on the thread that created the
1765    ///   font.
1766    ///
1767    /// ## Availability
1768    /// This function is available since SDL_ttf 3.0.0.
1769    pub fn TTF_FontHasGlyph(font: *mut TTF_Font, ch: Uint32) -> ::core::primitive::bool;
1770}
1771
1772/// The type of data in a glyph image
1773///
1774/// ## Availability
1775/// This enum is available since SDL_ttf 3.0.0.
1776///
1777/// ## Known values (`sdl3-sys`)
1778/// | Associated constant | Global constant | Description |
1779/// | ------------------- | --------------- | ----------- |
1780/// | [`INVALID`](TTF_ImageType::INVALID) | [`TTF_IMAGE_INVALID`] | |
1781/// | [`ALPHA`](TTF_ImageType::ALPHA) | [`TTF_IMAGE_ALPHA`] | The color channels are white |
1782/// | [`COLOR`](TTF_ImageType::COLOR) | [`TTF_IMAGE_COLOR`] | The color channels have image data |
1783/// | [`SDF`](TTF_ImageType::SDF) | [`TTF_IMAGE_SDF`] | The alpha channel has signed distance field information |
1784#[repr(transparent)]
1785#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
1786pub struct TTF_ImageType(pub ::core::ffi::c_int);
1787
1788impl ::core::cmp::PartialEq<::core::ffi::c_int> for TTF_ImageType {
1789    #[inline(always)]
1790    fn eq(&self, other: &::core::ffi::c_int) -> bool {
1791        &self.0 == other
1792    }
1793}
1794
1795impl ::core::cmp::PartialEq<TTF_ImageType> for ::core::ffi::c_int {
1796    #[inline(always)]
1797    fn eq(&self, other: &TTF_ImageType) -> bool {
1798        self == &other.0
1799    }
1800}
1801
1802impl From<TTF_ImageType> for ::core::ffi::c_int {
1803    #[inline(always)]
1804    fn from(value: TTF_ImageType) -> Self {
1805        value.0
1806    }
1807}
1808
1809#[cfg(feature = "debug-impls")]
1810impl ::core::fmt::Debug for TTF_ImageType {
1811    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
1812        #[allow(unreachable_patterns)]
1813        f.write_str(match *self {
1814            Self::INVALID => "TTF_IMAGE_INVALID",
1815            Self::ALPHA => "TTF_IMAGE_ALPHA",
1816            Self::COLOR => "TTF_IMAGE_COLOR",
1817            Self::SDF => "TTF_IMAGE_SDF",
1818
1819            _ => return write!(f, "TTF_ImageType({})", self.0),
1820        })
1821    }
1822}
1823
1824impl TTF_ImageType {
1825    pub const INVALID: Self = Self((0 as ::core::ffi::c_int));
1826    /// The color channels are white
1827    pub const ALPHA: Self = Self((1 as ::core::ffi::c_int));
1828    /// The color channels have image data
1829    pub const COLOR: Self = Self((2 as ::core::ffi::c_int));
1830    /// The alpha channel has signed distance field information
1831    pub const SDF: Self = Self((3 as ::core::ffi::c_int));
1832}
1833
1834pub const TTF_IMAGE_INVALID: TTF_ImageType = TTF_ImageType::INVALID;
1835/// The color channels are white
1836pub const TTF_IMAGE_ALPHA: TTF_ImageType = TTF_ImageType::ALPHA;
1837/// The color channels have image data
1838pub const TTF_IMAGE_COLOR: TTF_ImageType = TTF_ImageType::COLOR;
1839/// The alpha channel has signed distance field information
1840pub const TTF_IMAGE_SDF: TTF_ImageType = TTF_ImageType::SDF;
1841
1842#[cfg(feature = "metadata")]
1843impl sdl3_sys::metadata::GroupMetadata for TTF_ImageType {
1844    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
1845        &crate::metadata::ttf::METADATA_TTF_ImageType;
1846}
1847
1848unsafe extern "C" {
1849    /// Get the pixel image for a UNICODE codepoint.
1850    ///
1851    /// ## Parameters
1852    /// - `font`: the font to query.
1853    /// - `ch`: the codepoint to check.
1854    /// - `image_type`: a pointer filled in with the glyph image type, may be
1855    ///   NULL.
1856    ///
1857    /// ## Return value
1858    /// Returns an [`SDL_Surface`] containing the glyph, or NULL on failure; call
1859    ///   [`SDL_GetError()`] for more information.
1860    ///
1861    /// ## Thread safety
1862    /// This function should be called on the thread that created the
1863    ///   font.
1864    ///
1865    /// ## Availability
1866    /// This function is available since SDL_ttf 3.0.0.
1867    pub fn TTF_GetGlyphImage(
1868        font: *mut TTF_Font,
1869        ch: Uint32,
1870        image_type: *mut TTF_ImageType,
1871    ) -> *mut SDL_Surface;
1872}
1873
1874unsafe extern "C" {
1875    /// Get the pixel image for a character index.
1876    ///
1877    /// This is useful for text engine implementations, which can call this with
1878    /// the `glyph_index` in a [`TTF_CopyOperation`]
1879    ///
1880    /// ## Parameters
1881    /// - `font`: the font to query.
1882    /// - `glyph_index`: the index of the glyph to return.
1883    /// - `image_type`: a pointer filled in with the glyph image type, may be
1884    ///   NULL.
1885    ///
1886    /// ## Return value
1887    /// Returns an [`SDL_Surface`] containing the glyph, or NULL on failure; call
1888    ///   [`SDL_GetError()`] for more information.
1889    ///
1890    /// ## Thread safety
1891    /// This function should be called on the thread that created the
1892    ///   font.
1893    ///
1894    /// ## Availability
1895    /// This function is available since SDL_ttf 3.0.0.
1896    pub fn TTF_GetGlyphImageForIndex(
1897        font: *mut TTF_Font,
1898        glyph_index: Uint32,
1899        image_type: *mut TTF_ImageType,
1900    ) -> *mut SDL_Surface;
1901}
1902
1903unsafe extern "C" {
1904    /// Query the metrics (dimensions) of a font's glyph for a UNICODE codepoint.
1905    ///
1906    /// To understand what these metrics mean, here is a useful link:
1907    ///
1908    /// <https://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html>
1909    ///
1910    /// ## Parameters
1911    /// - `font`: the font to query.
1912    /// - `ch`: the codepoint to check.
1913    /// - `minx`: a pointer filled in with the minimum x coordinate of the glyph
1914    ///   from the left edge of its bounding box. This value may be
1915    ///   negative.
1916    /// - `maxx`: a pointer filled in with the maximum x coordinate of the glyph
1917    ///   from the left edge of its bounding box.
1918    /// - `miny`: a pointer filled in with the minimum y coordinate of the glyph
1919    ///   from the bottom edge of its bounding box. This value may be
1920    ///   negative.
1921    /// - `maxy`: a pointer filled in with the maximum y coordinate of the glyph
1922    ///   from the bottom edge of its bounding box.
1923    /// - `advance`: a pointer filled in with the distance to the next glyph from
1924    ///   the left edge of this glyph's bounding box.
1925    ///
1926    /// ## Return value
1927    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1928    ///   information.
1929    ///
1930    /// ## Thread safety
1931    /// This function should be called on the thread that created the
1932    ///   font.
1933    ///
1934    /// ## Availability
1935    /// This function is available since SDL_ttf 3.0.0.
1936    pub fn TTF_GetGlyphMetrics(
1937        font: *mut TTF_Font,
1938        ch: Uint32,
1939        minx: *mut ::core::ffi::c_int,
1940        maxx: *mut ::core::ffi::c_int,
1941        miny: *mut ::core::ffi::c_int,
1942        maxy: *mut ::core::ffi::c_int,
1943        advance: *mut ::core::ffi::c_int,
1944    ) -> ::core::primitive::bool;
1945}
1946
1947unsafe extern "C" {
1948    /// Query the kerning size between the glyphs of two UNICODE codepoints.
1949    ///
1950    /// ## Parameters
1951    /// - `font`: the font to query.
1952    /// - `previous_ch`: the previous codepoint.
1953    /// - `ch`: the current codepoint.
1954    /// - `kerning`: a pointer filled in with the kerning size between the two
1955    ///   glyphs, in pixels, may be NULL.
1956    ///
1957    /// ## Return value
1958    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1959    ///   information.
1960    ///
1961    /// ## Thread safety
1962    /// This function should be called on the thread that created the
1963    ///   font.
1964    ///
1965    /// ## Availability
1966    /// This function is available since SDL_ttf 3.0.0.
1967    pub fn TTF_GetGlyphKerning(
1968        font: *mut TTF_Font,
1969        previous_ch: Uint32,
1970        ch: Uint32,
1971        kerning: *mut ::core::ffi::c_int,
1972    ) -> ::core::primitive::bool;
1973}
1974
1975unsafe extern "C" {
1976    /// Calculate the dimensions of a rendered string of UTF-8 text.
1977    ///
1978    /// This will report the width and height, in pixels, of the space that the
1979    /// specified string will take to fully render.
1980    ///
1981    /// ## Parameters
1982    /// - `font`: the font to query.
1983    /// - `text`: text to calculate, in UTF-8 encoding.
1984    /// - `length`: the length of the text, in bytes, or 0 for null terminated
1985    ///   text.
1986    /// - `w`: will be filled with width, in pixels, on return.
1987    /// - `h`: will be filled with height, in pixels, on return.
1988    ///
1989    /// ## Return value
1990    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1991    ///   information.
1992    ///
1993    /// ## Thread safety
1994    /// This function should be called on the thread that created the
1995    ///   font.
1996    ///
1997    /// ## Availability
1998    /// This function is available since SDL_ttf 3.0.0.
1999    pub fn TTF_GetStringSize(
2000        font: *mut TTF_Font,
2001        text: *const ::core::ffi::c_char,
2002        length: ::core::primitive::usize,
2003        w: *mut ::core::ffi::c_int,
2004        h: *mut ::core::ffi::c_int,
2005    ) -> ::core::primitive::bool;
2006}
2007
2008unsafe extern "C" {
2009    /// Calculate the dimensions of a rendered string of UTF-8 text.
2010    ///
2011    /// This will report the width and height, in pixels, of the space that the
2012    /// specified string will take to fully render.
2013    ///
2014    /// Text is wrapped to multiple lines on line endings and on word boundaries if
2015    /// it extends beyond `wrap_width` in pixels.
2016    ///
2017    /// If wrap_width is 0, this function will only wrap on newline characters.
2018    ///
2019    /// ## Parameters
2020    /// - `font`: the font to query.
2021    /// - `text`: text to calculate, in UTF-8 encoding.
2022    /// - `length`: the length of the text, in bytes, or 0 for null terminated
2023    ///   text.
2024    /// - `wrap_width`: the maximum width or 0 to wrap on newline characters.
2025    /// - `w`: will be filled with width, in pixels, on return.
2026    /// - `h`: will be filled with height, in pixels, on return.
2027    ///
2028    /// ## Return value
2029    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2030    ///   information.
2031    ///
2032    /// ## Thread safety
2033    /// This function should be called on the thread that created the
2034    ///   font.
2035    ///
2036    /// ## Availability
2037    /// This function is available since SDL_ttf 3.0.0.
2038    pub fn TTF_GetStringSizeWrapped(
2039        font: *mut TTF_Font,
2040        text: *const ::core::ffi::c_char,
2041        length: ::core::primitive::usize,
2042        wrap_width: ::core::ffi::c_int,
2043        w: *mut ::core::ffi::c_int,
2044        h: *mut ::core::ffi::c_int,
2045    ) -> ::core::primitive::bool;
2046}
2047
2048unsafe extern "C" {
2049    /// Calculate how much of a UTF-8 string will fit in a given width.
2050    ///
2051    /// This reports the number of characters that can be rendered before reaching
2052    /// `max_width`.
2053    ///
2054    /// This does not need to render the string to do this calculation.
2055    ///
2056    /// ## Parameters
2057    /// - `font`: the font to query.
2058    /// - `text`: text to calculate, in UTF-8 encoding.
2059    /// - `length`: the length of the text, in bytes, or 0 for null terminated
2060    ///   text.
2061    /// - `max_width`: maximum width, in pixels, available for the string, or 0
2062    ///   for unbounded width.
2063    /// - `measured_width`: a pointer filled in with the width, in pixels, of the
2064    ///   string that will fit, may be NULL.
2065    /// - `measured_length`: a pointer filled in with the length, in bytes, of
2066    ///   the string that will fit, may be NULL.
2067    ///
2068    /// ## Return value
2069    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2070    ///   information.
2071    ///
2072    /// ## Thread safety
2073    /// This function should be called on the thread that created the
2074    ///   font.
2075    ///
2076    /// ## Availability
2077    /// This function is available since SDL_ttf 3.0.0.
2078    pub fn TTF_MeasureString(
2079        font: *mut TTF_Font,
2080        text: *const ::core::ffi::c_char,
2081        length: ::core::primitive::usize,
2082        max_width: ::core::ffi::c_int,
2083        measured_width: *mut ::core::ffi::c_int,
2084        measured_length: *mut ::core::primitive::usize,
2085    ) -> ::core::primitive::bool;
2086}
2087
2088unsafe extern "C" {
2089    /// Render UTF-8 text at fast quality to a new 8-bit surface.
2090    ///
2091    /// This function will allocate a new 8-bit, palettized surface. The surface's
2092    /// 0 pixel will be the colorkey, giving a transparent background. The 1 pixel
2093    /// will be set to the text color.
2094    ///
2095    /// This will not word-wrap the string; you'll get a surface with a single line
2096    /// of text, as long as the string requires. You can use
2097    /// [`TTF_RenderText_Solid_Wrapped()`] instead if you need to wrap the output to
2098    /// multiple lines.
2099    ///
2100    /// This will not wrap on newline characters.
2101    ///
2102    /// You can render at other quality levels with [`TTF_RenderText_Shaded`],
2103    /// [`TTF_RenderText_Blended`], and [`TTF_RenderText_LCD`].
2104    ///
2105    /// ## Parameters
2106    /// - `font`: the font to render with.
2107    /// - `text`: text to render, in UTF-8 encoding.
2108    /// - `length`: the length of the text, in bytes, or 0 for null terminated
2109    ///   text.
2110    /// - `fg`: the foreground color for the text.
2111    ///
2112    /// ## Return value
2113    /// Returns a new 8-bit, palettized surface, or NULL if there was an error.
2114    ///
2115    /// ## Thread safety
2116    /// This function should be called on the thread that created the
2117    ///   font.
2118    ///
2119    /// ## Availability
2120    /// This function is available since SDL_ttf 3.0.0.
2121    ///
2122    /// ## See also
2123    /// - [`TTF_RenderText_Blended`]
2124    /// - [`TTF_RenderText_LCD`]
2125    /// - [`TTF_RenderText_Shaded`]
2126    /// - [`TTF_RenderText_Solid`]
2127    /// - [`TTF_RenderText_Solid_Wrapped`]
2128    pub fn TTF_RenderText_Solid(
2129        font: *mut TTF_Font,
2130        text: *const ::core::ffi::c_char,
2131        length: ::core::primitive::usize,
2132        fg: SDL_Color,
2133    ) -> *mut SDL_Surface;
2134}
2135
2136unsafe extern "C" {
2137    /// Render word-wrapped UTF-8 text at fast quality to a new 8-bit surface.
2138    ///
2139    /// This function will allocate a new 8-bit, palettized surface. The surface's
2140    /// 0 pixel will be the colorkey, giving a transparent background. The 1 pixel
2141    /// will be set to the text color.
2142    ///
2143    /// Text is wrapped to multiple lines on line endings and on word boundaries if
2144    /// it extends beyond `wrapLength` in pixels.
2145    ///
2146    /// If wrapLength is 0, this function will only wrap on newline characters.
2147    ///
2148    /// You can render at other quality levels with [`TTF_RenderText_Shaded_Wrapped`],
2149    /// [`TTF_RenderText_Blended_Wrapped`], and [`TTF_RenderText_LCD_Wrapped`].
2150    ///
2151    /// ## Parameters
2152    /// - `font`: the font to render with.
2153    /// - `text`: text to render, in UTF-8 encoding.
2154    /// - `length`: the length of the text, in bytes, or 0 for null terminated
2155    ///   text.
2156    /// - `fg`: the foreground color for the text.
2157    /// - `wrapLength`: the maximum width of the text surface or 0 to wrap on
2158    ///   newline characters.
2159    ///
2160    /// ## Return value
2161    /// Returns a new 8-bit, palettized surface, or NULL if there was an error.
2162    ///
2163    /// ## Thread safety
2164    /// This function should be called on the thread that created the
2165    ///   font.
2166    ///
2167    /// ## Availability
2168    /// This function is available since SDL_ttf 3.0.0.
2169    ///
2170    /// ## See also
2171    /// - [`TTF_RenderText_Blended_Wrapped`]
2172    /// - [`TTF_RenderText_LCD_Wrapped`]
2173    /// - [`TTF_RenderText_Shaded_Wrapped`]
2174    /// - [`TTF_RenderText_Solid`]
2175    pub fn TTF_RenderText_Solid_Wrapped(
2176        font: *mut TTF_Font,
2177        text: *const ::core::ffi::c_char,
2178        length: ::core::primitive::usize,
2179        fg: SDL_Color,
2180        wrapLength: ::core::ffi::c_int,
2181    ) -> *mut SDL_Surface;
2182}
2183
2184unsafe extern "C" {
2185    /// Render a single 32-bit glyph at fast quality to a new 8-bit surface.
2186    ///
2187    /// This function will allocate a new 8-bit, palettized surface. The surface's
2188    /// 0 pixel will be the colorkey, giving a transparent background. The 1 pixel
2189    /// will be set to the text color.
2190    ///
2191    /// The glyph is rendered without any padding or centering in the X direction,
2192    /// and aligned normally in the Y direction.
2193    ///
2194    /// You can render at other quality levels with [`TTF_RenderGlyph_Shaded`],
2195    /// [`TTF_RenderGlyph_Blended`], and [`TTF_RenderGlyph_LCD`].
2196    ///
2197    /// ## Parameters
2198    /// - `font`: the font to render with.
2199    /// - `ch`: the character to render.
2200    /// - `fg`: the foreground color for the text.
2201    ///
2202    /// ## Return value
2203    /// Returns a new 8-bit, palettized surface, or NULL if there was an error.
2204    ///
2205    /// ## Thread safety
2206    /// This function should be called on the thread that created the
2207    ///   font.
2208    ///
2209    /// ## Availability
2210    /// This function is available since SDL_ttf 3.0.0.
2211    ///
2212    /// ## See also
2213    /// - [`TTF_RenderGlyph_Blended`]
2214    /// - [`TTF_RenderGlyph_LCD`]
2215    /// - [`TTF_RenderGlyph_Shaded`]
2216    pub fn TTF_RenderGlyph_Solid(
2217        font: *mut TTF_Font,
2218        ch: Uint32,
2219        fg: SDL_Color,
2220    ) -> *mut SDL_Surface;
2221}
2222
2223unsafe extern "C" {
2224    /// Render UTF-8 text at high quality to a new 8-bit surface.
2225    ///
2226    /// This function will allocate a new 8-bit, palettized surface. The surface's
2227    /// 0 pixel will be the specified background color, while other pixels have
2228    /// varying degrees of the foreground color. This function returns the new
2229    /// surface, or NULL if there was an error.
2230    ///
2231    /// This will not word-wrap the string; you'll get a surface with a single line
2232    /// of text, as long as the string requires. You can use
2233    /// [`TTF_RenderText_Shaded_Wrapped()`] instead if you need to wrap the output to
2234    /// multiple lines.
2235    ///
2236    /// This will not wrap on newline characters.
2237    ///
2238    /// You can render at other quality levels with [`TTF_RenderText_Solid`],
2239    /// [`TTF_RenderText_Blended`], and [`TTF_RenderText_LCD`].
2240    ///
2241    /// ## Parameters
2242    /// - `font`: the font to render with.
2243    /// - `text`: text to render, in UTF-8 encoding.
2244    /// - `length`: the length of the text, in bytes, or 0 for null terminated
2245    ///   text.
2246    /// - `fg`: the foreground color for the text.
2247    /// - `bg`: the background color for the text.
2248    ///
2249    /// ## Return value
2250    /// Returns a new 8-bit, palettized surface, or NULL if there was an error.
2251    ///
2252    /// ## Thread safety
2253    /// This function should be called on the thread that created the
2254    ///   font.
2255    ///
2256    /// ## Availability
2257    /// This function is available since SDL_ttf 3.0.0.
2258    ///
2259    /// ## See also
2260    /// - [`TTF_RenderText_Blended`]
2261    /// - [`TTF_RenderText_LCD`]
2262    /// - [`TTF_RenderText_Shaded_Wrapped`]
2263    /// - [`TTF_RenderText_Solid`]
2264    pub fn TTF_RenderText_Shaded(
2265        font: *mut TTF_Font,
2266        text: *const ::core::ffi::c_char,
2267        length: ::core::primitive::usize,
2268        fg: SDL_Color,
2269        bg: SDL_Color,
2270    ) -> *mut SDL_Surface;
2271}
2272
2273unsafe extern "C" {
2274    /// Render word-wrapped UTF-8 text at high quality to a new 8-bit surface.
2275    ///
2276    /// This function will allocate a new 8-bit, palettized surface. The surface's
2277    /// 0 pixel will be the specified background color, while other pixels have
2278    /// varying degrees of the foreground color. This function returns the new
2279    /// surface, or NULL if there was an error.
2280    ///
2281    /// Text is wrapped to multiple lines on line endings and on word boundaries if
2282    /// it extends beyond `wrap_width` in pixels.
2283    ///
2284    /// If wrap_width is 0, this function will only wrap on newline characters.
2285    ///
2286    /// You can render at other quality levels with [`TTF_RenderText_Solid_Wrapped`],
2287    /// [`TTF_RenderText_Blended_Wrapped`], and [`TTF_RenderText_LCD_Wrapped`].
2288    ///
2289    /// ## Parameters
2290    /// - `font`: the font to render with.
2291    /// - `text`: text to render, in UTF-8 encoding.
2292    /// - `length`: the length of the text, in bytes, or 0 for null terminated
2293    ///   text.
2294    /// - `fg`: the foreground color for the text.
2295    /// - `bg`: the background color for the text.
2296    /// - `wrap_width`: the maximum width of the text surface or 0 to wrap on
2297    ///   newline characters.
2298    ///
2299    /// ## Return value
2300    /// Returns a new 8-bit, palettized surface, or NULL if there was an error.
2301    ///
2302    /// ## Thread safety
2303    /// This function should be called on the thread that created the
2304    ///   font.
2305    ///
2306    /// ## Availability
2307    /// This function is available since SDL_ttf 3.0.0.
2308    ///
2309    /// ## See also
2310    /// - [`TTF_RenderText_Blended_Wrapped`]
2311    /// - [`TTF_RenderText_LCD_Wrapped`]
2312    /// - [`TTF_RenderText_Shaded`]
2313    /// - [`TTF_RenderText_Solid_Wrapped`]
2314    pub fn TTF_RenderText_Shaded_Wrapped(
2315        font: *mut TTF_Font,
2316        text: *const ::core::ffi::c_char,
2317        length: ::core::primitive::usize,
2318        fg: SDL_Color,
2319        bg: SDL_Color,
2320        wrap_width: ::core::ffi::c_int,
2321    ) -> *mut SDL_Surface;
2322}
2323
2324unsafe extern "C" {
2325    /// Render a single UNICODE codepoint at high quality to a new 8-bit surface.
2326    ///
2327    /// This function will allocate a new 8-bit, palettized surface. The surface's
2328    /// 0 pixel will be the specified background color, while other pixels have
2329    /// varying degrees of the foreground color. This function returns the new
2330    /// surface, or NULL if there was an error.
2331    ///
2332    /// The glyph is rendered without any padding or centering in the X direction,
2333    /// and aligned normally in the Y direction.
2334    ///
2335    /// You can render at other quality levels with [`TTF_RenderGlyph_Solid`],
2336    /// [`TTF_RenderGlyph_Blended`], and [`TTF_RenderGlyph_LCD`].
2337    ///
2338    /// ## Parameters
2339    /// - `font`: the font to render with.
2340    /// - `ch`: the codepoint to render.
2341    /// - `fg`: the foreground color for the text.
2342    /// - `bg`: the background color for the text.
2343    ///
2344    /// ## Return value
2345    /// Returns a new 8-bit, palettized surface, or NULL if there was an error.
2346    ///
2347    /// ## Thread safety
2348    /// This function should be called on the thread that created the
2349    ///   font.
2350    ///
2351    /// ## Availability
2352    /// This function is available since SDL_ttf 3.0.0.
2353    ///
2354    /// ## See also
2355    /// - [`TTF_RenderGlyph_Blended`]
2356    /// - [`TTF_RenderGlyph_LCD`]
2357    /// - [`TTF_RenderGlyph_Solid`]
2358    pub fn TTF_RenderGlyph_Shaded(
2359        font: *mut TTF_Font,
2360        ch: Uint32,
2361        fg: SDL_Color,
2362        bg: SDL_Color,
2363    ) -> *mut SDL_Surface;
2364}
2365
2366unsafe extern "C" {
2367    /// Render UTF-8 text at high quality to a new ARGB surface.
2368    ///
2369    /// This function will allocate a new 32-bit, ARGB surface, using alpha
2370    /// blending to dither the font with the given color. This function returns the
2371    /// new surface, or NULL if there was an error.
2372    ///
2373    /// This will not word-wrap the string; you'll get a surface with a single line
2374    /// of text, as long as the string requires. You can use
2375    /// [`TTF_RenderText_Blended_Wrapped()`] instead if you need to wrap the output to
2376    /// multiple lines.
2377    ///
2378    /// This will not wrap on newline characters.
2379    ///
2380    /// You can render at other quality levels with [`TTF_RenderText_Solid`],
2381    /// [`TTF_RenderText_Shaded`], and [`TTF_RenderText_LCD`].
2382    ///
2383    /// ## Parameters
2384    /// - `font`: the font to render with.
2385    /// - `text`: text to render, in UTF-8 encoding.
2386    /// - `length`: the length of the text, in bytes, or 0 for null terminated
2387    ///   text.
2388    /// - `fg`: the foreground color for the text.
2389    ///
2390    /// ## Return value
2391    /// Returns a new 32-bit, ARGB surface, or NULL if there was an error.
2392    ///
2393    /// ## Thread safety
2394    /// This function should be called on the thread that created the
2395    ///   font.
2396    ///
2397    /// ## Availability
2398    /// This function is available since SDL_ttf 3.0.0.
2399    ///
2400    /// ## See also
2401    /// - [`TTF_RenderText_Blended_Wrapped`]
2402    /// - [`TTF_RenderText_LCD`]
2403    /// - [`TTF_RenderText_Shaded`]
2404    /// - [`TTF_RenderText_Solid`]
2405    pub fn TTF_RenderText_Blended(
2406        font: *mut TTF_Font,
2407        text: *const ::core::ffi::c_char,
2408        length: ::core::primitive::usize,
2409        fg: SDL_Color,
2410    ) -> *mut SDL_Surface;
2411}
2412
2413unsafe extern "C" {
2414    /// Render word-wrapped UTF-8 text at high quality to a new ARGB surface.
2415    ///
2416    /// This function will allocate a new 32-bit, ARGB surface, using alpha
2417    /// blending to dither the font with the given color. This function returns the
2418    /// new surface, or NULL if there was an error.
2419    ///
2420    /// Text is wrapped to multiple lines on line endings and on word boundaries if
2421    /// it extends beyond `wrap_width` in pixels.
2422    ///
2423    /// If wrap_width is 0, this function will only wrap on newline characters.
2424    ///
2425    /// You can render at other quality levels with [`TTF_RenderText_Solid_Wrapped`],
2426    /// [`TTF_RenderText_Shaded_Wrapped`], and [`TTF_RenderText_LCD_Wrapped`].
2427    ///
2428    /// ## Parameters
2429    /// - `font`: the font to render with.
2430    /// - `text`: text to render, in UTF-8 encoding.
2431    /// - `length`: the length of the text, in bytes, or 0 for null terminated
2432    ///   text.
2433    /// - `fg`: the foreground color for the text.
2434    /// - `wrap_width`: the maximum width of the text surface or 0 to wrap on
2435    ///   newline characters.
2436    ///
2437    /// ## Return value
2438    /// Returns a new 32-bit, ARGB surface, or NULL if there was an error.
2439    ///
2440    /// ## Thread safety
2441    /// This function should be called on the thread that created the
2442    ///   font.
2443    ///
2444    /// ## Availability
2445    /// This function is available since SDL_ttf 3.0.0.
2446    ///
2447    /// ## See also
2448    /// - [`TTF_RenderText_Blended`]
2449    /// - [`TTF_RenderText_LCD_Wrapped`]
2450    /// - [`TTF_RenderText_Shaded_Wrapped`]
2451    /// - [`TTF_RenderText_Solid_Wrapped`]
2452    pub fn TTF_RenderText_Blended_Wrapped(
2453        font: *mut TTF_Font,
2454        text: *const ::core::ffi::c_char,
2455        length: ::core::primitive::usize,
2456        fg: SDL_Color,
2457        wrap_width: ::core::ffi::c_int,
2458    ) -> *mut SDL_Surface;
2459}
2460
2461unsafe extern "C" {
2462    /// Render a single UNICODE codepoint at high quality to a new ARGB surface.
2463    ///
2464    /// This function will allocate a new 32-bit, ARGB surface, using alpha
2465    /// blending to dither the font with the given color. This function returns the
2466    /// new surface, or NULL if there was an error.
2467    ///
2468    /// The glyph is rendered without any padding or centering in the X direction,
2469    /// and aligned normally in the Y direction.
2470    ///
2471    /// You can render at other quality levels with [`TTF_RenderGlyph_Solid`],
2472    /// [`TTF_RenderGlyph_Shaded`], and [`TTF_RenderGlyph_LCD`].
2473    ///
2474    /// ## Parameters
2475    /// - `font`: the font to render with.
2476    /// - `ch`: the codepoint to render.
2477    /// - `fg`: the foreground color for the text.
2478    ///
2479    /// ## Return value
2480    /// Returns a new 32-bit, ARGB surface, or NULL if there was an error.
2481    ///
2482    /// ## Thread safety
2483    /// This function should be called on the thread that created the
2484    ///   font.
2485    ///
2486    /// ## Availability
2487    /// This function is available since SDL_ttf 3.0.0.
2488    ///
2489    /// ## See also
2490    /// - [`TTF_RenderGlyph_LCD`]
2491    /// - [`TTF_RenderGlyph_Shaded`]
2492    /// - [`TTF_RenderGlyph_Solid`]
2493    pub fn TTF_RenderGlyph_Blended(
2494        font: *mut TTF_Font,
2495        ch: Uint32,
2496        fg: SDL_Color,
2497    ) -> *mut SDL_Surface;
2498}
2499
2500unsafe extern "C" {
2501    /// Render UTF-8 text at LCD subpixel quality to a new ARGB surface.
2502    ///
2503    /// This function will allocate a new 32-bit, ARGB surface, and render
2504    /// alpha-blended text using FreeType's LCD subpixel rendering. This function
2505    /// returns the new surface, or NULL if there was an error.
2506    ///
2507    /// This will not word-wrap the string; you'll get a surface with a single line
2508    /// of text, as long as the string requires. You can use
2509    /// [`TTF_RenderText_LCD_Wrapped()`] instead if you need to wrap the output to
2510    /// multiple lines.
2511    ///
2512    /// This will not wrap on newline characters.
2513    ///
2514    /// You can render at other quality levels with [`TTF_RenderText_Solid`],
2515    /// [`TTF_RenderText_Shaded`], and [`TTF_RenderText_Blended`].
2516    ///
2517    /// ## Parameters
2518    /// - `font`: the font to render with.
2519    /// - `text`: text to render, in UTF-8 encoding.
2520    /// - `length`: the length of the text, in bytes, or 0 for null terminated
2521    ///   text.
2522    /// - `fg`: the foreground color for the text.
2523    /// - `bg`: the background color for the text.
2524    ///
2525    /// ## Return value
2526    /// Returns a new 32-bit, ARGB surface, or NULL if there was an error.
2527    ///
2528    /// ## Thread safety
2529    /// This function should be called on the thread that created the
2530    ///   font.
2531    ///
2532    /// ## Availability
2533    /// This function is available since SDL_ttf 3.0.0.
2534    ///
2535    /// ## See also
2536    /// - [`TTF_RenderText_Blended`]
2537    /// - [`TTF_RenderText_LCD_Wrapped`]
2538    /// - [`TTF_RenderText_Shaded`]
2539    /// - [`TTF_RenderText_Solid`]
2540    pub fn TTF_RenderText_LCD(
2541        font: *mut TTF_Font,
2542        text: *const ::core::ffi::c_char,
2543        length: ::core::primitive::usize,
2544        fg: SDL_Color,
2545        bg: SDL_Color,
2546    ) -> *mut SDL_Surface;
2547}
2548
2549unsafe extern "C" {
2550    /// Render word-wrapped UTF-8 text at LCD subpixel quality to a new ARGB
2551    /// surface.
2552    ///
2553    /// This function will allocate a new 32-bit, ARGB surface, and render
2554    /// alpha-blended text using FreeType's LCD subpixel rendering. This function
2555    /// returns the new surface, or NULL if there was an error.
2556    ///
2557    /// Text is wrapped to multiple lines on line endings and on word boundaries if
2558    /// it extends beyond `wrap_width` in pixels.
2559    ///
2560    /// If wrap_width is 0, this function will only wrap on newline characters.
2561    ///
2562    /// You can render at other quality levels with [`TTF_RenderText_Solid_Wrapped`],
2563    /// [`TTF_RenderText_Shaded_Wrapped`], and [`TTF_RenderText_Blended_Wrapped`].
2564    ///
2565    /// ## Parameters
2566    /// - `font`: the font to render with.
2567    /// - `text`: text to render, in UTF-8 encoding.
2568    /// - `length`: the length of the text, in bytes, or 0 for null terminated
2569    ///   text.
2570    /// - `fg`: the foreground color for the text.
2571    /// - `bg`: the background color for the text.
2572    /// - `wrap_width`: the maximum width of the text surface or 0 to wrap on
2573    ///   newline characters.
2574    ///
2575    /// ## Return value
2576    /// Returns a new 32-bit, ARGB surface, or NULL if there was an error.
2577    ///
2578    /// ## Thread safety
2579    /// This function should be called on the thread that created the
2580    ///   font.
2581    ///
2582    /// ## Availability
2583    /// This function is available since SDL_ttf 3.0.0.
2584    ///
2585    /// ## See also
2586    /// - [`TTF_RenderText_Blended_Wrapped`]
2587    /// - [`TTF_RenderText_LCD`]
2588    /// - [`TTF_RenderText_Shaded_Wrapped`]
2589    /// - [`TTF_RenderText_Solid_Wrapped`]
2590    pub fn TTF_RenderText_LCD_Wrapped(
2591        font: *mut TTF_Font,
2592        text: *const ::core::ffi::c_char,
2593        length: ::core::primitive::usize,
2594        fg: SDL_Color,
2595        bg: SDL_Color,
2596        wrap_width: ::core::ffi::c_int,
2597    ) -> *mut SDL_Surface;
2598}
2599
2600unsafe extern "C" {
2601    /// Render a single UNICODE codepoint at LCD subpixel quality to a new ARGB
2602    /// surface.
2603    ///
2604    /// This function will allocate a new 32-bit, ARGB surface, and render
2605    /// alpha-blended text using FreeType's LCD subpixel rendering. This function
2606    /// returns the new surface, or NULL if there was an error.
2607    ///
2608    /// The glyph is rendered without any padding or centering in the X direction,
2609    /// and aligned normally in the Y direction.
2610    ///
2611    /// You can render at other quality levels with [`TTF_RenderGlyph_Solid`],
2612    /// [`TTF_RenderGlyph_Shaded`], and [`TTF_RenderGlyph_Blended`].
2613    ///
2614    /// ## Parameters
2615    /// - `font`: the font to render with.
2616    /// - `ch`: the codepoint to render.
2617    /// - `fg`: the foreground color for the text.
2618    /// - `bg`: the background color for the text.
2619    ///
2620    /// ## Return value
2621    /// Returns a new 32-bit, ARGB surface, or NULL if there was an error.
2622    ///
2623    /// ## Thread safety
2624    /// This function should be called on the thread that created the
2625    ///   font.
2626    ///
2627    /// ## Availability
2628    /// This function is available since SDL_ttf 3.0.0.
2629    ///
2630    /// ## See also
2631    /// - [`TTF_RenderGlyph_Blended`]
2632    /// - [`TTF_RenderGlyph_Shaded`]
2633    /// - [`TTF_RenderGlyph_Solid`]
2634    pub fn TTF_RenderGlyph_LCD(
2635        font: *mut TTF_Font,
2636        ch: Uint32,
2637        fg: SDL_Color,
2638        bg: SDL_Color,
2639    ) -> *mut SDL_Surface;
2640}
2641
2642/// A text engine used to create text objects.
2643///
2644/// This is a public interface that can be used by applications and libraries
2645/// to perform customize rendering with text objects. See
2646/// <SDL3_ttf/SDL_textengine.h> for details.
2647///
2648/// There are three text engines provided with the library:
2649///
2650/// - Drawing to an [`SDL_Surface`], created with [`TTF_CreateSurfaceTextEngine()`]
2651/// - Drawing with an SDL 2D renderer, created with
2652///   [`TTF_CreateRendererTextEngine()`]
2653/// - Drawing with the SDL GPU API, created with [`TTF_CreateGPUTextEngine()`]
2654///
2655/// ## Availability
2656/// This struct is available since SDL_ttf 3.0.0.
2657pub use super::textengine::TTF_TextEngine;
2658
2659/// Internal data for [`TTF_Text`]
2660///
2661/// ## Availability
2662/// This struct is available since SDL_ttf 3.0.0.
2663pub use super::textengine::TTF_TextData;
2664
2665/// Text created with [`TTF_CreateText()`]
2666///
2667/// ## Availability
2668/// This struct is available since SDL_ttf 3.0.0.
2669///
2670/// ## See also
2671/// - [`TTF_CreateText`]
2672/// - [`TTF_GetTextProperties`]
2673/// - [`TTF_DestroyText`]
2674///
2675/// ## Notes for `sdl3-sys`
2676/// This struct can't be created manually. Use the corresponding SDL functions.
2677#[repr(C)]
2678#[cfg_attr(feature = "debug-impls", derive(Debug))]
2679pub struct TTF_Text {
2680    /// A copy of the UTF-8 string that this text object represents, useful for layout, debugging and retrieving substring text. This is updated when the text object is modified and will be freed automatically when the object is destroyed.
2681    pub text: *mut ::core::ffi::c_char,
2682    /// The number of lines in the text, 0 if it's empty
2683    pub num_lines: ::core::ffi::c_int,
2684    /// Application reference count, used when freeing surface
2685    pub refcount: ::core::ffi::c_int,
2686    /// Private
2687    pub internal: *mut TTF_TextData,
2688    #[doc(hidden)]
2689    __non_exhaustive: ::sdl3_sys::NonExhaustive,
2690}
2691
2692unsafe extern "C" {
2693    /// Create a text engine for drawing text on SDL surfaces.
2694    ///
2695    /// ## Return value
2696    /// Returns a [`TTF_TextEngine`] object or NULL on failure; call [`SDL_GetError()`]
2697    ///   for more information.
2698    ///
2699    /// ## Thread safety
2700    /// It is safe to call this function from any thread.
2701    ///
2702    /// ## Availability
2703    /// This function is available since SDL_ttf 3.0.0.
2704    ///
2705    /// ## See also
2706    /// - [`TTF_DestroySurfaceTextEngine`]
2707    /// - [`TTF_DrawSurfaceText`]
2708    pub fn TTF_CreateSurfaceTextEngine() -> *mut TTF_TextEngine;
2709}
2710
2711unsafe extern "C" {
2712    /// Draw text to an SDL surface.
2713    ///
2714    /// `text` must have been created using a [`TTF_TextEngine`] from
2715    /// [`TTF_CreateSurfaceTextEngine()`].
2716    ///
2717    /// ## Parameters
2718    /// - `text`: the text to draw.
2719    /// - `x`: the x coordinate in pixels, positive from the left edge towards
2720    ///   the right.
2721    /// - `y`: the y coordinate in pixels, positive from the top edge towards the
2722    ///   bottom.
2723    /// - `surface`: the surface to draw on.
2724    ///
2725    /// ## Return value
2726    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2727    ///   information.
2728    ///
2729    /// ## Thread safety
2730    /// This function should be called on the thread that created the
2731    ///   text.
2732    ///
2733    /// ## Availability
2734    /// This function is available since SDL_ttf 3.0.0.
2735    ///
2736    /// ## See also
2737    /// - [`TTF_CreateSurfaceTextEngine`]
2738    /// - [`TTF_CreateText`]
2739    pub fn TTF_DrawSurfaceText(
2740        text: *mut TTF_Text,
2741        x: ::core::ffi::c_int,
2742        y: ::core::ffi::c_int,
2743        surface: *mut SDL_Surface,
2744    ) -> ::core::primitive::bool;
2745}
2746
2747unsafe extern "C" {
2748    /// Destroy a text engine created for drawing text on SDL surfaces.
2749    ///
2750    /// All text created by this engine should be destroyed before calling this
2751    /// function.
2752    ///
2753    /// ## Parameters
2754    /// - `engine`: a [`TTF_TextEngine`] object created with
2755    ///   [`TTF_CreateSurfaceTextEngine()`].
2756    ///
2757    /// ## Thread safety
2758    /// This function should be called on the thread that created the
2759    ///   engine.
2760    ///
2761    /// ## Availability
2762    /// This function is available since SDL_ttf 3.0.0.
2763    ///
2764    /// ## See also
2765    /// - [`TTF_CreateSurfaceTextEngine`]
2766    pub fn TTF_DestroySurfaceTextEngine(engine: *mut TTF_TextEngine);
2767}
2768
2769unsafe extern "C" {
2770    /// Create a text engine for drawing text on an SDL renderer.
2771    ///
2772    /// ## Parameters
2773    /// - `renderer`: the renderer to use for creating textures and drawing text.
2774    ///
2775    /// ## Return value
2776    /// Returns a [`TTF_TextEngine`] object or NULL on failure; call [`SDL_GetError()`]
2777    ///   for more information.
2778    ///
2779    /// ## Thread safety
2780    /// This function should be called on the thread that created the
2781    ///   renderer.
2782    ///
2783    /// ## Availability
2784    /// This function is available since SDL_ttf 3.0.0.
2785    ///
2786    /// ## See also
2787    /// - [`TTF_DestroyRendererTextEngine`]
2788    /// - [`TTF_DrawRendererText`]
2789    /// - [`TTF_CreateRendererTextEngineWithProperties`]
2790    pub fn TTF_CreateRendererTextEngine(renderer: *mut SDL_Renderer) -> *mut TTF_TextEngine;
2791}
2792
2793unsafe extern "C" {
2794    /// Create a text engine for drawing text on an SDL renderer, with the
2795    /// specified properties.
2796    ///
2797    /// These are the supported properties:
2798    ///
2799    /// - [`TTF_PROP_RENDERER_TEXT_ENGINE_RENDERER`]\: the renderer to use for
2800    ///   creating textures and drawing text
2801    /// - [`TTF_PROP_RENDERER_TEXT_ENGINE_ATLAS_TEXTURE_SIZE`]\: the size of the
2802    ///   texture atlas
2803    ///
2804    /// ## Parameters
2805    /// - `props`: the properties to use.
2806    ///
2807    /// ## Return value
2808    /// Returns a [`TTF_TextEngine`] object or NULL on failure; call [`SDL_GetError()`]
2809    ///   for more information.
2810    ///
2811    /// ## Thread safety
2812    /// This function should be called on the thread that created the
2813    ///   renderer.
2814    ///
2815    /// ## Availability
2816    /// This function is available since SDL_ttf 3.0.0.
2817    ///
2818    /// ## See also
2819    /// - [`TTF_CreateRendererTextEngine`]
2820    /// - [`TTF_DestroyRendererTextEngine`]
2821    /// - [`TTF_DrawRendererText`]
2822    pub fn TTF_CreateRendererTextEngineWithProperties(
2823        props: SDL_PropertiesID,
2824    ) -> *mut TTF_TextEngine;
2825}
2826
2827pub const TTF_PROP_RENDERER_TEXT_ENGINE_RENDERER: *const ::core::ffi::c_char =
2828    c"SDL_ttf.renderer_text_engine.create.renderer".as_ptr();
2829
2830pub const TTF_PROP_RENDERER_TEXT_ENGINE_ATLAS_TEXTURE_SIZE: *const ::core::ffi::c_char =
2831    c"SDL_ttf.renderer_text_engine.create.atlas_texture_size".as_ptr();
2832
2833unsafe extern "C" {
2834    /// Draw text to an SDL renderer.
2835    ///
2836    /// `text` must have been created using a [`TTF_TextEngine`] from
2837    /// [`TTF_CreateRendererTextEngine()`], and will draw using the renderer passed to
2838    /// that function.
2839    ///
2840    /// ## Parameters
2841    /// - `text`: the text to draw.
2842    /// - `x`: the x coordinate in pixels, positive from the left edge towards
2843    ///   the right.
2844    /// - `y`: the y coordinate in pixels, positive from the top edge towards the
2845    ///   bottom.
2846    ///
2847    /// ## Return value
2848    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2849    ///   information.
2850    ///
2851    /// ## Thread safety
2852    /// This function should be called on the thread that created the
2853    ///   text.
2854    ///
2855    /// ## Availability
2856    /// This function is available since SDL_ttf 3.0.0.
2857    ///
2858    /// ## See also
2859    /// - [`TTF_CreateRendererTextEngine`]
2860    /// - [`TTF_CreateText`]
2861    pub fn TTF_DrawRendererText(
2862        text: *mut TTF_Text,
2863        x: ::core::ffi::c_float,
2864        y: ::core::ffi::c_float,
2865    ) -> ::core::primitive::bool;
2866}
2867
2868unsafe extern "C" {
2869    /// Destroy a text engine created for drawing text on an SDL renderer.
2870    ///
2871    /// All text created by this engine should be destroyed before calling this
2872    /// function.
2873    ///
2874    /// ## Parameters
2875    /// - `engine`: a [`TTF_TextEngine`] object created with
2876    ///   [`TTF_CreateRendererTextEngine()`].
2877    ///
2878    /// ## Thread safety
2879    /// This function should be called on the thread that created the
2880    ///   engine.
2881    ///
2882    /// ## Availability
2883    /// This function is available since SDL_ttf 3.0.0.
2884    ///
2885    /// ## See also
2886    /// - [`TTF_CreateRendererTextEngine`]
2887    pub fn TTF_DestroyRendererTextEngine(engine: *mut TTF_TextEngine);
2888}
2889
2890unsafe extern "C" {
2891    /// Create a text engine for drawing text with the SDL GPU API.
2892    ///
2893    /// ## Parameters
2894    /// - `device`: the [`SDL_GPUDevice`] to use for creating textures and drawing
2895    ///   text.
2896    ///
2897    /// ## Return value
2898    /// Returns a [`TTF_TextEngine`] object or NULL on failure; call [`SDL_GetError()`]
2899    ///   for more information.
2900    ///
2901    /// ## Thread safety
2902    /// This function should be called on the thread that created the
2903    ///   device.
2904    ///
2905    /// ## Availability
2906    /// This function is available since SDL_ttf 3.0.0.
2907    ///
2908    /// ## See also
2909    /// - [`TTF_CreateGPUTextEngineWithProperties`]
2910    /// - [`TTF_DestroyGPUTextEngine`]
2911    /// - [`TTF_GetGPUTextDrawData`]
2912    pub fn TTF_CreateGPUTextEngine(device: *mut SDL_GPUDevice) -> *mut TTF_TextEngine;
2913}
2914
2915unsafe extern "C" {
2916    /// Create a text engine for drawing text with the SDL GPU API, with the
2917    /// specified properties.
2918    ///
2919    /// These are the supported properties:
2920    ///
2921    /// - [`TTF_PROP_GPU_TEXT_ENGINE_DEVICE`]\: the [`SDL_GPUDevice`] to use for creating
2922    ///   textures and drawing text.
2923    /// - [`TTF_PROP_GPU_TEXT_ENGINE_ATLAS_TEXTURE_SIZE`]\: the size of the texture
2924    ///   atlas
2925    ///
2926    /// ## Parameters
2927    /// - `props`: the properties to use.
2928    ///
2929    /// ## Return value
2930    /// Returns a [`TTF_TextEngine`] object or NULL on failure; call [`SDL_GetError()`]
2931    ///   for more information.
2932    ///
2933    /// ## Thread safety
2934    /// This function should be called on the thread that created the
2935    ///   device.
2936    ///
2937    /// ## Availability
2938    /// This function is available since SDL_ttf 3.0.0.
2939    ///
2940    /// ## See also
2941    /// - [`TTF_CreateGPUTextEngine`]
2942    /// - [`TTF_DestroyGPUTextEngine`]
2943    /// - [`TTF_GetGPUTextDrawData`]
2944    pub fn TTF_CreateGPUTextEngineWithProperties(props: SDL_PropertiesID) -> *mut TTF_TextEngine;
2945}
2946
2947pub const TTF_PROP_GPU_TEXT_ENGINE_DEVICE: *const ::core::ffi::c_char =
2948    c"SDL_ttf.gpu_text_engine.create.device".as_ptr();
2949
2950pub const TTF_PROP_GPU_TEXT_ENGINE_ATLAS_TEXTURE_SIZE: *const ::core::ffi::c_char =
2951    c"SDL_ttf.gpu_text_engine.create.atlas_texture_size".as_ptr();
2952
2953/// Draw sequence returned by [`TTF_GetGPUTextDrawData`]
2954///
2955/// ## Availability
2956/// This struct is available since SDL_ttf 3.0.0.
2957///
2958/// ## See also
2959/// - [`TTF_GetGPUTextDrawData`]
2960#[repr(C)]
2961#[cfg_attr(feature = "debug-impls", derive(Debug))]
2962pub struct TTF_GPUAtlasDrawSequence {
2963    /// Texture atlas that stores the glyphs
2964    pub atlas_texture: *mut SDL_GPUTexture,
2965    /// An array of vertex positions
2966    pub xy: *mut SDL_FPoint,
2967    /// An array of normalized texture coordinates for each vertex
2968    pub uv: *mut SDL_FPoint,
2969    /// Number of vertices
2970    pub num_vertices: ::core::ffi::c_int,
2971    /// An array of indices into the 'vertices' arrays
2972    pub indices: *mut ::core::ffi::c_int,
2973    /// Number of indices
2974    pub num_indices: ::core::ffi::c_int,
2975    /// The image type of this draw sequence
2976    pub image_type: TTF_ImageType,
2977    /// The next sequence (will be NULL in case of the last sequence)
2978    pub next: *mut TTF_GPUAtlasDrawSequence,
2979}
2980
2981impl ::core::default::Default for TTF_GPUAtlasDrawSequence {
2982    /// Initialize all fields to zero
2983    #[inline(always)]
2984    fn default() -> Self {
2985        unsafe { ::core::mem::MaybeUninit::<Self>::zeroed().assume_init() }
2986    }
2987}
2988
2989unsafe extern "C" {
2990    /// Get the geometry data needed for drawing the text.
2991    ///
2992    /// `text` must have been created using a [`TTF_TextEngine`] from
2993    /// [`TTF_CreateGPUTextEngine()`].
2994    ///
2995    /// The positive X-axis is taken towards the right and the positive Y-axis is
2996    /// taken upwards for both the vertex and the texture coordinates, i.e, it
2997    /// follows the same convention used by the SDL_GPU API. If you want to use a
2998    /// different coordinate system you will need to transform the vertices
2999    /// yourself.
3000    ///
3001    /// If the text looks blocky use linear filtering.
3002    ///
3003    /// ## Parameters
3004    /// - `text`: the text to draw.
3005    ///
3006    /// ## Return value
3007    /// Returns a NULL terminated linked list of [`TTF_GPUAtlasDrawSequence`] objects
3008    ///   or NULL if the passed text is empty or in case of failure; call
3009    ///   [`SDL_GetError()`] for more information.
3010    ///
3011    /// ## Thread safety
3012    /// This function should be called on the thread that created the
3013    ///   text.
3014    ///
3015    /// ## Availability
3016    /// This function is available since SDL_ttf 3.0.0.
3017    ///
3018    /// ## See also
3019    /// - [`TTF_CreateGPUTextEngine`]
3020    /// - [`TTF_CreateText`]
3021    pub fn TTF_GetGPUTextDrawData(text: *mut TTF_Text) -> *mut TTF_GPUAtlasDrawSequence;
3022}
3023
3024unsafe extern "C" {
3025    /// Destroy a text engine created for drawing text with the SDL GPU API.
3026    ///
3027    /// All text created by this engine should be destroyed before calling this
3028    /// function.
3029    ///
3030    /// ## Parameters
3031    /// - `engine`: a [`TTF_TextEngine`] object created with
3032    ///   [`TTF_CreateGPUTextEngine()`].
3033    ///
3034    /// ## Thread safety
3035    /// This function should be called on the thread that created the
3036    ///   engine.
3037    ///
3038    /// ## Availability
3039    /// This function is available since SDL_ttf 3.0.0.
3040    ///
3041    /// ## See also
3042    /// - [`TTF_CreateGPUTextEngine`]
3043    pub fn TTF_DestroyGPUTextEngine(engine: *mut TTF_TextEngine);
3044}
3045
3046/// The winding order of the vertices returned by [`TTF_GetGPUTextDrawData`]
3047///
3048/// ## Availability
3049/// This enum is available since SDL_ttf 3.0.0.
3050///
3051/// ## Known values (`sdl3-sys`)
3052/// | Associated constant | Global constant | Description |
3053/// | ------------------- | --------------- | ----------- |
3054/// | [`INVALID`](TTF_GPUTextEngineWinding::INVALID) | [`TTF_GPU_TEXTENGINE_WINDING_INVALID`] | |
3055/// | [`CLOCKWISE`](TTF_GPUTextEngineWinding::CLOCKWISE) | [`TTF_GPU_TEXTENGINE_WINDING_CLOCKWISE`] | |
3056/// | [`COUNTER_CLOCKWISE`](TTF_GPUTextEngineWinding::COUNTER_CLOCKWISE) | [`TTF_GPU_TEXTENGINE_WINDING_COUNTER_CLOCKWISE`] | |
3057#[repr(transparent)]
3058#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3059pub struct TTF_GPUTextEngineWinding(pub ::core::ffi::c_int);
3060
3061impl ::core::cmp::PartialEq<::core::ffi::c_int> for TTF_GPUTextEngineWinding {
3062    #[inline(always)]
3063    fn eq(&self, other: &::core::ffi::c_int) -> bool {
3064        &self.0 == other
3065    }
3066}
3067
3068impl ::core::cmp::PartialEq<TTF_GPUTextEngineWinding> for ::core::ffi::c_int {
3069    #[inline(always)]
3070    fn eq(&self, other: &TTF_GPUTextEngineWinding) -> bool {
3071        self == &other.0
3072    }
3073}
3074
3075impl From<TTF_GPUTextEngineWinding> for ::core::ffi::c_int {
3076    #[inline(always)]
3077    fn from(value: TTF_GPUTextEngineWinding) -> Self {
3078        value.0
3079    }
3080}
3081
3082#[cfg(feature = "debug-impls")]
3083impl ::core::fmt::Debug for TTF_GPUTextEngineWinding {
3084    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
3085        #[allow(unreachable_patterns)]
3086        f.write_str(match *self {
3087            Self::INVALID => "TTF_GPU_TEXTENGINE_WINDING_INVALID",
3088            Self::CLOCKWISE => "TTF_GPU_TEXTENGINE_WINDING_CLOCKWISE",
3089            Self::COUNTER_CLOCKWISE => "TTF_GPU_TEXTENGINE_WINDING_COUNTER_CLOCKWISE",
3090
3091            _ => return write!(f, "TTF_GPUTextEngineWinding({})", self.0),
3092        })
3093    }
3094}
3095
3096impl TTF_GPUTextEngineWinding {
3097    pub const INVALID: Self = Self((-1_i32 as ::core::ffi::c_int));
3098    pub const CLOCKWISE: Self = Self((0_i32 as ::core::ffi::c_int));
3099    pub const COUNTER_CLOCKWISE: Self = Self((1_i32 as ::core::ffi::c_int));
3100}
3101
3102pub const TTF_GPU_TEXTENGINE_WINDING_INVALID: TTF_GPUTextEngineWinding =
3103    TTF_GPUTextEngineWinding::INVALID;
3104pub const TTF_GPU_TEXTENGINE_WINDING_CLOCKWISE: TTF_GPUTextEngineWinding =
3105    TTF_GPUTextEngineWinding::CLOCKWISE;
3106pub const TTF_GPU_TEXTENGINE_WINDING_COUNTER_CLOCKWISE: TTF_GPUTextEngineWinding =
3107    TTF_GPUTextEngineWinding::COUNTER_CLOCKWISE;
3108
3109#[cfg(feature = "metadata")]
3110impl sdl3_sys::metadata::GroupMetadata for TTF_GPUTextEngineWinding {
3111    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
3112        &crate::metadata::ttf::METADATA_TTF_GPUTextEngineWinding;
3113}
3114
3115unsafe extern "C" {
3116    /// Sets the winding order of the vertices returned by [`TTF_GetGPUTextDrawData`]
3117    /// for a particular GPU text engine.
3118    ///
3119    /// ## Parameters
3120    /// - `engine`: a [`TTF_TextEngine`] object created with
3121    ///   [`TTF_CreateGPUTextEngine()`].
3122    /// - `winding`: the new winding order option.
3123    ///
3124    /// ## Thread safety
3125    /// This function should be called on the thread that created the
3126    ///   engine.
3127    ///
3128    /// ## Availability
3129    /// This function is available since SDL_ttf 3.0.0.
3130    ///
3131    /// ## See also
3132    /// - [`TTF_GetGPUTextEngineWinding`]
3133    pub fn TTF_SetGPUTextEngineWinding(
3134        engine: *mut TTF_TextEngine,
3135        winding: TTF_GPUTextEngineWinding,
3136    );
3137}
3138
3139unsafe extern "C" {
3140    /// Get the winding order of the vertices returned by [`TTF_GetGPUTextDrawData`]
3141    /// for a particular GPU text engine
3142    ///
3143    /// ## Parameters
3144    /// - `engine`: a [`TTF_TextEngine`] object created with
3145    ///   [`TTF_CreateGPUTextEngine()`].
3146    ///
3147    /// ## Return value
3148    /// Returns the winding order used by the GPU text engine or
3149    ///   [`TTF_GPU_TEXTENGINE_WINDING_INVALID`] in case of error.
3150    ///
3151    /// ## Thread safety
3152    /// This function should be called on the thread that created the
3153    ///   engine.
3154    ///
3155    /// ## Availability
3156    /// This function is available since SDL_ttf 3.0.0.
3157    ///
3158    /// ## See also
3159    /// - [`TTF_SetGPUTextEngineWinding`]
3160    pub fn TTF_GetGPUTextEngineWinding(engine: *const TTF_TextEngine) -> TTF_GPUTextEngineWinding;
3161}
3162
3163unsafe extern "C" {
3164    /// Create a text object from UTF-8 text and a text engine.
3165    ///
3166    /// ## Parameters
3167    /// - `engine`: the text engine to use when creating the text object, may be
3168    ///   NULL.
3169    /// - `font`: the font to render with.
3170    /// - `text`: the text to use, in UTF-8 encoding.
3171    /// - `length`: the length of the text, in bytes, or 0 for null terminated
3172    ///   text.
3173    ///
3174    /// ## Return value
3175    /// Returns a [`TTF_Text`] object or NULL on failure; call [`SDL_GetError()`] for more
3176    ///   information.
3177    ///
3178    /// ## Thread safety
3179    /// This function should be called on the thread that created the
3180    ///   font and text engine.
3181    ///
3182    /// ## Availability
3183    /// This function is available since SDL_ttf 3.0.0.
3184    ///
3185    /// ## See also
3186    /// - [`TTF_DestroyText`]
3187    pub fn TTF_CreateText(
3188        engine: *mut TTF_TextEngine,
3189        font: *mut TTF_Font,
3190        text: *const ::core::ffi::c_char,
3191        length: ::core::primitive::usize,
3192    ) -> *mut TTF_Text;
3193}
3194
3195unsafe extern "C" {
3196    /// Get the properties associated with a text object.
3197    ///
3198    /// ## Parameters
3199    /// - `text`: the [`TTF_Text`] to query.
3200    ///
3201    /// ## Return value
3202    /// Returns a valid property ID on success or 0 on failure; call
3203    ///   [`SDL_GetError()`] for more information.
3204    ///
3205    /// ## Thread safety
3206    /// This function should be called on the thread that created the
3207    ///   text.
3208    ///
3209    /// ## Availability
3210    /// This function is available since SDL_ttf 3.0.0.
3211    pub fn TTF_GetTextProperties(text: *mut TTF_Text) -> SDL_PropertiesID;
3212}
3213
3214unsafe extern "C" {
3215    /// Set the text engine used by a text object.
3216    ///
3217    /// This function may cause the internal text representation to be rebuilt.
3218    ///
3219    /// ## Parameters
3220    /// - `text`: the [`TTF_Text`] to modify.
3221    /// - `engine`: the text engine to use for drawing.
3222    ///
3223    /// ## Return value
3224    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3225    ///   information.
3226    ///
3227    /// ## Thread safety
3228    /// This function should be called on the thread that created the
3229    ///   text.
3230    ///
3231    /// ## Availability
3232    /// This function is available since SDL_ttf 3.0.0.
3233    ///
3234    /// ## See also
3235    /// - [`TTF_GetTextEngine`]
3236    pub fn TTF_SetTextEngine(
3237        text: *mut TTF_Text,
3238        engine: *mut TTF_TextEngine,
3239    ) -> ::core::primitive::bool;
3240}
3241
3242unsafe extern "C" {
3243    /// Get the text engine used by a text object.
3244    ///
3245    /// ## Parameters
3246    /// - `text`: the [`TTF_Text`] to query.
3247    ///
3248    /// ## Return value
3249    /// Returns the [`TTF_TextEngine`] used by the text on success or NULL on failure;
3250    ///   call [`SDL_GetError()`] for more information.
3251    ///
3252    /// ## Thread safety
3253    /// This function should be called on the thread that created the
3254    ///   text.
3255    ///
3256    /// ## Availability
3257    /// This function is available since SDL_ttf 3.0.0.
3258    ///
3259    /// ## See also
3260    /// - [`TTF_SetTextEngine`]
3261    pub fn TTF_GetTextEngine(text: *mut TTF_Text) -> *mut TTF_TextEngine;
3262}
3263
3264unsafe extern "C" {
3265    /// Set the font used by a text object.
3266    ///
3267    /// When a text object has a font, any changes to the font will automatically
3268    /// regenerate the text. If you set the font to NULL, the text will continue to
3269    /// render but changes to the font will no longer affect the text.
3270    ///
3271    /// This function may cause the internal text representation to be rebuilt.
3272    ///
3273    /// ## Parameters
3274    /// - `text`: the [`TTF_Text`] to modify.
3275    /// - `font`: the font to use, may be NULL.
3276    ///
3277    /// ## Return value
3278    /// Returns false if the text pointer is null; otherwise, true. call
3279    ///   [`SDL_GetError()`] for more information.
3280    ///
3281    /// ## Thread safety
3282    /// This function should be called on the thread that created the
3283    ///   text.
3284    ///
3285    /// ## Availability
3286    /// This function is available since SDL_ttf 3.0.0.
3287    ///
3288    /// ## See also
3289    /// - [`TTF_GetTextFont`]
3290    pub fn TTF_SetTextFont(text: *mut TTF_Text, font: *mut TTF_Font) -> ::core::primitive::bool;
3291}
3292
3293unsafe extern "C" {
3294    /// Get the font used by a text object.
3295    ///
3296    /// ## Parameters
3297    /// - `text`: the [`TTF_Text`] to query.
3298    ///
3299    /// ## Return value
3300    /// Returns the [`TTF_Font`] used by the text on success or NULL on failure; call
3301    ///   [`SDL_GetError()`] for more information.
3302    ///
3303    /// ## Thread safety
3304    /// This function should be called on the thread that created the
3305    ///   text.
3306    ///
3307    /// ## Availability
3308    /// This function is available since SDL_ttf 3.0.0.
3309    ///
3310    /// ## See also
3311    /// - [`TTF_SetTextFont`]
3312    pub fn TTF_GetTextFont(text: *mut TTF_Text) -> *mut TTF_Font;
3313}
3314
3315unsafe extern "C" {
3316    /// Set the direction to be used for text shaping a text object.
3317    ///
3318    /// This function only supports left-to-right text shaping if SDL_ttf was not
3319    /// built with HarfBuzz support.
3320    ///
3321    /// ## Parameters
3322    /// - `text`: the text to modify.
3323    /// - `direction`: the new direction for text to flow.
3324    ///
3325    /// ## Return value
3326    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3327    ///   information.
3328    ///
3329    /// ## Thread safety
3330    /// This function should be called on the thread that created the
3331    ///   text.
3332    ///
3333    /// ## Availability
3334    /// This function is available since SDL_ttf 3.0.0.
3335    pub fn TTF_SetTextDirection(
3336        text: *mut TTF_Text,
3337        direction: TTF_Direction,
3338    ) -> ::core::primitive::bool;
3339}
3340
3341unsafe extern "C" {
3342    /// Get the direction to be used for text shaping a text object.
3343    ///
3344    /// This defaults to the direction of the font used by the text object.
3345    ///
3346    /// ## Parameters
3347    /// - `text`: the text to query.
3348    ///
3349    /// ## Return value
3350    /// Returns the direction to be used for text shaping.
3351    ///
3352    /// ## Thread safety
3353    /// This function should be called on the thread that created the
3354    ///   text.
3355    ///
3356    /// ## Availability
3357    /// This function is available since SDL_ttf 3.0.0.
3358    pub fn TTF_GetTextDirection(text: *mut TTF_Text) -> TTF_Direction;
3359}
3360
3361unsafe extern "C" {
3362    /// Set the script to be used for text shaping a text object.
3363    ///
3364    /// This returns false if SDL_ttf isn't built with HarfBuzz support.
3365    ///
3366    /// ## Parameters
3367    /// - `text`: the text to modify.
3368    /// - `script`: an
3369    ///   [ISO 15924 code](https://unicode.org/iso15924/iso15924-codes.html)
3370    ///   .
3371    ///
3372    /// ## Return value
3373    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3374    ///   information.
3375    ///
3376    /// ## Thread safety
3377    /// This function should be called on the thread that created the
3378    ///   text.
3379    ///
3380    /// ## Availability
3381    /// This function is available since SDL_ttf 3.0.0.
3382    ///
3383    /// ## See also
3384    /// - [`TTF_StringToTag`]
3385    pub fn TTF_SetTextScript(text: *mut TTF_Text, script: Uint32) -> ::core::primitive::bool;
3386}
3387
3388unsafe extern "C" {
3389    /// Get the script used for text shaping a text object.
3390    ///
3391    /// This defaults to the script of the font used by the text object.
3392    ///
3393    /// ## Parameters
3394    /// - `text`: the text to query.
3395    ///
3396    /// ## Return value
3397    /// Returns an
3398    ///   [ISO 15924 code](https://unicode.org/iso15924/iso15924-codes.html)
3399    ///   or 0 if a script hasn't been set on either the text object or the
3400    ///   font.
3401    ///
3402    /// ## Thread safety
3403    /// This function should be called on the thread that created the
3404    ///   text.
3405    ///
3406    /// ## Availability
3407    /// This function is available since SDL_ttf 3.0.0.
3408    ///
3409    /// ## See also
3410    /// - [`TTF_TagToString`]
3411    pub fn TTF_GetTextScript(text: *mut TTF_Text) -> Uint32;
3412}
3413
3414unsafe extern "C" {
3415    /// Set the color of a text object.
3416    ///
3417    /// The default text color is white (255, 255, 255, 255).
3418    ///
3419    /// ## Parameters
3420    /// - `text`: the [`TTF_Text`] to modify.
3421    /// - `r`: the red color value in the range of 0-255.
3422    /// - `g`: the green color value in the range of 0-255.
3423    /// - `b`: the blue color value in the range of 0-255.
3424    /// - `a`: the alpha value in the range of 0-255.
3425    ///
3426    /// ## Return value
3427    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3428    ///   information.
3429    ///
3430    /// ## Thread safety
3431    /// This function should be called on the thread that created the
3432    ///   text.
3433    ///
3434    /// ## Availability
3435    /// This function is available since SDL_ttf 3.0.0.
3436    ///
3437    /// ## See also
3438    /// - [`TTF_GetTextColor`]
3439    /// - [`TTF_SetTextColorFloat`]
3440    pub fn TTF_SetTextColor(
3441        text: *mut TTF_Text,
3442        r: Uint8,
3443        g: Uint8,
3444        b: Uint8,
3445        a: Uint8,
3446    ) -> ::core::primitive::bool;
3447}
3448
3449unsafe extern "C" {
3450    /// Set the color of a text object.
3451    ///
3452    /// The default text color is white (1.0f, 1.0f, 1.0f, 1.0f).
3453    ///
3454    /// ## Parameters
3455    /// - `text`: the [`TTF_Text`] to modify.
3456    /// - `r`: the red color value, normally in the range of 0-1.
3457    /// - `g`: the green color value, normally in the range of 0-1.
3458    /// - `b`: the blue color value, normally in the range of 0-1.
3459    /// - `a`: the alpha value in the range of 0-1.
3460    ///
3461    /// ## Return value
3462    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3463    ///   information.
3464    ///
3465    /// ## Thread safety
3466    /// This function should be called on the thread that created the
3467    ///   text.
3468    ///
3469    /// ## Availability
3470    /// This function is available since SDL_ttf 3.0.0.
3471    ///
3472    /// ## See also
3473    /// - [`TTF_GetTextColorFloat`]
3474    /// - [`TTF_SetTextColor`]
3475    pub fn TTF_SetTextColorFloat(
3476        text: *mut TTF_Text,
3477        r: ::core::ffi::c_float,
3478        g: ::core::ffi::c_float,
3479        b: ::core::ffi::c_float,
3480        a: ::core::ffi::c_float,
3481    ) -> ::core::primitive::bool;
3482}
3483
3484unsafe extern "C" {
3485    /// Get the color of a text object.
3486    ///
3487    /// ## Parameters
3488    /// - `text`: the [`TTF_Text`] to query.
3489    /// - `r`: a pointer filled in with the red color value in the range of
3490    ///   0-255, may be NULL.
3491    /// - `g`: a pointer filled in with the green color value in the range of
3492    ///   0-255, may be NULL.
3493    /// - `b`: a pointer filled in with the blue color value in the range of
3494    ///   0-255, may be NULL.
3495    /// - `a`: a pointer filled in with the alpha value in the range of 0-255,
3496    ///   may be NULL.
3497    ///
3498    /// ## Return value
3499    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3500    ///   information.
3501    ///
3502    /// ## Thread safety
3503    /// This function should be called on the thread that created the
3504    ///   text.
3505    ///
3506    /// ## Availability
3507    /// This function is available since SDL_ttf 3.0.0.
3508    ///
3509    /// ## See also
3510    /// - [`TTF_GetTextColorFloat`]
3511    /// - [`TTF_SetTextColor`]
3512    pub fn TTF_GetTextColor(
3513        text: *mut TTF_Text,
3514        r: *mut Uint8,
3515        g: *mut Uint8,
3516        b: *mut Uint8,
3517        a: *mut Uint8,
3518    ) -> ::core::primitive::bool;
3519}
3520
3521unsafe extern "C" {
3522    /// Get the color of a text object.
3523    ///
3524    /// ## Parameters
3525    /// - `text`: the [`TTF_Text`] to query.
3526    /// - `r`: a pointer filled in with the red color value, normally in the
3527    ///   range of 0-1, may be NULL.
3528    /// - `g`: a pointer filled in with the green color value, normally in the
3529    ///   range of 0-1, may be NULL.
3530    /// - `b`: a pointer filled in with the blue color value, normally in the
3531    ///   range of 0-1, may be NULL.
3532    /// - `a`: a pointer filled in with the alpha value in the range of 0-1, may
3533    ///   be NULL.
3534    ///
3535    /// ## Return value
3536    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3537    ///   information.
3538    ///
3539    /// ## Thread safety
3540    /// This function should be called on the thread that created the
3541    ///   text.
3542    ///
3543    /// ## Availability
3544    /// This function is available since SDL_ttf 3.0.0.
3545    ///
3546    /// ## See also
3547    /// - [`TTF_GetTextColor`]
3548    /// - [`TTF_SetTextColorFloat`]
3549    pub fn TTF_GetTextColorFloat(
3550        text: *mut TTF_Text,
3551        r: *mut ::core::ffi::c_float,
3552        g: *mut ::core::ffi::c_float,
3553        b: *mut ::core::ffi::c_float,
3554        a: *mut ::core::ffi::c_float,
3555    ) -> ::core::primitive::bool;
3556}
3557
3558unsafe extern "C" {
3559    /// Set the position of a text object.
3560    ///
3561    /// This can be used to position multiple text objects within a single wrapping
3562    /// text area.
3563    ///
3564    /// This function may cause the internal text representation to be rebuilt.
3565    ///
3566    /// ## Parameters
3567    /// - `text`: the [`TTF_Text`] to modify.
3568    /// - `x`: the x offset of the upper left corner of this text in pixels.
3569    /// - `y`: the y offset of the upper left corner of this text in pixels.
3570    ///
3571    /// ## Thread safety
3572    /// This function should be called on the thread that created the
3573    ///   text.
3574    ///
3575    /// ## Availability
3576    /// This function is available since SDL_ttf 3.0.0.
3577    ///
3578    /// ## See also
3579    /// - [`TTF_GetTextPosition`]
3580    pub fn TTF_SetTextPosition(
3581        text: *mut TTF_Text,
3582        x: ::core::ffi::c_int,
3583        y: ::core::ffi::c_int,
3584    ) -> ::core::primitive::bool;
3585}
3586
3587unsafe extern "C" {
3588    /// Get the position of a text object.
3589    ///
3590    /// ## Parameters
3591    /// - `text`: the [`TTF_Text`] to query.
3592    /// - `x`: a pointer filled in with the x offset of the upper left corner of
3593    ///   this text in pixels, may be NULL.
3594    /// - `y`: a pointer filled in with the y offset of the upper left corner of
3595    ///   this text in pixels, may be NULL.
3596    ///
3597    /// ## Thread safety
3598    /// This function should be called on the thread that created the
3599    ///   text.
3600    ///
3601    /// ## Availability
3602    /// This function is available since SDL_ttf 3.0.0.
3603    ///
3604    /// ## See also
3605    /// - [`TTF_SetTextPosition`]
3606    pub fn TTF_GetTextPosition(
3607        text: *mut TTF_Text,
3608        x: *mut ::core::ffi::c_int,
3609        y: *mut ::core::ffi::c_int,
3610    ) -> ::core::primitive::bool;
3611}
3612
3613unsafe extern "C" {
3614    /// Set whether wrapping is enabled on a text object.
3615    ///
3616    /// This function may cause the internal text representation to be rebuilt.
3617    ///
3618    /// ## Parameters
3619    /// - `text`: the [`TTF_Text`] to modify.
3620    /// - `wrap_width`: the maximum width in pixels, 0 to wrap on newline
3621    ///   characters.
3622    ///
3623    /// ## Return value
3624    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3625    ///   information.
3626    ///
3627    /// ## Thread safety
3628    /// This function should be called on the thread that created the
3629    ///   text.
3630    ///
3631    /// ## Availability
3632    /// This function is available since SDL_ttf 3.0.0.
3633    ///
3634    /// ## See also
3635    /// - [`TTF_GetTextWrapWidth`]
3636    pub fn TTF_SetTextWrapWidth(
3637        text: *mut TTF_Text,
3638        wrap_width: ::core::ffi::c_int,
3639    ) -> ::core::primitive::bool;
3640}
3641
3642unsafe extern "C" {
3643    /// Get whether wrapping is enabled on a text object.
3644    ///
3645    /// ## Parameters
3646    /// - `text`: the [`TTF_Text`] to query.
3647    /// - `wrap_width`: a pointer filled in with the maximum width in pixels or 0
3648    ///   if the text is being wrapped on newline characters.
3649    ///
3650    /// ## Return value
3651    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3652    ///   information.
3653    ///
3654    /// ## Thread safety
3655    /// This function should be called on the thread that created the
3656    ///   text.
3657    ///
3658    /// ## Availability
3659    /// This function is available since SDL_ttf 3.0.0.
3660    ///
3661    /// ## See also
3662    /// - [`TTF_SetTextWrapWidth`]
3663    pub fn TTF_GetTextWrapWidth(
3664        text: *mut TTF_Text,
3665        wrap_width: *mut ::core::ffi::c_int,
3666    ) -> ::core::primitive::bool;
3667}
3668
3669unsafe extern "C" {
3670    /// Set whether whitespace should be visible when wrapping a text object.
3671    ///
3672    /// If the whitespace is visible, it will take up space for purposes of
3673    /// alignment and wrapping. This is good for editing, but looks better when
3674    /// centered or aligned if whitespace around line wrapping is hidden. This
3675    /// defaults false.
3676    ///
3677    /// This function may cause the internal text representation to be rebuilt.
3678    ///
3679    /// ## Parameters
3680    /// - `text`: the [`TTF_Text`] to modify.
3681    /// - `visible`: true to show whitespace when wrapping text, false to hide
3682    ///   it.
3683    ///
3684    /// ## Return value
3685    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3686    ///   information.
3687    ///
3688    /// ## Thread safety
3689    /// This function should be called on the thread that created the
3690    ///   text.
3691    ///
3692    /// ## Availability
3693    /// This function is available since SDL_ttf 3.0.0.
3694    ///
3695    /// ## See also
3696    /// - [`TTF_TextWrapWhitespaceVisible`]
3697    pub fn TTF_SetTextWrapWhitespaceVisible(
3698        text: *mut TTF_Text,
3699        visible: ::core::primitive::bool,
3700    ) -> ::core::primitive::bool;
3701}
3702
3703unsafe extern "C" {
3704    /// Return whether whitespace is shown when wrapping a text object.
3705    ///
3706    /// ## Parameters
3707    /// - `text`: the [`TTF_Text`] to query.
3708    ///
3709    /// ## Return value
3710    /// Returns true if whitespace is shown when wrapping text, or false
3711    ///   otherwise.
3712    ///
3713    /// ## Thread safety
3714    /// This function should be called on the thread that created the
3715    ///   text.
3716    ///
3717    /// ## Availability
3718    /// This function is available since SDL_ttf 3.0.0.
3719    ///
3720    /// ## See also
3721    /// - [`TTF_SetTextWrapWhitespaceVisible`]
3722    pub fn TTF_TextWrapWhitespaceVisible(text: *mut TTF_Text) -> ::core::primitive::bool;
3723}
3724
3725unsafe extern "C" {
3726    /// Set the UTF-8 text used by a text object.
3727    ///
3728    /// This function may cause the internal text representation to be rebuilt.
3729    ///
3730    /// ## Parameters
3731    /// - `text`: the [`TTF_Text`] to modify.
3732    /// - `string`: the UTF-8 text to use, may be NULL.
3733    /// - `length`: the length of the text, in bytes, or 0 for null terminated
3734    ///   text.
3735    ///
3736    /// ## Return value
3737    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3738    ///   information.
3739    ///
3740    /// ## Thread safety
3741    /// This function should be called on the thread that created the
3742    ///   text.
3743    ///
3744    /// ## Availability
3745    /// This function is available since SDL_ttf 3.0.0.
3746    ///
3747    /// ## See also
3748    /// - [`TTF_AppendTextString`]
3749    /// - [`TTF_DeleteTextString`]
3750    /// - [`TTF_InsertTextString`]
3751    pub fn TTF_SetTextString(
3752        text: *mut TTF_Text,
3753        string: *const ::core::ffi::c_char,
3754        length: ::core::primitive::usize,
3755    ) -> ::core::primitive::bool;
3756}
3757
3758unsafe extern "C" {
3759    /// Insert UTF-8 text into a text object.
3760    ///
3761    /// This function may cause the internal text representation to be rebuilt.
3762    ///
3763    /// ## Parameters
3764    /// - `text`: the [`TTF_Text`] to modify.
3765    /// - `offset`: the offset, in bytes, from the beginning of the string if >=
3766    ///   0, the offset from the end of the string if < 0. Note that
3767    ///   this does not do UTF-8 validation, so you should only insert
3768    ///   at UTF-8 sequence boundaries.
3769    /// - `string`: the UTF-8 text to insert.
3770    /// - `length`: the length of the text, in bytes, or 0 for null terminated
3771    ///   text.
3772    ///
3773    /// ## Return value
3774    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3775    ///   information.
3776    ///
3777    /// ## Thread safety
3778    /// This function should be called on the thread that created the
3779    ///   text.
3780    ///
3781    /// ## Availability
3782    /// This function is available since SDL_ttf 3.0.0.
3783    ///
3784    /// ## See also
3785    /// - [`TTF_AppendTextString`]
3786    /// - [`TTF_DeleteTextString`]
3787    /// - [`TTF_SetTextString`]
3788    pub fn TTF_InsertTextString(
3789        text: *mut TTF_Text,
3790        offset: ::core::ffi::c_int,
3791        string: *const ::core::ffi::c_char,
3792        length: ::core::primitive::usize,
3793    ) -> ::core::primitive::bool;
3794}
3795
3796unsafe extern "C" {
3797    /// Append UTF-8 text to a text object.
3798    ///
3799    /// This function may cause the internal text representation to be rebuilt.
3800    ///
3801    /// ## Parameters
3802    /// - `text`: the [`TTF_Text`] to modify.
3803    /// - `string`: the UTF-8 text to insert.
3804    /// - `length`: the length of the text, in bytes, or 0 for null terminated
3805    ///   text.
3806    ///
3807    /// ## Return value
3808    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3809    ///   information.
3810    ///
3811    /// ## Thread safety
3812    /// This function should be called on the thread that created the
3813    ///   text.
3814    ///
3815    /// ## Availability
3816    /// This function is available since SDL_ttf 3.0.0.
3817    ///
3818    /// ## See also
3819    /// - [`TTF_DeleteTextString`]
3820    /// - [`TTF_InsertTextString`]
3821    /// - [`TTF_SetTextString`]
3822    pub fn TTF_AppendTextString(
3823        text: *mut TTF_Text,
3824        string: *const ::core::ffi::c_char,
3825        length: ::core::primitive::usize,
3826    ) -> ::core::primitive::bool;
3827}
3828
3829unsafe extern "C" {
3830    /// Delete UTF-8 text from a text object.
3831    ///
3832    /// This function may cause the internal text representation to be rebuilt.
3833    ///
3834    /// ## Parameters
3835    /// - `text`: the [`TTF_Text`] to modify.
3836    /// - `offset`: the offset, in bytes, from the beginning of the string if >=
3837    ///   0, the offset from the end of the string if < 0. Note that
3838    ///   this does not do UTF-8 validation, so you should only delete
3839    ///   at UTF-8 sequence boundaries.
3840    /// - `length`: the length of text to delete, in bytes, or -1 for the
3841    ///   remainder of the string.
3842    ///
3843    /// ## Return value
3844    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3845    ///   information.
3846    ///
3847    /// ## Thread safety
3848    /// This function should be called on the thread that created the
3849    ///   text.
3850    ///
3851    /// ## Availability
3852    /// This function is available since SDL_ttf 3.0.0.
3853    ///
3854    /// ## See also
3855    /// - [`TTF_AppendTextString`]
3856    /// - [`TTF_InsertTextString`]
3857    /// - [`TTF_SetTextString`]
3858    pub fn TTF_DeleteTextString(
3859        text: *mut TTF_Text,
3860        offset: ::core::ffi::c_int,
3861        length: ::core::ffi::c_int,
3862    ) -> ::core::primitive::bool;
3863}
3864
3865unsafe extern "C" {
3866    /// Get the size of a text object.
3867    ///
3868    /// The size of the text may change when the font or font style and size
3869    /// change.
3870    ///
3871    /// ## Parameters
3872    /// - `text`: the [`TTF_Text`] to query.
3873    /// - `w`: a pointer filled in with the width of the text, in pixels, may be
3874    ///   NULL.
3875    /// - `h`: a pointer filled in with the height of the text, in pixels, may be
3876    ///   NULL.
3877    ///
3878    /// ## Return value
3879    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
3880    ///   information.
3881    ///
3882    /// ## Thread safety
3883    /// This function should be called on the thread that created the
3884    ///   text.
3885    ///
3886    /// ## Availability
3887    /// This function is available since SDL_ttf 3.0.0.
3888    pub fn TTF_GetTextSize(
3889        text: *mut TTF_Text,
3890        w: *mut ::core::ffi::c_int,
3891        h: *mut ::core::ffi::c_int,
3892    ) -> ::core::primitive::bool;
3893}
3894
3895/// Flags for [`TTF_SubString`]
3896///
3897/// ## Availability
3898/// This datatype is available since SDL_ttf 3.0.0.
3899///
3900/// ## See also
3901/// - [`TTF_SubString`]
3902///
3903/// ## Known values (`sdl3-sys`)
3904/// | Associated constant | Global constant | Description |
3905/// | ------------------- | --------------- | ----------- |
3906/// | [`DIRECTION_MASK`](TTF_SubStringFlags::DIRECTION_MASK) | [`TTF_SUBSTRING_DIRECTION_MASK`] | The mask for the flow direction for this substring |
3907/// | [`TEXT_START`](TTF_SubStringFlags::TEXT_START) | [`TTF_SUBSTRING_TEXT_START`] | This substring contains the beginning of the text |
3908/// | [`LINE_START`](TTF_SubStringFlags::LINE_START) | [`TTF_SUBSTRING_LINE_START`] | This substring contains the beginning of line `line_index` |
3909/// | [`LINE_END`](TTF_SubStringFlags::LINE_END) | [`TTF_SUBSTRING_LINE_END`] | This substring contains the end of line `line_index` |
3910/// | [`TEXT_END`](TTF_SubStringFlags::TEXT_END) | [`TTF_SUBSTRING_TEXT_END`] | This substring contains the end of the text |
3911#[repr(transparent)]
3912#[derive(Clone, Copy, Default, PartialEq, Eq, Hash)]
3913pub struct TTF_SubStringFlags(pub Uint32);
3914
3915impl ::core::cmp::PartialEq<Uint32> for TTF_SubStringFlags {
3916    #[inline(always)]
3917    fn eq(&self, other: &Uint32) -> bool {
3918        &self.0 == other
3919    }
3920}
3921
3922impl ::core::cmp::PartialEq<TTF_SubStringFlags> for Uint32 {
3923    #[inline(always)]
3924    fn eq(&self, other: &TTF_SubStringFlags) -> bool {
3925        self == &other.0
3926    }
3927}
3928
3929impl From<TTF_SubStringFlags> for Uint32 {
3930    #[inline(always)]
3931    fn from(value: TTF_SubStringFlags) -> Self {
3932        value.0
3933    }
3934}
3935
3936#[cfg(feature = "debug-impls")]
3937impl ::core::fmt::Debug for TTF_SubStringFlags {
3938    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
3939        let mut first = true;
3940        let all_bits = 0;
3941        write!(f, "TTF_SubStringFlags(")?;
3942        let all_bits = all_bits | Self::DIRECTION_MASK.0;
3943        if (Self::DIRECTION_MASK != 0 || self.0 == 0)
3944            && *self & Self::DIRECTION_MASK == Self::DIRECTION_MASK
3945        {
3946            if !first {
3947                write!(f, " | ")?;
3948            }
3949            first = false;
3950            write!(f, "DIRECTION_MASK")?;
3951        }
3952        let all_bits = all_bits | Self::TEXT_START.0;
3953        if (Self::TEXT_START != 0 || self.0 == 0) && *self & Self::TEXT_START == Self::TEXT_START {
3954            if !first {
3955                write!(f, " | ")?;
3956            }
3957            first = false;
3958            write!(f, "TEXT_START")?;
3959        }
3960        let all_bits = all_bits | Self::LINE_START.0;
3961        if (Self::LINE_START != 0 || self.0 == 0) && *self & Self::LINE_START == Self::LINE_START {
3962            if !first {
3963                write!(f, " | ")?;
3964            }
3965            first = false;
3966            write!(f, "LINE_START")?;
3967        }
3968        let all_bits = all_bits | Self::LINE_END.0;
3969        if (Self::LINE_END != 0 || self.0 == 0) && *self & Self::LINE_END == Self::LINE_END {
3970            if !first {
3971                write!(f, " | ")?;
3972            }
3973            first = false;
3974            write!(f, "LINE_END")?;
3975        }
3976        let all_bits = all_bits | Self::TEXT_END.0;
3977        if (Self::TEXT_END != 0 || self.0 == 0) && *self & Self::TEXT_END == Self::TEXT_END {
3978            if !first {
3979                write!(f, " | ")?;
3980            }
3981            first = false;
3982            write!(f, "TEXT_END")?;
3983        }
3984
3985        if self.0 & !all_bits != 0 {
3986            if !first {
3987                write!(f, " | ")?;
3988            }
3989            write!(f, "{:#x}", self.0)?;
3990        } else if first {
3991            write!(f, "0")?;
3992        }
3993        write!(f, ")")
3994    }
3995}
3996
3997impl ::core::ops::BitAnd for TTF_SubStringFlags {
3998    type Output = Self;
3999
4000    #[inline(always)]
4001    fn bitand(self, rhs: Self) -> Self::Output {
4002        Self(self.0 & rhs.0)
4003    }
4004}
4005
4006impl ::core::ops::BitAndAssign for TTF_SubStringFlags {
4007    #[inline(always)]
4008    fn bitand_assign(&mut self, rhs: Self) {
4009        self.0 &= rhs.0;
4010    }
4011}
4012
4013impl ::core::ops::BitOr for TTF_SubStringFlags {
4014    type Output = Self;
4015
4016    #[inline(always)]
4017    fn bitor(self, rhs: Self) -> Self::Output {
4018        Self(self.0 | rhs.0)
4019    }
4020}
4021
4022impl ::core::ops::BitOrAssign for TTF_SubStringFlags {
4023    #[inline(always)]
4024    fn bitor_assign(&mut self, rhs: Self) {
4025        self.0 |= rhs.0;
4026    }
4027}
4028
4029impl ::core::ops::BitXor for TTF_SubStringFlags {
4030    type Output = Self;
4031
4032    #[inline(always)]
4033    fn bitxor(self, rhs: Self) -> Self::Output {
4034        Self(self.0 ^ rhs.0)
4035    }
4036}
4037
4038impl ::core::ops::BitXorAssign for TTF_SubStringFlags {
4039    #[inline(always)]
4040    fn bitxor_assign(&mut self, rhs: Self) {
4041        self.0 ^= rhs.0;
4042    }
4043}
4044
4045impl ::core::ops::Not for TTF_SubStringFlags {
4046    type Output = Self;
4047
4048    #[inline(always)]
4049    fn not(self) -> Self::Output {
4050        Self(!self.0)
4051    }
4052}
4053
4054impl TTF_SubStringFlags {
4055    /// The mask for the flow direction for this substring
4056    pub const DIRECTION_MASK: Self = Self((0x000000ff as Uint32));
4057    /// This substring contains the beginning of the text
4058    pub const TEXT_START: Self = Self((0x00000100 as Uint32));
4059    /// This substring contains the beginning of line `line_index`
4060    pub const LINE_START: Self = Self((0x00000200 as Uint32));
4061    /// This substring contains the end of line `line_index`
4062    pub const LINE_END: Self = Self((0x00000400 as Uint32));
4063    /// This substring contains the end of the text
4064    pub const TEXT_END: Self = Self((0x00000800 as Uint32));
4065}
4066
4067/// The mask for the flow direction for this substring
4068pub const TTF_SUBSTRING_DIRECTION_MASK: TTF_SubStringFlags = TTF_SubStringFlags::DIRECTION_MASK;
4069/// This substring contains the beginning of the text
4070pub const TTF_SUBSTRING_TEXT_START: TTF_SubStringFlags = TTF_SubStringFlags::TEXT_START;
4071/// This substring contains the beginning of line `line_index`
4072pub const TTF_SUBSTRING_LINE_START: TTF_SubStringFlags = TTF_SubStringFlags::LINE_START;
4073/// This substring contains the end of line `line_index`
4074pub const TTF_SUBSTRING_LINE_END: TTF_SubStringFlags = TTF_SubStringFlags::LINE_END;
4075/// This substring contains the end of the text
4076pub const TTF_SUBSTRING_TEXT_END: TTF_SubStringFlags = TTF_SubStringFlags::TEXT_END;
4077
4078#[cfg(feature = "metadata")]
4079impl sdl3_sys::metadata::GroupMetadata for TTF_SubStringFlags {
4080    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
4081        &crate::metadata::ttf::METADATA_TTF_SubStringFlags;
4082}
4083
4084/// The representation of a substring within text.
4085///
4086/// ## Availability
4087/// This struct is available since SDL_ttf 3.0.0.
4088///
4089/// ## See also
4090/// - [`TTF_GetNextTextSubString`]
4091/// - [`TTF_GetPreviousTextSubString`]
4092/// - [`TTF_GetTextSubString`]
4093/// - [`TTF_GetTextSubStringForLine`]
4094/// - [`TTF_GetTextSubStringForPoint`]
4095/// - [`TTF_GetTextSubStringsForRange`]
4096#[repr(C)]
4097#[derive(Clone, Copy, Default, PartialEq, Eq, Hash)]
4098#[cfg_attr(feature = "debug-impls", derive(Debug))]
4099pub struct TTF_SubString {
4100    /// The flags for this substring
4101    pub flags: TTF_SubStringFlags,
4102    /// The byte offset from the beginning of the text
4103    pub offset: ::core::ffi::c_int,
4104    /// The byte length starting at the offset
4105    pub length: ::core::ffi::c_int,
4106    /// The index of the line that contains this substring
4107    pub line_index: ::core::ffi::c_int,
4108    /// The internal cluster index, used for quickly iterating
4109    pub cluster_index: ::core::ffi::c_int,
4110    /// The rectangle, relative to the top left of the text, containing the substring
4111    pub rect: SDL_Rect,
4112}
4113
4114unsafe extern "C" {
4115    /// Get the substring of a text object that surrounds a text offset.
4116    ///
4117    /// If `offset` is less than 0, this will return a zero length substring at the
4118    /// beginning of the text with the [`TTF_SUBSTRING_TEXT_START`] flag set. If
4119    /// `offset` is greater than or equal to the length of the text string, this
4120    /// will return a zero length substring at the end of the text with the
4121    /// [`TTF_SUBSTRING_TEXT_END`] flag set.
4122    ///
4123    /// ## Parameters
4124    /// - `text`: the [`TTF_Text`] to query.
4125    /// - `offset`: a byte offset into the text string.
4126    /// - `substring`: a pointer filled in with the substring containing the
4127    ///   offset.
4128    ///
4129    /// ## Return value
4130    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
4131    ///   information.
4132    ///
4133    /// ## Thread safety
4134    /// This function should be called on the thread that created the
4135    ///   text.
4136    ///
4137    /// ## Availability
4138    /// This function is available since SDL_ttf 3.0.0.
4139    pub fn TTF_GetTextSubString(
4140        text: *mut TTF_Text,
4141        offset: ::core::ffi::c_int,
4142        substring: *mut TTF_SubString,
4143    ) -> ::core::primitive::bool;
4144}
4145
4146unsafe extern "C" {
4147    /// Get the substring of a text object that contains the given line.
4148    ///
4149    /// If `line` is less than 0, this will return a zero length substring at the
4150    /// beginning of the text with the [`TTF_SUBSTRING_TEXT_START`] flag set. If `line`
4151    /// is greater than or equal to `text->num_lines` this will return a zero
4152    /// length substring at the end of the text with the [`TTF_SUBSTRING_TEXT_END`]
4153    /// flag set.
4154    ///
4155    /// ## Parameters
4156    /// - `text`: the [`TTF_Text`] to query.
4157    /// - `line`: a zero-based line index, in the range \[0 .. text->num_lines-1\].
4158    /// - `substring`: a pointer filled in with the substring containing the
4159    ///   offset.
4160    ///
4161    /// ## Return value
4162    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
4163    ///   information.
4164    ///
4165    /// ## Thread safety
4166    /// This function should be called on the thread that created the
4167    ///   text.
4168    ///
4169    /// ## Availability
4170    /// This function is available since SDL_ttf 3.0.0.
4171    pub fn TTF_GetTextSubStringForLine(
4172        text: *mut TTF_Text,
4173        line: ::core::ffi::c_int,
4174        substring: *mut TTF_SubString,
4175    ) -> ::core::primitive::bool;
4176}
4177
4178unsafe extern "C" {
4179    /// Get the substrings of a text object that contain a range of text.
4180    ///
4181    /// ## Parameters
4182    /// - `text`: the [`TTF_Text`] to query.
4183    /// - `offset`: a byte offset into the text string.
4184    /// - `length`: the length of the range being queried, in bytes, or -1 for
4185    ///   the remainder of the string.
4186    /// - `count`: a pointer filled in with the number of substrings returned,
4187    ///   may be NULL.
4188    ///
4189    /// ## Return value
4190    /// Returns a NULL terminated array of substring pointers or NULL on failure;
4191    ///   call [`SDL_GetError()`] for more information. This is a single
4192    ///   allocation that should be freed with [`SDL_free()`] when it is no
4193    ///   longer needed.
4194    ///
4195    /// ## Thread safety
4196    /// This function should be called on the thread that created the
4197    ///   text.
4198    ///
4199    /// ## Availability
4200    /// This function is available since SDL_ttf 3.0.0.
4201    pub fn TTF_GetTextSubStringsForRange(
4202        text: *mut TTF_Text,
4203        offset: ::core::ffi::c_int,
4204        length: ::core::ffi::c_int,
4205        count: *mut ::core::ffi::c_int,
4206    ) -> *mut *mut TTF_SubString;
4207}
4208
4209unsafe extern "C" {
4210    /// Get the portion of a text string that is closest to a point.
4211    ///
4212    /// This will return the closest substring of text to the given point.
4213    ///
4214    /// ## Parameters
4215    /// - `text`: the [`TTF_Text`] to query.
4216    /// - `x`: the x coordinate relative to the left side of the text, may be
4217    ///   outside the bounds of the text area.
4218    /// - `y`: the y coordinate relative to the top side of the text, may be
4219    ///   outside the bounds of the text area.
4220    /// - `substring`: a pointer filled in with the closest substring of text to
4221    ///   the given point.
4222    ///
4223    /// ## Return value
4224    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
4225    ///   information.
4226    ///
4227    /// ## Thread safety
4228    /// This function should be called on the thread that created the
4229    ///   text.
4230    ///
4231    /// ## Availability
4232    /// This function is available since SDL_ttf 3.0.0.
4233    pub fn TTF_GetTextSubStringForPoint(
4234        text: *mut TTF_Text,
4235        x: ::core::ffi::c_int,
4236        y: ::core::ffi::c_int,
4237        substring: *mut TTF_SubString,
4238    ) -> ::core::primitive::bool;
4239}
4240
4241unsafe extern "C" {
4242    /// Get the previous substring in a text object
4243    ///
4244    /// If called at the start of the text, this will return a zero length
4245    /// substring with the [`TTF_SUBSTRING_TEXT_START`] flag set.
4246    ///
4247    /// ## Parameters
4248    /// - `text`: the [`TTF_Text`] to query.
4249    /// - `substring`: the [`TTF_SubString`] to query.
4250    ///
4251    /// ## Return value
4252    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
4253    ///   information.
4254    ///
4255    /// ## Thread safety
4256    /// This function should be called on the thread that created the
4257    ///   text.
4258    ///
4259    /// ## Availability
4260    /// This function is available since SDL_ttf 3.0.0.
4261    pub fn TTF_GetPreviousTextSubString(
4262        text: *mut TTF_Text,
4263        substring: *const TTF_SubString,
4264        previous: *mut TTF_SubString,
4265    ) -> ::core::primitive::bool;
4266}
4267
4268unsafe extern "C" {
4269    /// Get the next substring in a text object
4270    ///
4271    /// If called at the end of the text, this will return a zero length substring
4272    /// with the [`TTF_SUBSTRING_TEXT_END`] flag set.
4273    ///
4274    /// ## Parameters
4275    /// - `text`: the [`TTF_Text`] to query.
4276    /// - `substring`: the [`TTF_SubString`] to query.
4277    /// - `next`: a pointer filled in with the next substring.
4278    ///
4279    /// ## Return value
4280    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
4281    ///   information.
4282    ///
4283    /// ## Thread safety
4284    /// This function should be called on the thread that created the
4285    ///   text.
4286    ///
4287    /// ## Availability
4288    /// This function is available since SDL_ttf 3.0.0.
4289    pub fn TTF_GetNextTextSubString(
4290        text: *mut TTF_Text,
4291        substring: *const TTF_SubString,
4292        next: *mut TTF_SubString,
4293    ) -> ::core::primitive::bool;
4294}
4295
4296unsafe extern "C" {
4297    /// Update the layout of a text object.
4298    ///
4299    /// This is automatically done when the layout is requested or the text is
4300    /// rendered, but you can call this if you need more control over the timing of
4301    /// when the layout and text engine representation are updated.
4302    ///
4303    /// ## Parameters
4304    /// - `text`: the [`TTF_Text`] to update.
4305    ///
4306    /// ## Return value
4307    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
4308    ///   information.
4309    ///
4310    /// ## Thread safety
4311    /// This function should be called on the thread that created the
4312    ///   text.
4313    ///
4314    /// ## Availability
4315    /// This function is available since SDL_ttf 3.0.0.
4316    pub fn TTF_UpdateText(text: *mut TTF_Text) -> ::core::primitive::bool;
4317}
4318
4319unsafe extern "C" {
4320    /// Destroy a text object created by a text engine.
4321    ///
4322    /// ## Parameters
4323    /// - `text`: the text to destroy.
4324    ///
4325    /// ## Thread safety
4326    /// This function should be called on the thread that created the
4327    ///   text.
4328    ///
4329    /// ## Availability
4330    /// This function is available since SDL_ttf 3.0.0.
4331    ///
4332    /// ## See also
4333    /// - [`TTF_CreateText`]
4334    pub fn TTF_DestroyText(text: *mut TTF_Text);
4335}
4336
4337unsafe extern "C" {
4338    /// Dispose of a previously-created font.
4339    ///
4340    /// Call this when done with a font. This function will free any resources
4341    /// associated with it. It is safe to call this function on NULL, for example
4342    /// on the result of a failed call to [`TTF_OpenFont()`].
4343    ///
4344    /// The font is not valid after being passed to this function. String pointers
4345    /// from functions that return information on this font, such as
4346    /// [`TTF_GetFontFamilyName()`] and [`TTF_GetFontStyleName()`], are no longer valid
4347    /// after this call, as well.
4348    ///
4349    /// ## Parameters
4350    /// - `font`: the font to dispose of.
4351    ///
4352    /// ## Thread safety
4353    /// This function should not be called while any other thread is
4354    ///   using the font.
4355    ///
4356    /// ## Availability
4357    /// This function is available since SDL_ttf 3.0.0.
4358    ///
4359    /// ## See also
4360    /// - [`TTF_OpenFont`]
4361    /// - [`TTF_OpenFontIO`]
4362    pub fn TTF_CloseFont(font: *mut TTF_Font);
4363}
4364
4365unsafe extern "C" {
4366    /// Deinitialize SDL_ttf.
4367    ///
4368    /// You must call this when done with the library, to free internal resources.
4369    /// It is safe to call this when the library isn't initialized, as it will just
4370    /// return immediately.
4371    ///
4372    /// Once you have as many quit calls as you have had successful calls to
4373    /// [`TTF_Init`], the library will actually deinitialize.
4374    ///
4375    /// Please note that this does not automatically close any fonts that are still
4376    /// open at the time of deinitialization, and it is possibly not safe to close
4377    /// them afterwards, as parts of the library will no longer be initialized to
4378    /// deal with it. A well-written program should call [`TTF_CloseFont()`] on any
4379    /// open fonts before calling this function!
4380    ///
4381    /// ## Thread safety
4382    /// It is safe to call this function from any thread.
4383    ///
4384    /// ## Availability
4385    /// This function is available since SDL_ttf 3.0.0.
4386    pub fn TTF_Quit();
4387}
4388
4389unsafe extern "C" {
4390    /// Check if SDL_ttf is initialized.
4391    ///
4392    /// This reports the number of times the library has been initialized by a call
4393    /// to [`TTF_Init()`], without a paired deinitialization request from [`TTF_Quit()`].
4394    ///
4395    /// In short: if it's greater than zero, the library is currently initialized
4396    /// and ready to work. If zero, it is not initialized.
4397    ///
4398    /// Despite the return value being a signed integer, this function should not
4399    /// return a negative number.
4400    ///
4401    /// ## Return value
4402    /// Returns the current number of initialization calls, that need to
4403    ///   eventually be paired with this many calls to [`TTF_Quit()`].
4404    ///
4405    /// ## Thread safety
4406    /// It is safe to call this function from any thread.
4407    ///
4408    /// ## Availability
4409    /// This function is available since SDL_ttf 3.0.0.
4410    ///
4411    /// ## See also
4412    /// - [`TTF_Init`]
4413    /// - [`TTF_Quit`]
4414    pub fn TTF_WasInit() -> ::core::ffi::c_int;
4415}
4416
4417/// The internal structure containing font information.
4418///
4419/// Opaque data!
4420#[repr(C)]
4421pub struct TTF_Font {
4422    _opaque: [::core::primitive::u8; 0],
4423}
4424
4425#[cfg(doc)]
4426use crate::everything::*;