1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157 | --------------------------------------------------------------------------------------------------------------------
-- This source code is subject to the Zlib license, see the LICENCE file in the root of this directory.
--------------------------------------------------------------------------------------------------------------------
-- SDL.TTFs
--
-- Root package implementing the binding to SDL2_ttf.
--------------------------------------------------------------------------------------------------------------------
with Ada.Finalization;
with Ada.Strings.UTF_Encoding;
with Interfaces.C;
with SDL.Video.Palettes;
with SDL.Video.Surfaces;
package SDL.TTFs is
pragma Preelaborate;
package UTF_Strings renames Ada.Strings.UTF_Encoding;
package C renames Interfaces.C;
TTF_Error : exception;
function Initialise return Boolean with
Inline_Always => True;
procedure Finalise with
Import => True,
Convention => C,
External_Name => "TTF_Quit";
-- Fonts.
type Point_Sizes is new C.int;
type Font_Faces is range 0 .. C.long'Last with
Size => C.long'Size,
Convention => C;
type Font_Styles is mod 2 ** 32 with
Convention => C;
Style_Normal : constant Font_Styles := 16#0000_0000#;
Style_Bold : constant Font_Styles := 16#0000_0001#;
Style_Italic : constant Font_Styles := 16#0000_0002#;
Style_Underline : constant Font_Styles := 16#0000_0004#;
Style_Strike_Through : constant Font_Styles := 16#0000_0008#;
type Font_Outlines is range 0 .. C.int'Last with
Size => C.int'Size,
Convention => C;
Outlines_Off : constant Font_Outlines := Font_Outlines'First;
type Font_Hints is (Normal, Light, Mono, None) with
Convention => C;
type Font_Measurements is range 0 .. C.int'Last with
Size => C.int'Size,
Convention => C;
type Fonts is new Ada.Finalization.Controlled with private;
Null_Font : constant Fonts;
overriding
procedure Finalize (Self : in out Fonts);
function Style (Self : in Fonts) return Font_Styles with
Inline => True;
procedure Set_Style (Self : in out Fonts; Now : in Font_Styles) with
Inline => True;
function Outline (Self : in Fonts) return Font_Outlines with
Inline => True;
procedure Set_Outline (Self : in out Fonts; Now : in Font_Outlines := Outlines_Off) with
Inline => True;
function Hinting (Self : in Fonts) return Font_Hints with
Inline => True;
procedure Set_Hinting (Self : in out Fonts; Now : in Font_Hints := Normal) with
Inline => True;
function Kerning (Self : in Fonts) return Boolean with
Inline => True;
procedure Set_Kerning (Self : in out Fonts; Now : in Boolean) with
Inline => True;
function Height (Self : in Fonts) return Font_Measurements with
Inline => True;
function Ascent (Self : in Fonts) return Font_Measurements with
Inline => True;
function Descent (Self : in Fonts) return Font_Measurements with
Inline => True;
function Line_Skip (Self : in Fonts) return Font_Measurements with
Inline => True;
function Faces (Self : in Fonts) return Font_Faces with
Inline => True;
function Is_Face_Fixed_Width (Self : in Fonts) return Boolean with
Inline => True;
function Face_Family_Name (Self : in Fonts) return String with
Inline => True;
function Face_Style_Name (Self : in Fonts) return String with
Inline => True;
function Size_Latin_1 (Self : in Fonts; Text : in String) return SDL.Sizes with
Inline => True;
function Size_UTF_8 (Self : in Fonts; Text : in UTF_Strings.UTF_8_String) return SDL.Sizes with
Inline => True;
function Render_Solid (Self : in Fonts;
Text : in String;
Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface;
function Render_Shaded (Self : in Fonts;
Text : in String;
Colour : in SDL.Video.Palettes.Colour;
Background_Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface;
function Render_Blended (Self : in Fonts;
Text : in String;
Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface;
function Render_UTF_8_Solid (Self : in Fonts;
Text : in UTF_Strings.UTF_8_String;
Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface;
function Render_UTF_8_Shaded (Self : in Fonts;
Text : in UTF_Strings.UTF_8_String;
Colour : in SDL.Video.Palettes.Colour;
Background_Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface;
function Render_UTF_8_Blended (Self : in Fonts;
Text : in UTF_Strings.UTF_8_String;
Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface;
private
type Internal_Fonts is null record;
type Fonts_Pointer is access all Internal_Fonts with
Convention => C;
subtype Fonts_Ref is not null Fonts_Pointer;
type Fonts is new Ada.Finalization.Controlled with
record
Internal : Fonts_Pointer := null;
Source_Freed : Boolean := False; -- Whether the Makers.* subprogram has already closed the font.
end record;
Null_Font : constant Fonts := (Ada.Finalization.Controlled with others => <>);
end SDL.TTFs;
|