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

Re: [pygame] BUG, PATCH: Don't barf on invalid Unix font files



Thanks.

It's been applied to cvs.

On 11/22/05, Joe Wreschnig <piman@xxxxxxxxxxxxxx> wrote:
> A small patch to prevent a ValueError when getting a list of fonts on
> Unix; this fixes Debian bug #337120.
>
> --- pygame-1.7.1release.orig/lib/sysfont.py
> +++ pygame-1.7.1release/lib/sysfont.py
> @@ -149,7 +149,9 @@
>  #read the fonts from a unix 'fonts.dot' file
>  def read_unix_fontsdir(dir, file, fonts):
>      file = open(os.path.join(dir, file))
> -    numfonts = int(file.readline())
> +    try: numfonts = int(file.readline())
> +    except ValueError: return # probably not a font file
> +
>      for line in file.readlines():
>          font, descr = (line.split(' ', 1) + ['', ''])[:2]
>          if font[-4:].lower() not in [".ttf", ".ttc"]:
> --
> Joe Wreschnig <piman@xxxxxxxxxxxxxx>
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
>
> iD8DBQBDgnMiTFkUq7Drx3cRAmsgAJ4kR6SdQ7uWewfcZJPMQjptiRm5cwCgw7f6
> ikUEp6uFv0nVTXBmvKBZkTg=
> =NOGk
> -----END PGP SIGNATURE-----
>
>
>