Skip to content

Commit 5893923

Browse files
committed
Add stub for sysfont
1 parent 2a157a1 commit 5893923

File tree

4 files changed

+32
-16
lines changed

4 files changed

+32
-16
lines changed

buildconfig/stubs/mypy_allow_list.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,4 @@ pygame\.newbuffer
2525
pygame\.pkgdata
2626
pygame\.pypm
2727
pygame\._sdl2\.mixer
28-
pygame\.sysfont.*
2928
pygame\.docs.*

buildconfig/stubs/pygame/font.pyi

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
from collections.abc import Callable, Hashable, Iterable
21
from typing import Literal, Optional, Union
32

3+
from typing_extensions import deprecated # added in 3.13
4+
45
from pygame.surface import Surface
6+
from pygame.sysfont import (
7+
get_fonts as get_fonts,
8+
match_font as match_font,
9+
SysFont as SysFont,
10+
)
511
from pygame.typing import ColorLike, FileLike
6-
from typing_extensions import deprecated # added in 3.13
712

813
# TODO: Figure out a way to type this attribute such that mypy knows it's not
914
# always defined at runtime
@@ -14,19 +19,6 @@ def quit() -> None: ...
1419
def get_init() -> bool: ...
1520
def get_sdl_ttf_version(linked: bool = True) -> tuple[int, int, int]: ...
1621
def get_default_font() -> str: ...
17-
def get_fonts() -> list[str]: ...
18-
def match_font(
19-
name: Union[str, bytes, Iterable[Union[str, bytes]]],
20-
bold: Hashable = False,
21-
italic: Hashable = False,
22-
) -> str: ...
23-
def SysFont(
24-
name: Union[str, bytes, Iterable[Union[str, bytes]], None],
25-
size: int,
26-
bold: Hashable = False,
27-
italic: Hashable = False,
28-
constructor: Optional[Callable[[Optional[str], int, bool, bool], Font]] = None,
29-
) -> Font: ...
3022

3123
class Font:
3224
@property

buildconfig/stubs/pygame/sysfont.pyi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from collections.abc import Callable, Hashable, Iterable
2+
from typing import Optional, Union
3+
4+
from pygame.font import Font
5+
6+
def get_fonts() -> list[str]: ...
7+
def match_font(
8+
name: Union[str, bytes, Iterable[Union[str, bytes]]],
9+
bold: Hashable = False,
10+
italic: Hashable = False,
11+
) -> str: ...
12+
def SysFont(
13+
name: Union[str, bytes, Iterable[Union[str, bytes]], None],
14+
size: int,
15+
bold: Hashable = False,
16+
italic: Hashable = False,
17+
constructor: Optional[Callable[[Optional[str], int, bool, bool], Font]] = None,
18+
) -> Font: ...

src_py/sysfont.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,3 +561,10 @@ def match_font(name, bold=False, italic=False):
561561
break
562562

563563
return fontname
564+
565+
566+
__all__ = [
567+
"get_fonts",
568+
"match_font",
569+
"SysFont",
570+
]

0 commit comments

Comments
 (0)