summaryrefslogtreecommitdiffstats
path: root/Modules/stdwinmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-04-04 15:24:07 (GMT)
committerGuido van Rossum <guido@python.org>1991-04-04 15:24:07 (GMT)
commit50429a1d2c7894aeb857c5c3a8557bdee67f7fc9 (patch)
treed23799a0c0a1233ee511e7949d889c3e6bba269f /Modules/stdwinmodule.c
parent0bd2441e002ec0947071741a024e253da7355b02 (diff)
downloadcpython-50429a1d2c7894aeb857c5c3a8557bdee67f7fc9.zip
cpython-50429a1d2c7894aeb857c5c3a8557bdee67f7fc9.tar.gz
cpython-50429a1d2c7894aeb857c5c3a8557bdee67f7fc9.tar.bz2
More flexible font setting (mainly for the Mac).
Diffstat (limited to 'Modules/stdwinmodule.c')
-rw-r--r--Modules/stdwinmodule.c51
1 files changed, 47 insertions, 4 deletions
diff --git a/Modules/stdwinmodule.c b/Modules/stdwinmodule.c
index b55e58b..e00fc91 100644
--- a/Modules/stdwinmodule.c
+++ b/Modules/stdwinmodule.c
@@ -459,11 +459,54 @@ drawing_setfont(self, args)
drawingobject *self;
object *args;
{
- TEXTATTR saveattr, winattr;
- object *str;
- if (!getstrarg(args, &str))
+ object *font, *style;
+ int size;
+ if (args == NULL) {
+ err_badarg();
return NULL;
- wsetfont(getstringvalue(str));
+ }
+ if (is_stringobject(args)) {
+ font = args;
+ style = NULL;
+ size = 0;
+ }
+ else if (is_tupleobject(args)) {
+ int n = gettuplesize(args);
+ if (n == 2) {
+ if (!getstrintarg(args, &font, &size))
+ return NULL;
+ style = NULL;
+ }
+ else if (!getstrstrintarg(args, &font, &style, &size))
+ return NULL;
+ }
+ else {
+ err_badarg();
+ return NULL;
+ }
+ if (getstringsize(font) != 0)
+ wsetfont(getstringvalue(font));
+ if (style != NULL) {
+ switch (*getstringvalue(style)) {
+ case 'b':
+ wsetbold();
+ break;
+ case 'i':
+ wsetitalic();
+ break;
+ case 'o':
+ wsetbolditalic();
+ break;
+ case 'u':
+ wsetunderline();
+ break;
+ default:
+ wsetplain();
+ break;
+ }
+ }
+ if (size != 0)
+ wsetsize(size);
INCREF(None);
return None;
}