Skip to content

Commit de2473f

Browse files
committed
Removed Font outline getters/setters.
Preferring properties for new values.
1 parent 01aacde commit de2473f

File tree

5 files changed

+2
-99
lines changed

5 files changed

+2
-99
lines changed

buildconfig/stubs/pygame/font.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ class Font:
9191
def set_direction(self, direction: int) -> None: ...
9292
def get_point_size(self) -> int: ...
9393
def set_point_size(self, val: int, /) -> None: ...
94-
def get_outline(self) -> int: ...
95-
def set_outline(self, val: int, /) -> None: ...
9694

9795
@deprecated("Use `Font` instead (FontType is an old alias)")
9896
class FontType(Font): ...

docs/reST/ref/font.rst

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -579,32 +579,6 @@ solves no longer exists, it will likely be removed in the future.
579579

580580
.. ## Font.get_point_size ##
581581
582-
.. method:: set_outline
583-
584-
| :sl:`set the outline value of the font`
585-
| :sg:`set_outline(size, /) -> None`
586-
587-
Sets the outline value of the font.
588-
589-
.. note:: This is the same as the :attr:`outline` attribute.
590-
591-
.. versionadded:: 2.5.6
592-
593-
.. ## Font.set_outline ##
594-
595-
.. method:: get_outline
596-
597-
| :sl:`get the outline value of the font`
598-
| :sg:`get_outline() -> int`
599-
600-
Returns the outline value of the font.
601-
602-
.. note:: This is the same as the :attr:`outline` attribute.
603-
604-
.. versionadded:: 2.5.6
605-
606-
.. ## Font.get_outline ##
607-
608582
.. method:: get_ascent
609583

610584
| :sl:`get the ascent of the font`

src_c/doc/font_doc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
#define DOC_FONT_FONT_GETHEIGHT "get_height() -> int\nget the height of the font"
3535
#define DOC_FONT_FONT_SETPOINTSIZE "set_point_size(size, /) -> None\nset the point size of the font"
3636
#define DOC_FONT_FONT_GETPOINTSIZE "get_point_size() -> int\nget the point size of the font"
37-
#define DOC_FONT_FONT_SETOUTLINE "set_outline(size, /) -> None\nset the outline value of the font"
38-
#define DOC_FONT_FONT_GETOUTLINE "get_outline() -> int\nget the outline value of the font"
3937
#define DOC_FONT_FONT_GETASCENT "get_ascent() -> int\nget the ascent of the font"
4038
#define DOC_FONT_FONT_GETDESCENT "get_descent() -> int\nget the descent of the font"
4139
#define DOC_FONT_FONT_SETSCRIPT "set_script(str, /) -> None\nset the script code for text shaping"

src_c/font.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -952,25 +952,6 @@ font_setter_outline(PyObject *self, PyObject *value, void *closure)
952952
#endif
953953
}
954954

