Skip to content

Commit c211100

Browse files
authored
Update bindings to support SDL_ttf 2.0.18 (#216)
* Automatically add TTF functions to __all__ * Add raw bindings for SDL_ttf 2.0.18 * Document new TTF functions, add HB helpers * Add unit tests for new TTF functions * Update news.rst
1 parent 7ebf0a3 commit c211100

File tree

4 files changed

+1088
-67
lines changed

4 files changed

+1088
-67
lines changed

doc/modules/sdl2_sdlttf.rst

Lines changed: 117 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ Initialization functions
6767

6868
.. autofunction:: TTF_Linked_Version
6969

70+
.. autofunction:: TTF_GetFreeTypeVersion
71+
72+
.. autofunction:: TTF_GetHarfBuzzVersion
7073

7174

7275
Font loading functions
@@ -80,17 +83,26 @@ Font loading functions
8083

8184
.. autofunction:: TTF_OpenFontIndexRW
8285

86+
.. autofunction:: TTF_OpenFontDPI
87+
88+
.. autofunction:: TTF_OpenFontIndexDPI
89+
90+
.. autofunction:: TTF_OpenFontDPIRW
91+
92+
.. autofunction:: TTF_OpenFontIndexDPIRW
93+
8394
.. autofunction:: TTF_CloseFont
8495

8596

8697
Font attribute functions
8798
------------------------
8899

89-
.. autofunction:: TTF_SetFontStyle
100+
Sizing functions
101+
^^^^^^^^^^^^^^^^
90102

91-
.. autofunction:: TTF_GetFontStyle
103+
.. autofunction:: TTF_SetFontSize
92104

93-
.. autofunction:: TTF_SetFontHinting
105+
.. autofunction:: TTF_SetFontSizeDPI
94106

95107
.. autofunction:: TTF_FontHeight
96108

@@ -100,29 +112,65 @@ Font attribute functions
100112

101113
.. autofunction:: TTF_FontLineSkip
102114

103-
.. autofunction:: TTF_GetFontKerning
115+
Style functions
116+
^^^^^^^^^^^^^^^
104117

105-
.. autofunction:: TTF_SetFontKerning
118+
.. autofunction:: TTF_SetFontStyle
119+
120+
.. autofunction:: TTF_GetFontStyle
106121

107122
.. autofunction:: TTF_FontFaceIsFixedWidth
108123

109124
.. autofunction:: TTF_FontFaceFamilyName
110125

111126
.. autofunction:: TTF_FontFaceStyleName
112127

128+
129+
Glyph information functions
130+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
131+
113132
.. autofunction:: TTF_GlyphIsProvided
114133

134+
.. autofunction:: TTF_GlyphIsProvided32
135+
115136
.. autofunction:: TTF_GlyphMetrics
116137

138+
.. autofunction:: TTF_GlyphMetrics32
139+
140+
141+
Kerning functions
142+
^^^^^^^^^^^^^^^^^
143+
.. autofunction:: TTF_GetFontKerning
144+
145+
.. autofunction:: TTF_SetFontKerning
146+
117147
.. autofunction:: TTF_GetFontKerningSizeGlyphs
118148

149+
.. autofunction:: TTF_GetFontKerningSizeGlyphs32
150+
151+
152+
Render settings functions
153+
^^^^^^^^^^^^^^^^^^^^^^^^^
154+
155+
.. autofunction:: TTF_SetFontHinting
156+
157+
.. autofunction:: TTF_SetFontSDF
158+
159+
.. autofunction:: TTF_GetFontSDF
160+
119161

120162
Text rendering functions
121163
------------------------
122164

123165
Size calculation functions
124166
^^^^^^^^^^^^^^^^^^^^^^^^^^
125167

168+
.. autofunction:: TTF_MeasureText
169+
170+
.. autofunction:: TTF_MeasureUTF8
171+
172+
.. autofunction:: TTF_MeasureUNICODE
173+
126174
.. autofunction:: TTF_SizeText
127175

128176
.. autofunction:: TTF_SizeUTF8
@@ -141,6 +189,14 @@ Solid rendering functions
141189

142190
.. autofunction:: TTF_RenderGlyph_Solid
143191

192+
.. autofunction:: TTF_RenderGlyph32_Solid
193+
194+
.. autofunction:: TTF_RenderText_Solid_Wrapped
195+
196+
.. autofunction:: TTF_RenderUTF8_Solid_Wrapped
197+
198+
.. autofunction:: TTF_RenderUNICODE_Solid_Wrapped
199+
144200

145201
Shaded rendering functions
146202
^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -153,6 +209,14 @@ Shaded rendering functions
153209

154210
.. autofunction:: TTF_RenderGlyph_Shaded
155211

212+
.. autofunction:: TTF_RenderGlyph32_Shaded
213+
214+
.. autofunction:: TTF_RenderText_Shaded_Wrapped
215+
216+
.. autofunction:: TTF_RenderUTF8_Shaded_Wrapped
217+
218+
.. autofunction:: TTF_RenderUNICODE_Shaded_Wrapped
219+
156220

157221
Blended rendering functions
158222
^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -165,13 +229,23 @@ Blended rendering functions
165229

166230
.. autofunction:: TTF_RenderGlyph_Blended
167231

232+
.. autofunction:: TTF_RenderGlyph32_Blended
233+
168234
.. autofunction:: TTF_RenderText_Blended_Wrapped
169235

170236
.. autofunction:: TTF_RenderUTF8_Blended_Wrapped
171237

172238
.. autofunction:: TTF_RenderUNICODE_Blended_Wrapped
173239

174240

241+
Renderer configuration functions
242+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
243+
244+
.. autofunction:: TTF_SetDirection
245+
246+
.. autofunction:: TTF_SetScript
247+
248+
175249
Data types
176250
----------
177251

@@ -257,3 +331,41 @@ Module constants
257331
Used to indicate set hinting type to none.
258332
No hinting is used, so the font may become very blurry or messy at
259333
smaller sizes.
334+
335+
.. data:: TTF_HINTING_LIGHT_SUBPIXEL
336+
337+
Used to indicate set hinting type to light subpixel.
338+
This produces better results for small text sizes: glyph are rendered at
339+
subpixel positions, so they look blurrier but are uniformly positioned.
340+
This mode is slower than others since glyphs are rendered on the fly.
341+
342+
343+
HarfBuzz functions and constants
344+
--------------------------------
345+
346+
As of version 2.0.18, SDL2_ttf makes use of the HarfBuzz library for advanced
347+
text rendering and shaping unless explicitly compiled without it. As a
348+
consequence, some specific SDL2_ttf functions require HarfBuzz constants and
349+
macros for input.
350+
351+
To make these easier to use, the ``sdlttf`` module defines and implements the
352+
constants and macro functions necessary to make full use of the SDL2_ttf
353+
library.
354+
355+
.. autofunction:: HB_TAG
356+
357+
.. data:: HB_DIRECTION_LTR
358+
359+
A constant indicating left-to-right text rendering.
360+
361+
.. data:: HB_DIRECTION_RTL
362+
363+
A constant indicating right-to-left text rendering.
364+
365+
.. data:: HB_DIRECTION_TTB
366+
367+
A constant indicating top-to-bottom text rendering.
368+
369+
.. data:: HB_DIRECTION_BTT
370+
371+
A constant indicating bottom-to-top text rendering.

doc/news.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Released on XXXX-XX-XX.
1010
New Features:
1111

1212
* Updated to wrap new functions and constants in SDL2 2.0.20 (PR #214)
13+
* Updated to wrap new functions and constants in SDL2_ttf 2.0.18 (PR #216)
1314

1415

1516
0.9.10

0 commit comments

Comments
 (0)