Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1b39e89

Browse files
committed
Convert ft2font extension to pybind11
1 parentdf1cfde commit1b39e89

File tree

4 files changed

+703
-1067
lines changed

4 files changed

+703
-1067
lines changed

‎lib/matplotlib/ft2font.pyi

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -160,27 +160,6 @@ class _SfntPcltDict(TypedDict):
160160

161161
@final
162162
classFT2Font:
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-
184163
def__init__(
185164
self,
186165
filename:str|BinaryIO,
@@ -232,6 +211,46 @@ class FT2Font:
232211
defset_text(
233212
self,string:str,angle:float= ...,flags:int= ...
234213
)->NDArray[np.float64]: ...
214+
@property
215+
defascender(self)->int: ...
216+
@property
217+
defbbox(self)->tuple[int,int,int,int]: ...
218+
@property
219+
defdescender(self)->int: ...
220+
@property
221+
defface_flags(self)->int: ...
222+
@property
223+
deffamily_name(self)->str: ...
224+
@property
225+
deffname(self)->str: ...
226+
@property
227+
defheight(self)->int: ...
228+
@property
229+
defmax_advance_height(self)->int: ...
230+
@property
231+
defmax_advance_width(self)->int: ...
232+
@property
233+
defnum_charmaps(self)->int: ...
234+
@property
235+
defnum_faces(self)->int: ...
236+
@property
237+
defnum_fixed_sizes(self)->int: ...
238+
@property
239+
defnum_glyphs(self)->int: ...
240+
@property
241+
defpostscript_name(self)->str: ...
242+
@property
243+
defscalable(self)->bool: ...
244+
@property
245+
defstyle_flags(self)->int: ...
246+
@property
247+
defstyle_name(self)->str: ...
248+
@property
249+
defunderline_position(self)->int: ...
250+
@property
251+
defunderline_thickness(self)->int: ...
252+
@property
253+
defunits_per_EM(self)->int: ...
235254

236255
@final
237256
classFT2Image:# TODO: When updating mypy>=1.4, subclass from Buffer.
@@ -240,15 +259,23 @@ class FT2Image: # TODO: When updating mypy>=1.4, subclass from Buffer.
240259

241260
@final
242261
classGlyph:
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-
262+
@property
263+
defwidth(self)->int: ...
264+
@property
265+
defheight(self)->int: ...
266+
@property
267+
defhoriBearingX(self)->int: ...
268+
@property
269+
defhoriBearingY(self)->int: ...
270+
@property
271+
defhoriAdvance(self)->int: ...
272+
@property
273+
deflinearHoriAdvance(self)->int: ...
274+
@property
275+
defvertBearingX(self)->int: ...
276+
@property
277+
defvertBearingY(self)->int: ...
278+
@property
279+
defvertAdvance(self)->int: ...
253280
@property
254281
defbbox(self)->tuple[int,int,int,int]: ...

‎lib/matplotlib/tests/test_ft2font.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ def test_ft2font_invalid_args(tmp_path):
130130
# filename argument.
131131
withpytest.raises(TypeError,match='to a font file or a binary-mode file object'):
132132
ft2font.FT2Font(None)
133+
withpytest.raises(TypeError,match='to a font file or a binary-mode file object'):
134+
ft2font.FT2Font(object())# Not bytes or string, and has no read() method.
133135
file=tmp_path/'invalid-font.ttf'
134136
file.write_text('This is not a valid font file.')
135137
with (pytest.raises(TypeError,match='to a font file or a binary-mode file object'),
@@ -145,7 +147,7 @@ def test_ft2font_invalid_args(tmp_path):
145147
file=fm.findfont('DejaVu Sans')
146148

147149
# hinting_factor argument.
148-
withpytest.raises(TypeError,match='cannot be interpreted as an integer'):
150+
withpytest.raises(TypeError,match='incompatible constructor arguments'):
149151
ft2font.FT2Font(file,1.3)
150152
withpytest.raises(ValueError,match='hinting_factor must be greater than 0'):
151153
ft2font.FT2Font(file,0)
@@ -157,7 +159,7 @@ def test_ft2font_invalid_args(tmp_path):
157159
ft2font.FT2Font(file,_fallback_list=[0])# type: ignore[list-item]
158160

159161
# kerning_factor argument.
160-
withpytest.raises(TypeError,match='cannot be interpreted as an integer'):
162+
withpytest.raises(TypeError,match='incompatible constructor arguments'):
161163
ft2font.FT2Font(file,_kerning_factor=1.3)
162164

163165

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp