[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] PATCH: [re-submitted] font lookup infine loop
- To: pygame-users@xxxxxxxx
- Subject: [pygame] PATCH: [re-submitted] font lookup infine loop
- From: Regis Desgroppes <rdesgroppes@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 18 Sep 2006 10:02:01 +0200
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Mon, 18 Sep 2006 04:04:21 -0400
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060628 Debian/1.7.8-1sarge7.1
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)