Skip to content

Commit 0cd38a8

Browse files
committed
Removed checks for SDL_TTF < 2.0.12 in outline code.
We depend on SDL_TTF >= 2.0.15, so this is not needed.
1 parent 90bd615 commit 0cd38a8

File tree

2 files changed

+11
-54
lines changed

2 files changed

+11
-54
lines changed

src_c/font.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -908,14 +908,8 @@ font_getter_outline(PyObject *self, void *closure)
908908
return RAISE_FONT_QUIT_ERROR();
909909
}
910910

911-
#if SDL_TTF_VERSION_ATLEAST(2, 0, 12)
912911
TTF_Font *font = PyFont_AsFont(self);
913912
return PyLong_FromLong(TTF_GetFontOutline(font));
914-
#else
915-
return RAISE(pgExc_SDLError,
916-
"pygame.font not compiled with a new enough SDL_ttf version. "
917-
"Needs SDL_ttf 2.0.12 or above.");
918-
#endif
919913
}
920914

921915
static int
@@ -924,15 +918,10 @@ font_setter_outline(PyObject *self, PyObject *value, void *closure)
924918
if (!PgFont_GenerationCheck(self)) {
925919
RAISE_FONT_QUIT_ERROR_RETURN(-1);
926920
}
927-
#if SDL_TTF_VERSION_ATLEAST(2, 0, 12)
928921
TTF_Font *font = PyFont_AsFont(self);
929922

930923
DEL_ATTR_NOT_SUPPORTED_CHECK("outline", value);
931924

932-
if (!PyLong_Check(value)) {
933-
PyErr_SetString(PyExc_TypeError, "outline must be an integer");
934-
return -1;
935-
}
936925
long val = PyLong_AsLong(value);
937926
if (val == -1 && PyErr_Occurred()) {
938927
return -1;
@@ -941,15 +930,16 @@ font_setter_outline(PyObject *self, PyObject *value, void *closure)
941930
PyErr_SetString(PyExc_ValueError, "outline must be >= 0");
942931
return -1;
943932
}
944-
TTF_SetFontOutline(font, (int)val);
945-
return 0;
933+
934+
#if SDL_TTF_VERSION_ATLEAST(3, 0, 0)
935+
if (!TTF_SetFontOutline(font, (int)val)) {
936+
PyErr_SetString(pgExc_SDLError, SDL_GetError());
937+
return -1;
938+
}
946939
#else
947-
PyErr_SetString(
948-
pgExc_SDLError,
949-
"pygame.font not compiled with a new enough SDL_ttf version. Needs "
950-
"SDL_ttf 2.0.12 or above.");
951-
return -1;
940+
TTF_SetFontOutline(font, (int)val);
952941
#endif
942+
return 0;
953943
}
954944

955945
static PyObject *

test/font_test.py

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -685,10 +685,6 @@ def test_point_size_method(self):
685685
self.assertRaises(ValueError, f.set_point_size, -500)
686686
self.assertRaises(TypeError, f.set_point_size, "15")
687687

688-
@unittest.skipIf(
689-
pygame.font.get_sdl_ttf_version() < (2, 0, 12),
690-
"outlines were added in SDL_TTF 2.0.12",
691-
)
692688
def test_outline_property(self):
693689
if pygame_font.__name__ == "pygame.ftfont":
694690
return # not a pygame.ftfont feature
@@ -720,25 +716,6 @@ def test_incorrect_type():
720716
self.assertRaises(ValueError, test_neg)
721717
self.assertRaises(TypeError, test_incorrect_type)
722718

723-
@unittest.skipIf(
724-
pygame.font.get_sdl_ttf_version() >= (2, 0, 12),
725-
"outlines were added in SDL_TTF 2.0.12",
726-
)
727-
def test_outline_property_stub(self):
728-
if pygame_font.__name__ == "pygame.ftfont":
729-
return # not a pygame.ftfont feature
730-
731-
pygame_font.init()
732-
font_path = os.path.join(
733-
os.path.split(pygame.__file__)[0], pygame_font.get_default_font()
734-
)
735-
f = pygame_font.Font(pathlib.Path(font_path), 25)
736-
737-
with self.assertRaises(pygame.error):
738-
f.outline = 0
739-
with self.assertRaises(pygame.error):
740-
_ = f.outline
741-
742719
def test_font_name(self):
743720
f = pygame_font.Font(None, 20)
744721
self.assertEqual(f.name, "FreeSans")
@@ -1075,6 +1052,7 @@ def test_font_property_should_raise_exception_after_quit(self):
10751052
("italic", True),
10761053
("underline", True),
10771054
("strikethrough", True),
1055+
("outline", 1),
10781056
]
10791057
skip_properties = set()
10801058
version = pygame.font.get_sdl_ttf_version()
@@ -1087,11 +1065,6 @@ def test_font_property_should_raise_exception_after_quit(self):
10871065
else:
10881066
skip_properties.add("point_size")
10891067

1090-
if version >= (2, 0, 12):
1091-
properties.append(("outline", 1))
1092-
else:
1093-
skip_properties.add("outline")
1094-
10951068
font = pygame_font.Font(None, 10)
10961069
actual_names = []
10971070

@@ -1188,17 +1161,15 @@ def query(
11881161
f.set_italic(italic)
11891162
f.set_underline(underline)
11901163
f.set_strikethrough(strikethrough)
1191-
if pygame.font.get_sdl_ttf_version() >= (2, 0, 12):
1192-
f.outline = outline
1164+
f.outline = outline
11931165
s = f.render(text, antialiase, (0, 0, 0))
11941166
screen.blit(s, (offset, y))
11951167
y += s.get_size()[1] + spacing
11961168
f.set_bold(False)
11971169
f.set_italic(False)
11981170
f.set_underline(False)
11991171
f.set_strikethrough(False)
1200-
if pygame.font.get_sdl_ttf_version() >= (2, 0, 12):
1201-
f.outline = 0
1172+
f.outline = 0
12021173
s = f.render("(some comparison text)", False, (0, 0, 0))
12031174
screen.blit(s, (offset, y))
12041175
pygame.display.flip()
@@ -1240,10 +1211,6 @@ def test_italic_underline(self):
12401211
def test_bold_strikethrough(self):
12411212
self.assertTrue(self.query(bold=True, strikethrough=True))
12421213

1243-
@unittest.skipIf(
1244-
pygame.font.get_sdl_ttf_version() < (2, 0, 12),
1245-
"outlines were added in SDL_TTF 2.0.12",
1246-
)
12471214
def test_outline(self):
12481215
self.assertTrue(self.query(outline=1))
12491216

0 commit comments

Comments
 (0)