Skip to content

Commit ed59a94

Browse files
committed
Update font tests and docs
1 parent 0aff9f3 commit ed59a94

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

docs/reST/ref/font.rst

+1
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ solves no longer exists, it will likely be removed in the future.
518518
519519
Set the height in pixels for a line of text with the font. When rendering
520520
multiple lines of text this refers to the amount of space between lines.
521+
The value must be non-negative.
521522

522523
.. versionadded:: 2.5.4
523524

src_c/doc/font_doc.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
#define DOC_FONT_FONT_METRICS "metrics(text, /) -> list\ngets the metrics for each character in the passed string"
3030
#define DOC_FONT_FONT_GETITALIC "get_italic() -> bool\ncheck if the text will be rendered italic"
3131
#define DOC_FONT_FONT_GETLINESIZE "get_linesize() -> int\nget the line space of the font text"
32-
#define DOC_FONT_FONT_SETLINESIZE "set_linesize(linesize) -> int\nset the line space of the font text"
32+
#define DOC_FONT_FONT_SETLINESIZE "set_linesize(linesize) -> None\nset the line space of the font text"
3333
#define DOC_FONT_FONT_GETHEIGHT "get_height() -> int\nget the height of the font"
34-
#define DOC_FONT_FONT_SETPOINTSIZE "set_point_size(size, /) -> int\nset the point size of the font"
34+
#define DOC_FONT_FONT_SETPOINTSIZE "set_point_size(size, /) -> None\nset the point size of the font"
3535
#define DOC_FONT_FONT_GETPOINTSIZE "get_point_size() -> int\nget the point size of the font"
3636
#define DOC_FONT_FONT_GETASCENT "get_ascent() -> int\nget the ascent of the font"
3737
#define DOC_FONT_FONT_GETDESCENT "get_descent() -> int\nget the descent of the font"

test/font_test.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# -*- coding: utf-8 -*-
2-
import sys
3-
import os
42
import io
5-
import unittest
3+
import os
64
import pathlib
75
import platform
6+
import sys
7+
import unittest
88

99
import pygame
1010
from pygame import font as pygame_font # So font can be replaced with ftfont
@@ -409,6 +409,10 @@ def test_set_linesize(self):
409409
# check invalid linesize
410410
with self.assertRaises(ValueError):
411411
f.set_linesize(-1)
412+
with self.assertRaises(OverflowError):
413+
f.set_linesize(2**100)
414+
with self.assertRaises(TypeError):
415+
f.set_linesize(12.0)
412416

413417
def test_metrics(self):
414418
# Ensure bytes decoding works correctly. Can only compare results

0 commit comments

Comments
 (0)