Skip to content

Commit 3b15e7d

Browse files
committed
Add outline & docs
1 parent 6fbcb1a commit 3b15e7d

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

buildconfig/stubs/pygame/font.pyi

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class Font:
5656
def point_size(self) -> int: ...
5757
@point_size.setter
5858
def point_size(self, value: int) -> None: ...
59+
@property
60+
def outline(self) -> int: ...
5961
def __init__(self, filename: Optional[FileArg] = None, size: int = 20) -> None: ...
6062
def render(
6163
self,

docs/reST/ref/font.rst

+11
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,17 @@ solves no longer exists, it will likely be removed in the future.
306306

307307
.. ## Font.point_size ##
308308
309+
.. attribute:: outline
310+
311+
| :sl:`Gets or sets the font's outline size`
312+
| :sg:`outline -> int`
313+
314+
Returns the size of the outline.
315+
316+
.. versionadded:: 2.5.0
317+
318+
.. ## Font.outline ##
319+
309320
.. method:: render
310321

311322
| :sl:`draw text on a new Surface`

src_c/doc/font_doc.h

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define DOC_FONT_FONT_STRIKETHROUGH "strikethrough -> bool\nGets or sets whether the font should be rendered with a strikethrough."
1818
#define DOC_FONT_FONT_ALIGN "align -> int\nSet how rendered text is aligned when given a wrap length."
1919
#define DOC_FONT_FONT_POINTSIZE "point_size -> int\nGets or sets the font's point size"
20+
#define DOC_FONT_FONT_OUTLINE "outline -> int\nGets or sets the font's outline size"
2021
#define DOC_FONT_FONT_RENDER "render(text, antialias, color, bgcolor=None, wraplength=0) -> Surface\ndraw text on a new Surface"
2122
#define DOC_FONT_FONT_SIZE "size(text, /) -> (width, height)\ndetermine the amount of space needed to render text"
2223
#define DOC_FONT_FONT_SETUNDERLINE "set_underline(bool, /) -> None\ncontrol if text is rendered with an underline"

src_c/font.c

+22
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,26 @@ font_getter_style_name(PyObject *self, void *closure)
829829
return PyUnicode_FromString(font_style_name ? font_style_name : "");
830830
}
831831

832+
static int
833+
font_setter_outline(PyObject *self, PyObject *value, void *closure)
834+
{
835+
TTF_Font *font = PyFont_AsFont(self);
836+
int val;
837+
838+
DEL_ATTR_NOT_SUPPORTED_CHECK("outline", value);
839+
840+
val = PyLong_AsLong(value);
841+
842+
TTF_SetFontOutline(font, val);
843+
return 0;
844+
}
845+
846+
static PyObject *
847+
font_getter_outline(PyObject *self, void *closure)
848+
{
849+
return PyLong_FromLong(TTF_GetFontOutline(PyFont_AsFont(self)));
850+
}
851+
832852
static PyObject *
833853
font_metrics(PyObject *self, PyObject *textobj)
834854
{
@@ -1058,6 +1078,8 @@ static PyGetSetDef font_getsets[] = {
10581078
DOC_FONT_FONT_ALIGN, NULL},
10591079
{"point_size", (getter)font_getter_point_size,
10601080
(setter)font_setter_point_size, DOC_FONT_FONT_POINTSIZE, NULL},
1081+
{"outline", (getter)font_getter_outline, (setter)font_setter_outline,
1082+
"TODO", NULL},
10611083
{NULL, NULL, NULL, NULL, NULL}};
10621084

10631085
static PyMethodDef font_methods[] = {

0 commit comments

Comments
 (0)