Commits

Anonymous committed 1ea14a6

Fixed returning the original surface when doing FT.render() on existing surfaces.

Comments (0)

Files changed (2)

examples/freetype/sdlfont.py

 
     screen = video.set_mode (320, 240)
     screen.fill (pygame2.Color (200, 200, 200))
-    w, h = font.render("Hello", pygame2.Color(100, 100, 100), None, screen, 10, 10, 24)
+    w, h, _ = font.render("Hello", pygame2.Color(100, 100, 100), None, screen, 10, 10, 24)
 
-    w, h = font.render("Hello", pygame2.Color(100, 100, 100), None, screen, 10, 40, 48)
+    w, h, _ = font.render("Hello", pygame2.Color(100, 100, 100), None, screen, 10, 40, 48)
 
     w, g, buf = font.render("Hello World, Jay",
             pygame2.Color(100, 200, 32),

src/freetype/ft_font.c

             goto _finish;
         }
 
+        /* 
+         * If we return a new reference to our target surface, we
+         * need to increase it's refcount first.
+         */
+        Py_INCREF(target_surf); 
         rtuple = Py_BuildValue("(iiO)", width, height, target_surf);
     }
     else