Skip to content

Commit 52a823b

Browse files
authored
Merge pull request #383 from ppizarror/fix-font-arg
Fix font argument as pygame.Font
2 parents 40e8275 + 3d30d0d commit 52a823b

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright 2017-2021 Pablo Pizarro R. @ppizarror
3+
Copyright 2017 Pablo Pizarro R. @ppizarror
44

55
Permission is hereby granted, free of charge, to any person obtaining a
66
copy of this software and associated documentation files (the "Software"),

pygame_menu/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
'zPaw'
116116

117117
]
118-
__copyright__ = 'Copyright 2017-2021 Pablo Pizarro R. @ppizarror'
118+
__copyright__ = 'Copyright 2017 Pablo Pizarro R. @ppizarror'
119119
__description__ = 'A menu for pygame. Simple, and easy to use'
120120
__email__ = '[email protected]'
121121
__keywords__ = 'pygame menu menus gui widget input button pygame-menu image sound ui'

pygame_menu/_widgetmanager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def _filter_widget_attributes(self, kwargs: Dict) -> Dict[str, Any]:
177177
# font_name
178178
font_name = kwargs.pop('font_name', self._theme.widget_font)
179179
assert_font(font_name)
180-
attributes['font_name'] = str(font_name)
180+
attributes['font_name'] = font_name
181181

182182
# font_shadow
183183
font_shadow = kwargs.pop('font_shadow', self._theme.widget_font_shadow)

pygame_menu/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ def __str__(self) -> str:
3434
patch = property(lambda self: self[2])
3535

3636

37-
vernum = Version(4, 2, 3)
37+
vernum = Version(4, 2, 4)
3838
ver = str(vernum)
3939
rev = ''

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
License:
99
-------------------------------------------------------------------------------
1010
The MIT License (MIT)
11-
Copyright 2017-2021 Pablo Pizarro R. @ppizarror
11+
Copyright 2017 Pablo Pizarro R. @ppizarror
1212
1313
Permission is hereby granted, free of charge, to any person obtaining a
1414
copy of this software and associated documentation files (the "Software"),

test/test_font.py

+16
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from pathlib import Path
1212
from test._utils import MenuUtils, BaseTest
1313

14+
import pygame
1415
import pygame_menu
1516

1617

@@ -45,3 +46,18 @@ def test_system_load(self) -> None:
4546

4647
# Modify the system font and load, this will raise an exception
4748
self.assertRaises(ValueError, lambda: MenuUtils.get_font('invalid font', 5))
49+
50+
def test_font_argument(self) -> None:
51+
"""
52+
Test font pass as argument.
53+
"""
54+
menu = MenuUtils.generic_menu()
55+
f0 = pygame.font.SysFont(pygame.font.get_fonts()[0], 20)
56+
57+
# Widget with custom font
58+
text = menu.add.text_input('First name: ', default='John', font_name=f0)
59+
self.assertEqual(text.get_font_info()['name'], f0)
60+
61+
# Test widgets with default font, check are equal
62+
text2 = menu.add.text_input('First name: ', default='John')
63+
self.assertEqual(text2.get_font_info()['name'], menu.get_theme().widget_font)

0 commit comments

Comments
 (0)