Commit d266bc70 authored by Guido van Rossum's avatar Guido van Rossum

More flexible font setting (mainly for the Mac).

parent f28996ed
...@@ -459,11 +459,54 @@ drawing_setfont(self, args) ...@@ -459,11 +459,54 @@ drawing_setfont(self, args)
drawingobject *self; drawingobject *self;
object *args; object *args;
{ {
TEXTATTR saveattr, winattr; object *font, *style;
object *str; int size;
if (!getstrarg(args, &str)) if (args == NULL) {
err_badarg();
return NULL; 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); INCREF(None);
return None; return None;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment