illume committed 4299d72

Fixes for set_icon and do_set_icon, to check if display is initialised
before setting the icon.
Added back missing read_unix_fontscache.
Thanks John Popplewell.

Comments (0)

Files changed (3)

 # BREAK = change breaks existing code
 # BUG	= fixed a bug that was (or could have been) crashing
+October 28, 2005
+    fix for do_set_icon when display not initialised. Thanks John Popplewell!
+    Added missing read_unix_fonts_cache function. Thanks again John Popplewell.
 October 24, 2005
     Add support for 64bit data types in surfarray.blit_array()
     return fonts
+def read_unix_fontscache(dir, file, fonts):
+    file = open(os.path.join(dir, file))
+    for line in file.readlines():
+        try:
+            font, num, vals = line.split(' ', 2)
+        except ValueError:
+            continue
+        font = font.replace('"', '')
+        if font[-4:].lower() not in [".ttf", ".ttc"]:
+            continue
+        font = os.path.join(dir, font)
+        vals = vals.split(':')
+        name = _simplename(vals[0][1:])
+        bold = vals[1].find('Bold') >= 0
+        italic = vals[1].find('Italic') >= 0
+        _addfont(name, bold, italic, font, fonts)
 #read the fonts from a unix 'fonts.cache-1' file
 def read_unix_fontsdir(dir, file, fonts):
 static void do_set_icon(PyObject *surface)
 	SDL_Surface* surf = PySurface_AsSurface(surface);
-	surf = PySurface_AsSurface(surface);
+        // NOTE: XXX: is this extra surf = line in here for some reason?
+	//surf = PySurface_AsSurface(surface);
 	SDL_WM_SetIcon(surf, NULL);
 	icon_was_set = 1;
 	PyObject* surface;
 	if(!PyArg_ParseTuple(arg, "O!", &PySurface_Type, &surface))
 		return NULL;
+        if(!PyGame_Video_AutoInit())
+               return RAISE(PyExc_SDLError, SDL_GetError());
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.