955-
static PyObject *
956-
font_get_outline(PyObject *self, PyObject *_null)
957-
{
958-
/* logic is identical to the getter, aside from the closure in the
959-
* signature */
960-
return font_getter_outline(self, NULL);
961-
}
962-
963-
static PyObject *
964-
font_set_outline(PyObject *self, PyObject *arg)
965-
{
966-
/* logic is identical to the setter, but we need to massage the return type
967-
from int to PyObject*) */
968-
if (font_setter_outline(self, arg, NULL) < 0) {
969-
return NULL;
970-
}
971-
Py_RETURN_NONE;
972-
}
973-
974955
static PyObject *
975956
font_getter_name(PyObject *self, void *closure)
976957
{
@@ -1264,8 +1245,6 @@ static PyMethodDef font_methods[] = {
12641245
DOC_FONT_FONT_GETSTRIKETHROUGH},
12651246
{"set_strikethrough", font_set_strikethrough, METH_O,
12661247
DOC_FONT_FONT_SETSTRIKETHROUGH},
1267-
{"get_outline", font_get_outline, METH_NOARGS, DOC_FONT_FONT_GETOUTLINE},
1268-
{"set_outline", font_set_outline, METH_O, DOC_FONT_FONT_SETOUTLINE},
12691248
{"get_point_size", font_get_ptsize, METH_NOARGS,
12701249
DOC_FONT_FONT_GETPOINTSIZE},
12711250
{"set_point_size", font_set_ptsize, METH_O, DOC_FONT_FONT_SETPOINTSIZE},

test/font_test.py

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -739,45 +739,6 @@ def test_outline_property_stub(self):
739739
with self.assertRaises(pygame.error):
740740
_ = f.outline
741741

742-
@unittest.skipIf(
743-
pygame.font.get_sdl_ttf_version() < (2, 0, 12),
744-
"outlines were added in SDL_TTF 2.0.12",
745-
)
746-
def test_outline_method(self):
747-
if pygame_font.__name__ == "pygame.ftfont":
748-
return # not a pygame.ftfont feature
749-
750-
pygame_font.init()
751-
font_path = os.path.join(
752-
os.path.split(pygame.__file__)[0], pygame_font.get_default_font()
753-
)
754-
f = pygame_font.Font(pathlib.Path(font_path), 25)
755-
756-
val0 = f.get_outline()
757-
self.assertIsInstance(val0, int)
758-
self.assertGreaterEqual(val0, 0)
759-
760-
f.set_outline(5)
761-
self.assertEqual(5, f.get_outline())
762-
self.assertRaises(ValueError, f.set_outline, -1)
763-
self.assertRaises(TypeError, f.set_outline, "2")
764-
765-
@unittest.skipIf(
766-
pygame.font.get_sdl_ttf_version() >= (2, 0, 12),
767-
"outlines were added in SDL_TTF 2.0.12",
768-
)
769-
def test_outline_method_stub(self):
770-
if pygame_font.__name__ == "pygame.ftfont":
771-
return # not a pygame.ftfont feature
772-
773-
pygame_font.init()
774-
font_path = os.path.join(
775-
os.path.split(pygame.__file__)[0], pygame_font.get_default_font()
776-
)
777-
f = pygame_font.Font(pathlib.Path(font_path), 25)
778-
779-
self.assertRaises(pygame.error, f.get_outline)
780-
self.assertRaises(pygame.error, f.set_outline, 1)
781742

782743
def test_font_name(self):
783744
f = pygame_font.Font(None, 20)
@@ -1028,13 +989,6 @@ def test_font_method_should_raise_exception_after_quit(self):
1028989
skip_methods = set()
1029990
version = pygame.font.get_sdl_ttf_version()
1030991

1031-
if version >= (2, 0, 12):
1032-
methods.append(("get_outline", ()))
1033-
methods.append(("set_outline", (2,)))
1034-
else:
1035-
skip_methods.add("get_outline")
1036-
skip_methods.add("set_outline")
1037-
1038992
if version >= (2, 0, 18):
1039993
methods.append(("get_point_size", ()))
1040994
methods.append(("set_point_size", (34,)))
@@ -1236,7 +1190,7 @@ def query(
12361190
f.set_underline(underline)
12371191
f.set_strikethrough(strikethrough)
12381192
if pygame.font.get_sdl_ttf_version() >= (2, 0, 12):
1239-
f.set_outline(outline)
1193+
f.outline = outline
12401194
s = f.render(text, antialiase, (0, 0, 0))
12411195
screen.blit(s, (offset, y))
12421196
y += s.get_size()[1] + spacing
@@ -1245,7 +1199,7 @@ def query(
12451199
f.set_underline(False)
12461200
f.set_strikethrough(False)
12471201
if pygame.font.get_sdl_ttf_version() >= (2, 0, 12):
1248-
f.set_outline(0)
1202+
f.outline = 0
12491203
s = f.render("(some comparison text)", False, (0, 0, 0))
12501204
screen.blit(s, (offset, y))
12511205
pygame.display.flip()

0 commit comments

Comments
 (0)