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

[pygame] PATCH: [re-submitted] 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.

--- 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)