blib/lib/SDL3/TTF.pm untested

filter: Statementstmt 0.0% 0 / 654 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 20 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 0.0% 0 / 21 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 733 CC 9 SCAR 19.2
CC
9
Cov
0%
_ttf
20.0
_affix_and_export
12.0
_enum_and_export
12.0
CRAP 6.8
1 package SDL3::TTF v0.0.7 {
2 use v5.40;
3 use base 'Exporter';
4 use Affix qw[:all];
5 use Alien::SDL3;
6 use SDL3 qw[:all];
7 use Carp qw[croak confess];
8 use Config qw[%Config];
9  
10 =encoding utf-8
11  
12 =head1 NAME
13  
14 SDL3::TTF - TrueType Font support for SDL3
15  
16 =head1 SYNOPSIS
17  
18 use v5.40;
19 use SDL3 qw[:all :main];
20 use SDL3::TTF qw[:all];
21  
22 TTF_Init() or die SDL_GetError();
23  
24 my $font = TTF_OpenFont( 'C:/Windows/Fonts/arial.ttf', 48.0 )
25 or die SDL_GetError();
26  
27 my $surface =
28 TTF_RenderText_Blended( $font, 'Hello, World!', 0, { r => 255, g => 255, b => 255, a => 255 } );
29 my $texture = SDL_CreateTextureFromSurface( $renderer, $surface );
30  
31 TTF_CloseFont($font);
32 TTF_Quit();
33  
34 =head1 DESCRIPTION
35  
36 C<SDL3::TTF> binds SDL_ttf, a companion library to SDL for working with TrueType (tm) fonts.
37  
38 The library is a wrapper around the FreeType and HarfBuzz libraries, allowing you to use TrueType fonts to render text
39 in SDL applications. Text can be rendered to a surface or directly to a texture, with control over the font size,
40 style, hinting, and color. Complex scripts are shaped with HarfBuzz, fallback fonts extend the glyphs a font can draw,
41 and outlines can be stroked with an arbitrary width.
42  
43 Open a font with C<TTF_OpenFont( ... )> or C<TTF_OpenFontWithProperties( ... )>, then render with the
44 C<TTF_RenderText_*( ... )> and C<TTF_RenderGlyph_*( ... )> families. For styled, wrapped, and measured text, build a
45 reusable C<TTF_Text> object against a C<TTF_TextEngine> and draw it into the renderer. Free fonts with C<TTF_CloseFont(
46 ... )> and call C<TTF_Quit( )> when you are done.
47  
48 There are a few examples in this distribution's C<eg/ttf> directory.
49  
50 =head2 Features
51  
52 Each feature listed below is a tag you may use.
53  
54 =head3 C<:all> - SDL3_ttf Functions
55  
56 This binds all functions, defines all types, and imports them into your package.
57  
58 See L<the SDL3_ttf Wiki|https://wiki.libsdl.org/SDL3_ttf/FrontPage> for documentation of the functions and types you
59 will have access to with this import tag.
60  
61 =cut
62  
63 my $alien = Alien::SDL3->new;
64 my $info = $alien->alt('libsdl3_ttf')->package_info;
65 croak 'SDL3_ttf is not installed' unless $info;
66 my ($lib) = @{ $info->libfiles };
67 $ENV{PATH} = join( $Config{path_sep}, ( map { @{ $_->bindirs // [] } } $info ), $ENV{PATH} // '' );
68 our ( %EXPORT_TAGS, @EXPORT_OK );
69  
70 sub import ( $pkg, @wants ) {
71 {
72 no strict 'refs';
73 (s[^:][_]r)->() for @wants;
74 }
75 require List::Util;
76 @EXPORT_OK = sort map {@$_} values %EXPORT_TAGS;
77 $EXPORT_TAGS{all} = [@EXPORT_OK];
78 __PACKAGE__->export_to_level( 1, $pkg, @wants );
79 }
80  
81 sub _affix_and_export ( $name, $args, $ret ) {
82 my ( $n, $r ) = ref $name ? @$name : ( $name, $name );
83 confess "Failed to affix $n" unless affix( $lib, $name, $args, $ret );
84 push @{ $EXPORT_TAGS{ [ caller(1) ]->[3] =~ s/^.+?_//r } }, $n;
85 }
86  
87 sub _const_and_export ( $name, $value ) {
88 no strict 'refs';
89 *{$name} = sub () {$value};
90 push @{ $EXPORT_TAGS{ [ caller(1) ]->[3] =~ s/^.+?_//r } }, $name;
91 }
92  
93 sub _func_and_export ( $name, $sub ) {
94 no strict 'refs';
95 *{$name} = $sub;
96 push @{ $EXPORT_TAGS{ [ caller(1) ]->[3] =~ s/^.+?_//r } }, $name;
97 }
98  
99 sub _typedef_and_export ( $name, $type //= () ) {
100 no strict 'refs';
101 if ( defined $type ) {
102 typedef $name, $type;
103 }
104 else {
105 typedef $name;
106 }
107 push @{ $EXPORT_TAGS{ [ caller(1) ]->[3] =~ s/^.+?_//r } }, $name;
108 }
109  
110 sub _enum_and_export ( $name, $values ) {
111 no strict 'refs';
112 if ( defined $values ) {
113 typedef $name, Enum [@$values];
114 push @{ $EXPORT_TAGS{ [ caller(1) ]->[3] =~ s/^.+?_//r } }, $name;
115 for my $enum (@$values) {
116 push @{ $EXPORT_TAGS{ [ caller(1) ]->[3] =~ s/^.+?_//r } }, ref $enum ? $enum->[0] : $enum;
117 }
118 }
119 }
120  
121 sub _ttf () {
122 state $done++ && return;
123  
124 # Runtime version discovery
125 _affix_and_export 'TTF_Version', [], Int;
126 _func_and_export TTF_VERSIONNUM => sub ( $major, $minor, $patch ) { ( ($major) * 1000000 + ($minor) * 1000 + ($patch) ) };
127 _func_and_export TTF_VERSIONNUM_MAJOR => sub ($version) { int( ($version) / 1000000 ) };
128 _func_and_export TTF_VERSIONNUM_MINOR => sub ($version) { int( ( ($version) / 1000 ) % 1000 ) };
129 _func_and_export TTF_VERSIONNUM_MICRO => sub ($version) { int( ($version) % 1000 ) };
130 _func_and_export TTF_MAJOR_VERSION => sub () { state $i //= TTF_VERSIONNUM_MAJOR( TTF_Version() ); $i };
131 _func_and_export TTF_MINOR_VERSION => sub () { state $i //= TTF_VERSIONNUM_MINOR( TTF_Version() ); $i };
132 _func_and_export TTF_MICRO_VERSION => sub () { state $i //= TTF_VERSIONNUM_MICRO( TTF_Version() ); $i };
133 _const_and_export TTF_VERSION => TTF_VERSIONNUM( TTF_MAJOR_VERSION(), TTF_MINOR_VERSION(), TTF_MICRO_VERSION() );
134 _func_and_export TTF_VERSION_ATLEAST => sub ( $X, $Y, $Z ) { ( TTF_VERSION() >= TTF_VERSIONNUM( $X, $Y, $Z ) ); };
135 _affix_and_export TTF_GetFreeTypeVersion => [ Pointer [Int], Pointer [Int], Pointer [Int] ], Void;
136 _affix_and_export TTF_GetHarfBuzzVersion => [ Pointer [Int], Pointer [Int], Pointer [Int] ], Void;
137 _typedef_and_export TTF_Font => Void;
138 _affix_and_export TTF_Init => [], Bool;
139 _affix_and_export TTF_Quit => [], Void;
140 _affix_and_export TTF_WasInit => [], Int;
141 _affix_and_export TTF_OpenFont => [ String, Float ], Pointer [ TTF_Font() ];
142 _affix_and_export TTF_OpenFontIO => [ Pointer [ SDL_IOStream() ], Bool, Float ], Pointer [ TTF_Font() ];
143 _affix_and_export TTF_OpenFontWithProperties => [ SDL_PropertiesID() ], Pointer [ TTF_Font() ];
144 _const_and_export TTF_PROP_FONT_CREATE_FILENAME_STRING => 'SDL_ttf.font.create.filename';
145 _const_and_export TTF_PROP_FONT_CREATE_IOSTREAM_POINTER => 'SDL_ttf.font.create.iostream';
146 _const_and_export TTF_PROP_FONT_CREATE_IOSTREAM_OFFSET_NUMBER => 'SDL_ttf.font.create.iostream.offset';
147 _const_and_export TTF_PROP_FONT_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN => 'SDL_ttf.font.create.iostream.autoclose';
148 _const_and_export TTF_PROP_FONT_CREATE_SIZE_FLOAT => 'SDL_ttf.font.create.size';
149 _const_and_export TTF_PROP_FONT_CREATE_FACE_NUMBER => 'SDL_ttf.font.create.face';
150 _const_and_export TTF_PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER => 'SDL_ttf.font.create.hdpi';
151 _const_and_export TTF_PROP_FONT_CREATE_VERTICAL_DPI_NUMBER => 'SDL_ttf.font.create.vdpi';
152 _const_and_export TTF_PROP_FONT_CREATE_EXISTING_FONT_POINTER => 'SDL_ttf.font.create.existing_font';
153 _affix_and_export TTF_CopyFont => [ Pointer [ TTF_Font() ] ], Pointer [ TTF_Font() ];
154 _affix_and_export TTF_CloseFont => [ Pointer [ TTF_Font() ] ], Void;
155 _affix_and_export TTF_GetFontProperties => [ Pointer [ TTF_Font() ] ], SDL_PropertiesID();
156 _const_and_export TTF_PROP_FONT_OUTLINE_LINE_CAP_NUMBER => 'SDL_ttf.font.outline.line_cap';
157 _const_and_export TTF_PROP_FONT_OUTLINE_LINE_JOIN_NUMBER => 'SDL_ttf.font.outline.line_join';
158 _const_and_export TTF_PROP_FONT_OUTLINE_MITER_LIMIT_NUMBER => 'SDL_ttf.font.outline.miter_limit';
159 _affix_and_export TTF_GetFontGeneration => [ Pointer [ TTF_Font() ] ], UInt32;
160 _affix_and_export TTF_AddFallbackFont => [ Pointer [ TTF_Font() ], Pointer [ TTF_Font() ] ], Bool;
161 _affix_and_export TTF_RemoveFallbackFont => [ Pointer [ TTF_Font() ], Pointer [ TTF_Font() ] ], Void;
162 _affix_and_export TTF_ClearFallbackFonts => [ Pointer [ TTF_Font() ] ], Void;
163 _affix_and_export TTF_SetFontSize => [ Pointer [ TTF_Font() ], Float ], Bool;
164 _affix_and_export TTF_SetFontSizeDPI => [ Pointer [ TTF_Font() ], Float, Int, Int ], Bool;
165 _affix_and_export TTF_GetFontSize => [ Pointer [ TTF_Font() ] ], Float;
166 _affix_and_export TTF_GetFontDPI => [ Pointer [ TTF_Font() ], Pointer [Int], Pointer [Int] ], Bool;
167 _typedef_and_export TTF_FontStyleFlags => UInt32;
168 _const_and_export TTF_STYLE_NORMAL => 0x00;
169 _const_and_export TTF_STYLE_BOLD => 0x01;
170 _const_and_export TTF_STYLE_ITALIC => 0x02;
171 _const_and_export TTF_STYLE_UNDERLINE => 0x04;
172 _const_and_export TTF_STYLE_STRIKETHROUGH => 0x08;
173 _affix_and_export TTF_SetFontStyle => [ Pointer [ TTF_Font() ], TTF_FontStyleFlags() ], Void;
174 _affix_and_export TTF_GetFontStyle => [ Pointer [ TTF_Font() ] ], TTF_FontStyleFlags();
175 _affix_and_export TTF_SetFontOutline => [ Pointer [ TTF_Font() ], Int ], Bool;
176 _affix_and_export TTF_GetFontOutline => [ Pointer [ TTF_Font() ] ], Int;
177 _enum_and_export TTF_HintingFlags =>
178 [ [ TTF_HINTING_INVALID => -1 ], qw[TTF_HINTING_NORMAL TTF_HINTING_LIGHT TTF_HINTING_MONO TTF_HINTING_NONE TTF_HINTING_LIGHT_SUBPIXEL] ];
179 _affix_and_export TTF_SetFontHinting => [ Pointer [ TTF_Font() ], TTF_HintingFlags() ], Void;
180 _affix_and_export TTF_GetFontHinting => [ Pointer [ TTF_Font() ] ], TTF_HintingFlags();
181 _affix_and_export TTF_GetNumFontFaces => [ Pointer [ TTF_Font() ] ], Int;
182 _affix_and_export TTF_SetFontSDF => [ Pointer [ TTF_Font() ], Bool ], Bool;
183 _affix_and_export TTF_GetFontSDF => [ Pointer [ TTF_Font() ] ], Bool;
184  
185 # Added in SDL_ttf 3.2.2
186 if ( TTF_VERSION_ATLEAST( 3, 2, 2 ) ) {
187 _affix_and_export TTF_GetFontWeight => [ Pointer [ TTF_Font() ] ], Int;
188 }
189 _const_and_export TTF_FONT_WEIGHT_THIN => 100;
190 _const_and_export TTF_FONT_WEIGHT_EXTRA_LIGHT => 200;
191 _const_and_export TTF_FONT_WEIGHT_LIGHT => 300;
192 _const_and_export TTF_FONT_WEIGHT_NORMAL => 400;
193 _const_and_export TTF_FONT_WEIGHT_MEDIUM => 500;
194 _const_and_export TTF_FONT_WEIGHT_SEMI_BOLD => 600;
195 _const_and_export TTF_FONT_WEIGHT_BOLD => 700;
196 _const_and_export TTF_FONT_WEIGHT_EXTRA_BOLD => 800;
197 _const_and_export TTF_FONT_WEIGHT_BLACK => 900;
198 _const_and_export TTF_FONT_WEIGHT_EXTRA_BLACK => 950;
199 _enum_and_export TTF_HorizontalAlignment =>
200 [ [ TTF_HORIZONTAL_ALIGN_INVALID => -1 ], qw[TTF_HORIZONTAL_ALIGN_LEFT TTF_HORIZONTAL_ALIGN_CENTER TTF_HORIZONTAL_ALIGN_RIGHT] ];
201 _affix_and_export TTF_SetFontWrapAlignment => [ Pointer [ TTF_Font() ], TTF_HorizontalAlignment() ], Void;
202 _affix_and_export TTF_GetFontWrapAlignment => [ Pointer [ TTF_Font() ] ], TTF_HorizontalAlignment();
203 _affix_and_export TTF_GetFontHeight => [ Pointer [ TTF_Font() ] ], Int;
204 _affix_and_export TTF_GetFontAscent => [ Pointer [ TTF_Font() ] ], Int;
205 _affix_and_export TTF_GetFontDescent => [ Pointer [ TTF_Font() ] ], Int;
206 _affix_and_export TTF_SetFontLineSkip => [ Pointer [ TTF_Font() ], Int ], Void;
207 _affix_and_export TTF_GetFontLineSkip => [ Pointer [ TTF_Font() ] ], Int;
208 _affix_and_export TTF_SetFontKerning => [ Pointer [ TTF_Font() ], Bool ], Void;
209 _affix_and_export TTF_GetFontKerning => [ Pointer [ TTF_Font() ] ], Bool;
210 _affix_and_export TTF_FontIsFixedWidth => [ Pointer [ TTF_Font() ] ], Bool;
211 _affix_and_export TTF_FontIsScalable => [ Pointer [ TTF_Font() ] ], Bool;
212 _affix_and_export TTF_GetFontFamilyName => [ Pointer [ TTF_Font() ] ], String;
213 _affix_and_export TTF_GetFontStyleName => [ Pointer [ TTF_Font() ] ], String;
214 _enum_and_export TTF_Direction =>
215 [ [ TTF_DIRECTION_INVALID => 0 ], [ TTF_DIRECTION_LTR => 4 ], qw[TTF_DIRECTION_RTL TTF_DIRECTION_TTB TTF_DIRECTION_BTT] ];
216 _affix_and_export TTF_SetFontDirection => [ Pointer [ TTF_Font() ], TTF_Direction() ], Bool;
217 _affix_and_export TTF_GetFontDirection => [ Pointer [ TTF_Font() ] ], TTF_Direction();
218  
219 # Added in SDL_ttf 3.4.0
220 if ( TTF_VERSION_ATLEAST( 3, 4, 0 ) ) {
221 _affix_and_export TTF_SetFontCharSpacing => [ Pointer [ TTF_Font() ], Int ], Bool;
222 _affix_and_export TTF_GetFontCharSpacing => [ Pointer [ TTF_Font() ], Int ], Int;
223 }
224 _affix_and_export TTF_StringToTag => [String], UInt32;
225 _affix_and_export TTF_TagToString => [ UInt32, Pointer [Char], Size_t ], Void;
226 _affix_and_export TTF_SetFontScript => [ Pointer [ TTF_Font() ], UInt32 ], Bool;
227 _affix_and_export TTF_GetFontScript => [ Pointer [ TTF_Font() ] ], UInt32;
228 _affix_and_export TTF_GetGlyphScript => [UInt32], UInt32;
229 _affix_and_export TTF_SetFontLanguage => [ Pointer [ TTF_Font() ], String ], Bool;
230 _affix_and_export TTF_FontHasGlyph => [ Pointer [ TTF_Font() ], UInt32 ], Bool;
231 _enum_and_export TTF_ImageType => [qw[TTF_IMAGE_INVALID TTF_IMAGE_ALPHA TTF_IMAGE_COLOR TTF_IMAGE_SDF]];
232 _affix_and_export TTF_GetGlyphImage => [ Pointer [ TTF_Font() ], UInt32, Pointer [ TTF_ImageType() ] ], Pointer [ SDL_Surface() ];
233 _affix_and_export TTF_GetGlyphImageForIndex => [ Pointer [ TTF_Font() ], UInt32, Pointer [ TTF_ImageType() ] ], Pointer [ SDL_Surface() ];
234 _affix_and_export
235 TTF_GetGlyphMetrics => [ Pointer [ TTF_Font() ], UInt32, Pointer [Int], Pointer [Int], Pointer [Int], Pointer [Int], Pointer [Int] ],
236 Bool;
237 _affix_and_export TTF_GetGlyphKerning => [ Pointer [ TTF_Font() ], UInt32, UInt32, Pointer [Int] ], Bool;
238 _affix_and_export TTF_GetStringSize => [ Pointer [ TTF_Font() ], String, Size_t, Pointer [Int], Pointer [Int] ], Bool;
239 _affix_and_export TTF_GetStringSizeWrapped => [ Pointer [ TTF_Font() ], String, Size_t, Int, Pointer [Int], Pointer [Int] ], Bool;
240 _affix_and_export TTF_MeasureString => [ Pointer [ TTF_Font() ], String, Size_t, Int, Pointer [Int], Pointer [Size_t] ], Bool;
241 _affix_and_export TTF_RenderText_Solid => [ Pointer [ TTF_Font() ], String, Size_t, SDL_Color() ], Pointer [ SDL_Surface() ];
242 _affix_and_export TTF_RenderText_Solid_Wrapped => [ Pointer [ TTF_Font() ], String, Size_t, SDL_Color(), Int ], Pointer [ SDL_Surface() ];
243 _affix_and_export TTF_RenderGlyph_Solid => [ Pointer [ TTF_Font() ], UInt32, SDL_Color() ], Pointer [ SDL_Surface() ];
244 _affix_and_export TTF_RenderText_Shaded => [ Pointer [ TTF_Font() ], String, Size_t, SDL_Color(), SDL_Color() ], Pointer [ SDL_Surface() ];
245 _affix_and_export
246 TTF_RenderText_Shaded_Wrapped => [ Pointer [ TTF_Font() ], String, Size_t, SDL_Color(), SDL_Color(), Int ],
247 Pointer [ SDL_Surface() ];
248 _affix_and_export TTF_RenderGlyph_Shaded => [ Pointer [ TTF_Font() ], UInt32, SDL_Color(), SDL_Color() ], Pointer [ SDL_Surface() ];
249 _affix_and_export TTF_RenderText_Blended => [ Pointer [ TTF_Font() ], String, Size_t, SDL_Color() ], Pointer [ SDL_Surface() ];
250 _affix_and_export TTF_RenderText_Blended_Wrapped => [ Pointer [ TTF_Font() ], String, Size_t, SDL_Color(), Int ], Pointer [ SDL_Surface() ];
251 _affix_and_export TTF_RenderGlyph_Blended => [ Pointer [ TTF_Font() ], UInt32, SDL_Color() ], Pointer [ SDL_Surface() ];
252 _affix_and_export TTF_RenderText_LCD => [ Pointer [ TTF_Font() ], String, Size_t, SDL_Color(), SDL_Color() ], Pointer [ SDL_Surface() ];
253 _affix_and_export
254 TTF_RenderText_LCD_Wrapped => [ Pointer [ TTF_Font() ], String, Size_t, SDL_Color(), SDL_Color(), Int ],
255 Pointer [ SDL_Surface() ];
256 _affix_and_export TTF_RenderGlyph_LCD => [ Pointer [ TTF_Font() ], UInt32, SDL_Color(), SDL_Color() ], Pointer [ SDL_Surface() ];
257  
258 # Text Engine API (from SDL_textengine.h)
259 _enum_and_export TTF_DrawCommand => [qw[TTF_DRAW_COMMAND_NOOP TTF_DRAW_COMMAND_FILL TTF_DRAW_COMMAND_COPY]];
260 _typedef_and_export TTF_FillOperation => Struct [ cmd => TTF_DrawCommand(), rect => SDL_Rect() ];
261 _typedef_and_export TTF_CopyOperation => Struct [
262 cmd => TTF_DrawCommand(),
263 text_offset => Int,
264 glyph_font => Pointer [ TTF_Font() ],
265 glyph_index => UInt32,
266 src => SDL_Rect(),
267 dst => SDL_Rect(),
268 reserved => Pointer [Void]
269 ];
270 _typedef_and_export TTF_DrawOperation => Union [ cmd => TTF_DrawCommand(), fill => TTF_FillOperation(), copy => TTF_CopyOperation() ];
271 _typedef_and_export TTF_TextLayout => Void;
272 typedef 'TTF_Text';
273 typedef 'TTF_TextEngine';
274 _typedef_and_export TTF_SubStringFlags => UInt32;
275 _const_and_export TTF_SUBSTRING_DIRECTION_MASK => 0x000000FF;
276 _const_and_export TTF_SUBSTRING_TEXT_START => 0x00000100;
277 _const_and_export TTF_SUBSTRING_LINE_START => 0x00000200;
278 _const_and_export TTF_SUBSTRING_LINE_END => 0x00000400;
279 _const_and_export TTF_SUBSTRING_TEXT_END => 0x00000800;
280 _typedef_and_export TTF_SubString =>
281 Struct [ flags => TTF_SubStringFlags(), offset => Int, length => Int, line_index => Int, cluster_index => Int, rect => SDL_Rect() ];
282 _typedef_and_export TTF_TextData => Struct [
283 font => Pointer [ TTF_Font() ],
284 color => SDL_FColor(),
285 needs_layout_update => Bool,
286 layout => Pointer [ TTF_TextLayout() ],
287 x => Int,
288 y => Int,
289 w => Int,
290 h => Int,
291 num_ops => Int,
292 ops => Pointer [ TTF_DrawOperation() ],
293 num_clusters => Int,
294 clusters => Pointer [ TTF_SubString() ],
295 props => SDL_PropertiesID(),
296 needs_engine_update => Bool,
297 engine => Pointer [ TTF_TextEngine() ],
298 engine_text => Pointer [Void]
299 ];
300 _typedef_and_export TTF_Text => Struct [ text => String, num_lines => Int, refcount => Int, internal => Pointer [ TTF_TextData() ] ];
301 _typedef_and_export TTF_TextEngine => Struct [
302 version => UInt32,
303 userdata => Pointer [Void],
304 CreateText => Callback [ [ Pointer [Void], Pointer [ TTF_Text() ] ] => Bool ],
305 DestroyText => Callback [ [ Pointer [Void], Pointer [ TTF_Text() ] ] => Void ]
306 ];
307 _affix_and_export TTF_CreateSurfaceTextEngine => [], Pointer [ TTF_TextEngine() ];
308 _affix_and_export TTF_DrawSurfaceText => [ Pointer [ TTF_Text() ], Int, Int, Pointer [ SDL_Surface() ] ], Bool;
309 _affix_and_export TTF_DestroySurfaceTextEngine => [ Pointer [ TTF_TextEngine() ] ], Void;
310 _affix_and_export TTF_CreateRendererTextEngine => [ Pointer [ SDL_Renderer() ] ], Pointer [ TTF_TextEngine() ];
311 _affix_and_export TTF_CreateRendererTextEngineWithProperties => [ SDL_PropertiesID() ], Pointer [ TTF_TextEngine() ];
312 _const_and_export TTF_PROP_RENDERER_TEXT_ENGINE_RENDERER_POINTER => 'SDL_ttf.renderer_text_engine.create.renderer';
313 _const_and_export TTF_PROP_RENDERER_TEXT_ENGINE_ATLAS_TEXTURE_SIZE_NUMBER => 'SDL_ttf.renderer_text_engine.create.atlas_texture_size';
314 _affix_and_export TTF_DrawRendererText => [ Pointer [ TTF_Text() ], Float, Float ], Bool;
315 _affix_and_export TTF_DestroyRendererTextEngine => [ Pointer [ TTF_TextEngine() ] ], Void;
316 _affix_and_export TTF_CreateGPUTextEngine => [ Pointer [ SDL_GPUDevice() ] ], Pointer [ TTF_TextEngine() ];
317 _affix_and_export TTF_CreateGPUTextEngineWithProperties => [ SDL_PropertiesID() ], Pointer [ TTF_TextEngine() ];
318 _const_and_export TTF_PROP_GPU_TEXT_ENGINE_DEVICE_POINTER => 'SDL_ttf.gpu_text_engine.create.device';
319 _const_and_export TTF_PROP_GPU_TEXT_ENGINE_ATLAS_TEXTURE_SIZE_NUMBER => 'SDL_ttf.gpu_text_engine.create.atlas_texture_size';
320 typedef 'TTF_GPUAtlasDrawSequence';
321 _typedef_and_export TTF_GPUAtlasDrawSequence => Struct [
322 atlas_texture => Pointer [ SDL_GPUTexture() ],
323 xy => Pointer [ SDL_FPoint() ],
324 uv => Pointer [ SDL_FPoint() ],
325 num_vertices => Int,
326 indices => Pointer [Int],
327 num_indices => Int,
328 image_type => TTF_ImageType(),
329 next => Pointer [ TTF_GPUAtlasDrawSequence() ]
330 ];
331 _affix_and_export TTF_GetGPUTextDrawData => [ Pointer [ TTF_Text() ] ], Pointer [ TTF_GPUAtlasDrawSequence() ];
332 _affix_and_export TTF_DestroyGPUTextEngine => [ Pointer [ TTF_TextEngine() ] ], Void;
333 _enum_and_export TTF_GPUTextEngineWinding =>
334 [ [ TTF_GPU_TEXTENGINE_WINDING_INVALID => -1 ], 'TTF_GPU_TEXTENGINE_WINDING_CLOCKWISE', 'TTF_GPU_TEXTENGINE_WINDING_COUNTER_CLOCKWISE' ];
335 _affix_and_export TTF_SetGPUTextEngineWinding => [ Pointer [ TTF_TextEngine() ], TTF_GPUTextEngineWinding() ], Void;
336 _affix_and_export TTF_GetGPUTextEngineWinding => [ Pointer [ TTF_TextEngine() ] ], TTF_GPUTextEngineWinding();
337  
338 # Added in SDL_ttf 3.3.0
339 if ( TTF_VERSION_ATLEAST( 3, 3, 0 ) ) {
340 _affix_and_export TTF_CreateGLTextEngine => [], Pointer [ TTF_TextEngine() ];
341 _affix_and_export TTF_CreateGLTextEngineWithProperties => [ SDL_PropertiesID() ], Pointer [ TTF_TextEngine() ];
342 _const_and_export TTF_PROP_GL_TEXT_ENGINE_ATLAS_TEXTURE_SIZE_NUMBER => 'SDL_ttf.gl_text_engine.create.atlas_texture_size';
343 _typedef_and_export TTF_GLAtlasDrawVertex => Struct [ position => SDL_FPoint(), texcoord => SDL_FPoint() ];
344 typedef 'TTF_GLAtlasDrawSequence';
345 _typedef_and_export TTF_GLAtlasDrawSequence => Struct [
346 atlas_texture => UInt,
347 vertices => Pointer [ TTF_GLAtlasDrawVertex() ],
348 num_vertices => Int,
349 indices => Pointer [UShort],
350 num_indices => Int,
351 image_type => TTF_ImageType(),
352 next => Pointer [ TTF_GLAtlasDrawSequence() ]
353 ];
354 _affix_and_export TTF_GetGLTextDrawData => [ Pointer [ TTF_Text() ] ], Pointer [ TTF_GLAtlasDrawSequence() ];
355 _affix_and_export TTF_DestroyGLTextEngine => [ Pointer [ TTF_TextEngine() ] ], Void;
356 _enum_and_export TTF_GLTextEngineWinding =>
357 [ [ TTF_GL_TEXTENGINE_WINDING_INVALID => -1 ], 'TTF_GL_TEXTENGINE_WINDING_CLOCKWISE', 'TTF_GL_TEXTENGINE_WINDING_COUNTER_CLOCKWISE' ];
358 _affix_and_export TTF_SetGLTextEngineWinding => [ Pointer [ TTF_TextEngine() ], TTF_GLTextEngineWinding() ], Void;
359 _affix_and_export TTF_GetGLTextEngineWinding => [ Pointer [ TTF_TextEngine() ] ], TTF_GLTextEngineWinding();
360 }
361 _affix_and_export TTF_CreateText => [ Pointer [ TTF_TextEngine() ], Pointer [ TTF_Font() ], String, Size_t ], Pointer [ TTF_Text() ];
362 _affix_and_export TTF_GetTextProperties => [ Pointer [ TTF_Text() ] ], SDL_PropertiesID();
363 _affix_and_export TTF_SetTextEngine => [ Pointer [ TTF_Text() ], Pointer [ TTF_TextEngine() ] ], Bool;
364 _affix_and_export TTF_GetTextEngine => [ Pointer [ TTF_Text() ] ], Pointer [ TTF_TextEngine() ];
365 _affix_and_export TTF_SetTextFont => [ Pointer [ TTF_Text() ], Pointer [ TTF_Font() ] ], Bool;
366 _affix_and_export TTF_GetTextFont => [ Pointer [ TTF_Text() ] ], Pointer [ TTF_Font() ];
367 _affix_and_export TTF_SetTextDirection => [ Pointer [ TTF_Text() ], TTF_Direction() ], Bool;
368 _affix_and_export TTF_GetTextDirection => [ Pointer [ TTF_Text() ] ], TTF_Direction();
369 _affix_and_export TTF_SetTextScript => [ Pointer [ TTF_Text() ], UInt32 ], Bool;
370 _affix_and_export TTF_GetTextScript => [ Pointer [ TTF_Text() ] ], UInt32;
371 _affix_and_export TTF_SetTextColor => [ Pointer [ TTF_Text() ], UInt8, UInt8, UInt8, UInt8 ], Bool;
372 _affix_and_export TTF_SetTextColorFloat => [ Pointer [ TTF_Text() ], Float, Float, Float, Float ], Bool;
373 _affix_and_export TTF_GetTextColor => [ Pointer [ TTF_Text() ], Pointer [UInt8], Pointer [UInt8], Pointer [UInt8], Pointer [UInt8] ], Bool;
374 _affix_and_export
375 TTF_GetTextColorFloat => [ Pointer [ TTF_Text() ], Pointer [Float], Pointer [Float], Pointer [Float], Pointer [Float] ],
376 Bool;
377 _affix_and_export TTF_SetTextPosition => [ Pointer [ TTF_Text() ], Int, Int ], Bool;
378 _affix_and_export TTF_GetTextPosition => [ Pointer [ TTF_Text() ], Pointer [Int], Pointer [Int] ], Bool;
379 _affix_and_export TTF_SetTextWrapWidth => [ Pointer [ TTF_Text() ], Int ], Bool;
380 _affix_and_export TTF_GetTextWrapWidth => [ Pointer [ TTF_Text() ], Pointer [Int] ], Bool;
381 _affix_and_export TTF_SetTextWrapWhitespaceVisible => [ Pointer [ TTF_Text() ], Bool ], Bool;
382 _affix_and_export TTF_TextWrapWhitespaceVisible => [ Pointer [ TTF_Text() ] ], Bool;
383 _affix_and_export TTF_SetTextString => [ Pointer [ TTF_Text() ], String, Size_t ], Bool;
384 _affix_and_export TTF_InsertTextString => [ Pointer [ TTF_Text() ], Int, String, Size_t ], Bool;
385 _affix_and_export TTF_AppendTextString => [ Pointer [ TTF_Text() ], String, Size_t ], Bool;
386 _affix_and_export TTF_DeleteTextString => [ Pointer [ TTF_Text() ], Int, Int ], Bool;
387 _affix_and_export TTF_GetTextSize => [ Pointer [ TTF_Text() ], Pointer [Int], Pointer [Int] ], Bool;
388 _affix_and_export TTF_GetTextSubString => [ Pointer [ TTF_Text() ], Int, Pointer [ TTF_SubString() ] ], Bool;
389 _affix_and_export TTF_GetTextSubStringForLine => [ Pointer [ TTF_Text() ], Int, Pointer [ TTF_SubString() ] ], Bool;
390 _affix_and_export
391 TTF_GetTextSubStringsForRange => [ Pointer [ TTF_Text() ], Int, Int, Pointer [Int] ],
392 Pointer [ Pointer [ TTF_SubString() ] ];
393 _affix_and_export TTF_GetTextSubStringForPoint => [ Pointer [ TTF_Text() ], Int, Int, Pointer [ TTF_SubString() ] ], Bool;
394 _affix_and_export TTF_GetPreviousTextSubString => [ Pointer [ TTF_Text() ], Pointer [ TTF_SubString() ], Pointer [ TTF_SubString() ] ], Bool;
395 _affix_and_export TTF_GetNextTextSubString => [ Pointer [ TTF_Text() ], Pointer [ TTF_SubString() ], Pointer [ TTF_SubString() ] ], Bool;
396 _affix_and_export TTF_UpdateText => [ Pointer [ TTF_Text() ] ], Bool;
397 _affix_and_export TTF_DestroyText => [ Pointer [ TTF_Text() ] ], Void;
398 }
399  
400 sub _all () {
401 state $done++ && return;
402 _ttf();
403 }
404 }
405 1;
406  
407 =head1 See Also
408  
409 The project's repo: L<https://github.com/Perl-SDL3/>
410  
411 The SDL3_ttf Wiki: L<https://wiki.libsdl.org/SDL3_ttf/FrontPage>
412  
413 L<SDL3>
414  
415 L<Affix>
416  
417 =head1 LICENSE
418  
419 This software is Copyright (c) 2026 by Sanko Robinson.
420  
421 This is free software, licensed under:
422  
423 The Artistic License 2.0 (GPL Compatible)
424  
425 See the F<LICENSE> file for full text.
426  
427 =head1 AUTHOR
428  
429 Sanko Robinson L<https://github.com/sanko>
430  
431 =begin stopwords
432  
433  
434 =end stopwords
435  
436 =cut