1
+ import sys
1
2
from typing import BinaryIO , Literal , TypedDict , final , overload
3
+ from typing_extensions import Buffer # < Py 3.12
2
4
3
5
import numpy as np
4
6
from numpy .typing import NDArray
@@ -159,28 +161,7 @@ class _SfntPcltDict(TypedDict):
159
161
serifStyle : int
160
162
161
163
@final
162
- class FT2Font :
163
- ascender : int
164
- bbox : tuple [int , int , int , int ]
165
- descender : int
166
- face_flags : int
167
- family_name : str
168
- fname : str
169
- height : int
170
- max_advance_height : int
171
- max_advance_width : int
172
- num_charmaps : int
173
- num_faces : int
174
- num_fixed_sizes : int
175
- num_glyphs : int
176
- postscript_name : str
177
- scalable : bool
178
- style_flags : int
179
- style_name : str
180
- underline_position : int
181
- underline_thickness : int
182
- units_per_EM : int
183
-
164
+ class FT2Font (Buffer ):
184
165
def __init__ (
185
166
self ,
186
167
filename : str | BinaryIO ,
@@ -189,6 +170,8 @@ class FT2Font:
189
170
_fallback_list : list [FT2Font ] | None = ...,
190
171
_kerning_factor : int = ...
191
172
) -> None : ...
173
+ if sys .version_info [:2 ] >= (3 , 12 ):
174
+ def __buffer__ (self , flags : int ) -> memoryview : ...
192
175
def _get_fontmap (self , string : str ) -> dict [str , FT2Font ]: ...
193
176
def clear (self ) -> None : ...
194
177
def draw_glyph_to_bitmap (
@@ -232,23 +215,73 @@ class FT2Font:
232
215
def set_text (
233
216
self , string : str , angle : float = ..., flags : int = ...
234
217
) -> NDArray [np .float64 ]: ...
218
+ @property
219
+ def ascender (self ) -> int : ...
220
+ @property
221
+ def bbox (self ) -> tuple [int , int , int , int ]: ...
222
+ @property
223
+ def descender (self ) -> int : ...
224
+ @property
225
+ def face_flags (self ) -> int : ...
226
+ @property
227
+ def family_name (self ) -> str : ...
228
+ @property
229
+ def fname (self ) -> str : ...
230
+ @property
231
+ def height (self ) -> int : ...
232
+ @property
233
+ def max_advance_height (self ) -> int : ...
234
+ @property
235
+ def max_advance_width (self ) -> int : ...
236
+ @property
237
+ def num_charmaps (self ) -> int : ...
238
+ @property
239
+ def num_faces (self ) -> int : ...
240
+ @property
241
+ def num_fixed_sizes (self ) -> int : ...
242
+ @property
243
+ def num_glyphs (self ) -> int : ...
244
+ @property
245
+ def postscript_name (self ) -> str : ...
246
+ @property
247
+ def scalable (self ) -> bool : ...
248
+ @property
249
+ def style_flags (self ) -> int : ...
250
+ @property
251
+ def style_name (self ) -> str : ...
252
+ @property
253
+ def underline_position (self ) -> int : ...
254
+ @property
255
+ def underline_thickness (self ) -> int : ...
256
+ @property
257
+ def units_per_EM (self ) -> int : ...
235
258
236
259
@final
237
- class FT2Image : # TODO: When updating mypy>=1.4, subclass from Buffer.
260
+ class FT2Image ( Buffer ):
238
261
def __init__ (self , width : float , height : float ) -> None : ...
239
262
def draw_rect_filled (self , x0 : float , y0 : float , x1 : float , y1 : float ) -> None : ...
263
+ if sys .version_info [:2 ] >= (3 , 12 ):
264
+ def __buffer__ (self , flags : int ) -> memoryview : ...
240
265
241
266
@final
242
267
class Glyph :
243
- width : int
244
- height : int
245
- horiBearingX : int
246
- horiBearingY : int
247
- horiAdvance : int
248
- linearHoriAdvance : int
249
- vertBearingX : int
250
- vertBearingY : int
251
- vertAdvance : int
252
-
268
+ @property
269
+ def width (self ) -> int : ...
270
+ @property
271
+ def height (self ) -> int : ...
272
+ @property
273
+ def horiBearingX (self ) -> int : ...
274
+ @property
275
+ def horiBearingY (self ) -> int : ...
276
+ @property
277
+ def horiAdvance (self ) -> int : ...
278
+ @property
279
+ def linearHoriAdvance (self ) -> int : ...
280
+ @property
281
+ def vertBearingX (self ) -> int : ...
282
+ @property
283
+ def vertBearingY (self ) -> int : ...
284
+ @property
285
+ def vertAdvance (self ) -> int : ...
253
286
@property
254
287
def bbox (self ) -> tuple [int , int , int , int ]: ...
0 commit comments