Skip to content

Commit 12141bf

Browse files
authored
Improve SysFont documentation and add font verification warning. Closes #2643 (#3373)
* Improve SysFont documentation and add font verification warning * Refactor font verification message for correct formatting in SysFont function
1 parent a6bc7f3 commit 12141bf

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src_py/sysfont.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,13 @@ def SysFont(name, size, bold=False, italic=False, constructor=None):
437437
fall back on the builtin pygame font if the given font
438438
is not found.
439439
440-
Name can also be an iterable of font names, a string of
441-
comma-separated font names, or a bytes of comma-separated
442-
font names, in which case the set of names will be searched
443-
in order. Pygame uses a small set of common font aliases. If the
444-
specific font you ask for is not available, a reasonable
445-
alternative may be used.
440+
Name shall be supplied as the plain font name without
441+
file extensions. Name can also be an iterable of font names,
442+
a string of comma-separated font names, or a bytes of
443+
comma-separated font names, in which case the set of names
444+
will be searched in order. Pygame uses a small set of common
445+
font aliases. If the specific font you ask for is not available,
446+
a reasonable alternative may be used.
446447
447448
If optional constructor is provided, it must be a function with
448449
signature constructor(fontpath, size, bold, italic) which returns
@@ -469,12 +470,16 @@ def SysFont(name, size, bold=False, italic=False, constructor=None):
469470
break
470471

471472
else:
473+
font_verification_message = (
474+
"Verify your font name input. Using the default font instead."
475+
)
476+
472477
if len(name) > 1:
473478
names = "', '".join(name)
474479
warnings.warn(
475480
"None of the specified system fonts "
476481
f"('{names}') could be found. "
477-
"Using the default font instead."
482+
f"{font_verification_message}"
478483
)
479484
else:
480485
# Identifies the closest matches to the font provided by
@@ -490,7 +495,7 @@ def SysFont(name, size, bold=False, italic=False, constructor=None):
490495
warnings.warn(
491496
f"The system font '{name[0]}' couldn't be "
492497
f"found. {match_text}"
493-
"Using the default font instead."
498+
f"{font_verification_message}"
494499
)
495500
else:
496501
fontname = None

0 commit comments

Comments
 (0)