[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] PATCH: font lookup infine loop



Hello,
When a font with normal style exists in your system but not with the style you are looking for, an infinite loop may occur.
This bug is in pygame 1.7 release. It occurs with various fonts (e.g. Courier Bold) at least on Debian & RedHat GNU/Linux powered computers.
It is due to the fact that, in the loop (see SysFont function), "fontname" (font with the expected style) is compared to "plainname" (font with normal style) even if fontname is None. Moreover, if fontname is None, it is not reassigned to plainname (due to the "elif") what prevents exiting from the loop.
The attached patch consists in first testing if there's no fontname before comparing fontname to plainname.
Could you consider applying this patch in the next release ?
Thank you,
Regis.


--
------------------------------------------------------------------------
Regis C. Desgroppes, software geek
Parkeon (former Schlumberger e-City) - AFC - R&D
e-mail: rdesgroppes@xxxxxxxxxxxxxxxxxxxx
phone : +33 (0)3 81 54 68 73
fax : +33 (0)3 81 54 49 90
------------------------------------------------------------------------
C++ mailing: Scott Meyers <http://groups.yahoo.com/group/scott_meyers/join>, Herb Sutter <http://groups.yahoo.com/group/herb_sutter/join>, Boost users <http://groups.yahoo.com/group/Boost-Users/join>
no software patents <http://www.nosoftwarepatents.com>
Given enough eyeballs, all bugs are shallow. (Eric S Raymond)
--- sysfont.py.orig	2006-06-13 06:36:27.000000000 +0200
+++ sysfont.py	2006-09-08 15:03:03.000000000 +0200
@@ -269,11 +269,11 @@
                 while not fontname:
                     plainname = styles.get((False, False))
                     fontname = styles.get((bold, italic))
-                    if plainname != fontname:
+                    if not fontname:
+                        fontname = plainname
+                    elif plainname != fontname:
                         gotbold = bold
                         gotitalic = italic
-                    elif not fontname:
-                        fontname = plainname
             if fontname: break
 
     font = pygame.font.Font(fontname, size)