]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
More flexible font setting (mainly for the Mac).
authorGuido van Rossum <guido@python.org>
Thu, 4 Apr 1991 15:24:07 +0000 (15:24 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 4 Apr 1991 15:24:07 +0000 (15:24 +0000)
Modules/stdwinmodule.c

index b55e58b2b9b134f485f972d55798a347c7e3d804..e00fc91c334e4e148f1b1e09ca1e7c88af13c7e2 100644 (file)
@@ -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;
 }