sdl3_ttf_sys/generated/
textengine.rs

1use sdl3_sys::everything::*;
2
3use super::ttf::*;
4
5/// A font atlas draw command.
6///
7/// ## Availability
8/// This enum is available since SDL_ttf 3.0.0.
9///
10/// ## Known values (`sdl3-sys`)
11/// | Associated constant | Global constant | Description |
12/// | ------------------- | --------------- | ----------- |
13/// | [`NOOP`](TTF_DrawCommand::NOOP) | [`TTF_DRAW_COMMAND_NOOP`] | |
14/// | [`FILL`](TTF_DrawCommand::FILL) | [`TTF_DRAW_COMMAND_FILL`] | |
15/// | [`COPY`](TTF_DrawCommand::COPY) | [`TTF_DRAW_COMMAND_COPY`] | |
16#[repr(transparent)]
17#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
18pub struct TTF_DrawCommand(pub ::core::ffi::c_int);
19
20impl ::core::cmp::PartialEq<::core::ffi::c_int> for TTF_DrawCommand {
21    #[inline(always)]
22    fn eq(&self, other: &::core::ffi::c_int) -> bool {
23        &self.0 == other
24    }
25}
26
27impl ::core::cmp::PartialEq<TTF_DrawCommand> for ::core::ffi::c_int {
28    #[inline(always)]
29    fn eq(&self, other: &TTF_DrawCommand) -> bool {
30        self == &other.0
31    }
32}
33
34impl From<TTF_DrawCommand> for ::core::ffi::c_int {
35    #[inline(always)]
36    fn from(value: TTF_DrawCommand) -> Self {
37        value.0
38    }
39}
40
41#[cfg(feature = "debug-impls")]
42impl ::core::fmt::Debug for TTF_DrawCommand {
43    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
44        #[allow(unreachable_patterns)]
45        f.write_str(match *self {
46            Self::NOOP => "TTF_DRAW_COMMAND_NOOP",
47            Self::FILL => "TTF_DRAW_COMMAND_FILL",
48            Self::COPY => "TTF_DRAW_COMMAND_COPY",
49
50            _ => return write!(f, "TTF_DrawCommand({})", self.0),
51        })
52    }
53}
54
55impl TTF_DrawCommand {
56    pub const NOOP: Self = Self((0 as ::core::ffi::c_int));
57    pub const FILL: Self = Self((1 as ::core::ffi::c_int));
58    pub const COPY: Self = Self((2 as ::core::ffi::c_int));
59}
60
61pub const TTF_DRAW_COMMAND_NOOP: TTF_DrawCommand = TTF_DrawCommand::NOOP;
62pub const TTF_DRAW_COMMAND_FILL: TTF_DrawCommand = TTF_DrawCommand::FILL;
63pub const TTF_DRAW_COMMAND_COPY: TTF_DrawCommand = TTF_DrawCommand::COPY;
64
65#[cfg(feature = "metadata")]
66impl sdl3_sys::metadata::GroupMetadata for TTF_DrawCommand {
67    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
68        &crate::metadata::textengine::METADATA_TTF_DrawCommand;
69}
70
71/// A filled rectangle draw operation.
72///
73/// ## Availability
74/// This struct is available since SDL_ttf 3.0.0.
75///
76/// ## See also
77/// - [`TTF_DrawOperation`]
78#[repr(C)]
79#[derive(Clone, Copy, Default, PartialEq, Eq, Hash)]
80#[cfg_attr(feature = "debug-impls", derive(Debug))]
81pub struct TTF_FillOperation {
82    /// [`TTF_DRAW_COMMAND_FILL`]
83    pub cmd: TTF_DrawCommand,
84    /// The rectangle to fill, in pixels. The x coordinate is relative to the left side of the text area, going right, and the y coordinate is relative to the top side of the text area, going down.
85    pub rect: SDL_Rect,
86}
87
88/// A texture copy draw operation.
89///
90/// ## Availability
91/// This struct is available since SDL_ttf 3.0.0.
92///
93/// ## See also
94/// - [`TTF_DrawOperation`]
95#[repr(C)]
96#[derive(Clone, Copy)]
97#[cfg_attr(feature = "debug-impls", derive(Debug))]
98pub struct TTF_CopyOperation {
99    /// [`TTF_DRAW_COMMAND_COPY`]
100    pub cmd: TTF_DrawCommand,
101    /// The offset in the text corresponding to this glyph.
102    /// There may be multiple glyphs with the same text offset
103    /// and the next text offset might be several Unicode codepoints
104    /// later. In this case the glyphs and codepoints are grouped
105    /// together and the group bounding box is the union of the dst
106    /// rectangles for the corresponding glyphs.
107    pub text_offset: ::core::ffi::c_int,
108    /// The font containing the glyph to be drawn, can be passed to [`TTF_GetGlyphImageForIndex()`]
109    pub glyph_font: *mut TTF_Font,
110    /// The glyph index of the glyph to be drawn, can be passed to [`TTF_GetGlyphImageForIndex()`]
111    pub glyph_index: Uint32,
112    /// The area within the glyph to be drawn
113    pub src: SDL_Rect,
114    /// The drawing coordinates of the glyph, in pixels. The x coordinate is relative to the left side of the text area, going right, and the y coordinate is relative to the top side of the text area, going down.
115    pub dst: SDL_Rect,
116    pub reserved: *mut ::core::ffi::c_void,
117}
118
119impl ::core::default::Default for TTF_CopyOperation {
120    /// Initialize all fields to zero
121    #[inline(always)]
122    fn default() -> Self {
123        unsafe { ::core::mem::MaybeUninit::<Self>::zeroed().assume_init() }
124    }
125}
126
127/// A text engine draw operation.
128///
129/// ## Availability
130/// This struct is available since SDL_ttf 3.0.0.
131#[repr(C)]
132#[derive(Clone, Copy)]
133pub union TTF_DrawOperation {
134    pub cmd: TTF_DrawCommand,
135    pub fill: TTF_FillOperation,
136    pub copy: TTF_CopyOperation,
137}
138
139impl ::core::default::Default for TTF_DrawOperation {
140    /// Initialize all fields to zero
141    #[inline(always)]
142    fn default() -> Self {
143        unsafe { ::core::mem::MaybeUninit::<Self>::zeroed().assume_init() }
144    }
145}
146
147#[repr(C)]
148#[cfg_attr(feature = "debug-impls", derive(Debug))]
149pub struct TTF_TextData {
150    /// The font used by this text, read-only.
151    pub font: *mut TTF_Font,
152    /// The color of the text, read-only.
153    pub color: SDL_FColor,
154    /// True if the layout needs to be updated
155    pub needs_layout_update: ::core::primitive::bool,
156    /// Cached layout information, read-only.
157    pub layout: *mut TTF_TextLayout,
158    /// The x offset of the upper left corner of this text, in pixels, read-only.
159    pub x: ::core::ffi::c_int,
160    /// The y offset of the upper left corner of this text, in pixels, read-only.
161    pub y: ::core::ffi::c_int,
162    /// The width of this text, in pixels, read-only.
163    pub w: ::core::ffi::c_int,
164    /// The height of this text, in pixels, read-only.
165    pub h: ::core::ffi::c_int,
166    /// The number of drawing operations to render this text, read-only.
167    pub num_ops: ::core::ffi::c_int,
168    /// The drawing operations used to render this text, read-only.
169    pub ops: *mut TTF_DrawOperation,
170    /// The number of substrings representing clusters of glyphs in the string, read-only
171    pub num_clusters: ::core::ffi::c_int,
172    /// Substrings representing clusters of glyphs in the string, read-only
173    pub clusters: *mut TTF_SubString,
174    /// Custom properties associated with this text, read-only. This field is created as-needed using [`TTF_GetTextProperties()`] and the properties may be then set and read normally
175    pub props: SDL_PropertiesID,
176    /// True if the engine text needs to be updated
177    pub needs_engine_update: ::core::primitive::bool,
178    /// The engine used to render this text, read-only.
179    pub engine: *mut TTF_TextEngine,
180    /// The implementation-specific representation of this text
181    pub engine_text: *mut ::core::ffi::c_void,
182}
183
184impl ::core::default::Default for TTF_TextData {
185    /// Initialize all fields to zero
186    #[inline(always)]
187    fn default() -> Self {
188        unsafe { ::core::mem::MaybeUninit::<Self>::zeroed().assume_init() }
189    }
190}
191
192/// A text engine interface.
193///
194/// This structure should be initialized using [`SDL_INIT_INTERFACE()`]
195///
196/// ## Availability
197/// This struct is available since SDL_ttf 3.0.0.
198///
199/// ## See also
200/// - [`SDL_INIT_INTERFACE`]
201///
202/// ## Notes for `sdl3-sys`
203/// This interface struct can be initialized with [`TTF_TextEngine::new()`] or `Default::default()`.
204#[repr(C)]
205#[cfg_attr(feature = "debug-impls", derive(Debug))]
206pub struct TTF_TextEngine {
207    /// The version of this interface
208    pub version: Uint32,
209    /// User data pointer passed to callbacks
210    pub userdata: *mut ::core::ffi::c_void,
211    pub CreateText: ::core::option::Option<
212        unsafe extern "C" fn(
213            userdata: *mut ::core::ffi::c_void,
214            text: *mut TTF_Text,
215        ) -> ::core::primitive::bool,
216    >,
217    /// * Destroy a text representation.
218    pub DestroyText: ::core::option::Option<
219        unsafe extern "C" fn(userdata: *mut ::core::ffi::c_void, text: *mut TTF_Text),
220    >,
221}
222
223impl TTF_TextEngine {
224    /// Create a new `TTF_TextEngine` initialized with `SDL_INIT_INTERFACE`
225    #[inline]
226    pub const fn new() -> Self {
227        const { ::core::assert!(::core::mem::size_of::<Self>() <= ::core::primitive::u32::MAX as usize) };
228        let mut this = unsafe { ::core::mem::MaybeUninit::<Self>::zeroed().assume_init() };
229        this.version = ::core::mem::size_of::<Self>() as ::core::primitive::u32;
230        this
231    }
232}
233
234impl ::core::default::Default for TTF_TextEngine {
235    /// Create a new `TTF_TextEngine` initialized with `SDL_INIT_INTERFACE`
236    #[inline(always)]
237    fn default() -> Self {
238        Self::new()
239    }
240}
241
242const _: () = ::core::assert!(
243    (((::core::mem::size_of::<*mut ::core::ffi::c_void>() == 4_usize)
244        && (::core::mem::size_of::<TTF_TextEngine>() == 16_usize))
245        || ((::core::mem::size_of::<*mut ::core::ffi::c_void>() == 8_usize)
246            && (::core::mem::size_of::<TTF_TextEngine>() == 32_usize)))
247);
248
249#[repr(C)]
250pub struct TTF_TextLayout {
251    _opaque: [::core::primitive::u8; 0],
252}
253
254#[cfg(doc)]
255use crate::everything::*;