Skip to content

Commit 16b5976

Browse files
committed
Removed Font outline getters/setters.
Preferring properties for new values.
1 parent c73ae02 commit 16b5976

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
@@ -89,8 +89,6 @@ class Font:
8989
def set_direction(self, direction: int) -> None: ...
9090
def get_point_size(self) -> int: ...
9191
def set_point_size(self, val: int, /) -> None: ...
92-
def get_outline(self) -> int: ...
93-
def set_outline(self, val: int, /) -> None: ...
9492

9593
@deprecated("Use `Font` instead (FontType is an old alias)")
9694
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
@@ -742,45 +742,6 @@ def test_outline_property_stub(self):
742742
with self.assertRaises(pygame.error):
743743
_ = f.outline
744744

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

785746
def test_font_name(self):
786747
f = pygame_font.Font(None, 20)
@@ -1031,13 +992,6 @@ def test_font_method_should_raise_exception_after_quit(self):
1031992
skip_methods = set()
1032993
version = pygame.font.get_sdl_ttf_version()
1033994

1034-
if version >= (2, 0, 12):
1035-
methods.append(("get_outline", ()))
1036-
methods.append(("set_outline", (2,)))
1037-
else:
1038-
skip_methods.add("get_outline")
1039-
skip_methods.add("set_outline")
1040-
1041995
if version >= (2, 0, 18):
1042996
methods.append(("get_point_size", ()))
1043997
methods.append(("set_point_size", (34,)))
@@ -1239,7 +1193,7 @@ def query(
12391193
f.set_underline(underline)
12401194
f.set_strikethrough(strikethrough)
12411195
if pygame.font.get_sdl_ttf_version() >= (2, 0, 12):
1242-
f.set_outline(outline)
1196+
f.outline = outline
12431197
s = f.render(text, antialiase, (0, 0, 0))
12441198
screen.blit(s, (offset, y))
12451199
y += s.get_size()[1] + spacing
@@ -1248,7 +1202,7 @@ def query(
12481202
f.set_underline(False)
12491203
f.set_strikethrough(False)
12501204
if pygame.font.get_sdl_ttf_version() >= (2, 0, 12):
1251-
f.set_outline(0)
1205+
f.outline = 0
12521206
s = f.render("(some comparison text)", False, (0, 0, 0))
12531207
screen.blit(s, (offset, y))
12541208
pygame.display.flip()

0 commit comments

Comments
 (0)