Skip to content

Commit fc71ffa

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 8eac437 commit fc71ffa

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
@@ -688,10 +688,6 @@ def test_point_size_method(self):
688688
self.assertRaises(ValueError, f.set_point_size, -500)
689689
self.assertRaises(TypeError, f.set_point_size, "15")
690690

691-
@unittest.skipIf(
692-
pygame.font.get_sdl_ttf_version() < (2, 0, 12),
693-
"outlines were added in SDL_TTF 2.0.12",
694-
)
695691
def test_outline_property(self):
696692
if pygame_font.__name__ == "pygame.ftfont":
697693
return # not a pygame.ftfont feature
@@ -723,25 +719,6 @@ def test_incorrect_type():
723719
self.assertRaises(ValueError, test_neg)
724720
self.assertRaises(TypeError, test_incorrect_type)
725721

726-
@unittest.skipIf(
727-
pygame.font.get_sdl_ttf_version() >= (2, 0, 12),
728-
"outlines were added in SDL_TTF 2.0.12",
729-
)
730-
def test_outline_property_stub(self):
731-
if pygame_font.__name__ == "pygame.ftfont":
732-
return # not a pygame.ftfont feature
733-
734-
pygame_font.init()
735-
font_path = os.path.join(
736-
os.path.split(pygame.__file__)[0], pygame_font.get_default_font()
737-
)
738-
f = pygame_font.Font(pathlib.Path(font_path), 25)
739-
740-
with self.assertRaises(pygame.error):
741-
f.outline = 0
742-
with self.assertRaises(pygame.error):
743-
_ = f.outline
744-
745722
def test_font_name(self):
746723
f = pygame_font.Font(None, 20)
747724
self.assertEqual(f.name, "FreeSans")
@@ -1078,6 +1055,7 @@ def test_font_property_should_raise_exception_after_quit(self):
10781055
("italic", True),
10791056
("underline", True),
10801057
("strikethrough", True),
1058+
("outline", 1),
10811059
]
10821060
skip_properties = set()
10831061
version = pygame.font.get_sdl_ttf_version()
@@ -1090,11 +1068,6 @@ def test_font_property_should_raise_exception_after_quit(self):
10901068
else:
10911069
skip_properties.add("point_size")
10921070

1093-
if version >= (2, 0, 12):
1094-
properties.append(("outline", 1))
1095-
else:
1096-
skip_properties.add("outline")
1097-
10981071
font = pygame_font.Font(None, 10)
10991072
actual_names = []
11001073

@@ -1191,17 +1164,15 @@ def query(
11911164
f.set_italic(italic)
11921165
f.set_underline(underline)
11931166
f.set_strikethrough(strikethrough)
1194-
if pygame.font.get_sdl_ttf_version() >= (2, 0, 12):
1195-
f.outline = outline
1167+
f.outline = outline
11961168
s = f.render(text, antialiase, (0, 0, 0))
11971169
screen.blit(s, (offset, y))
11981170
y += s.get_size()[1] + spacing
11991171
f.set_bold(False)
12001172
f.set_italic(False)
12011173
f.set_underline(False)
12021174
f.set_strikethrough(False)
1203-
if pygame.font.get_sdl_ttf_version() >= (2, 0, 12):
1204-
f.outline = 0
1175+
f.outline = 0
12051176
s = f.render("(some comparison text)", False, (0, 0, 0))
12061177
screen.blit(s, (offset, y))
12071178
pygame.display.flip()
@@ -1243,10 +1214,6 @@ def test_italic_underline(self):
12431214
def test_bold_strikethrough(self):
12441215
self.assertTrue(self.query(bold=True, strikethrough=True))
12451216

1246-
@unittest.skipIf(
1247-
pygame.font.get_sdl_ttf_version() < (2, 0, 12),
1248-
"outlines were added in SDL_TTF 2.0.12",
1249-
)
12501217
def test_outline(self):
12511218
self.assertTrue(self.query(outline=1))
12521219

0 commit comments

Comments
 (0)