Anonymous avatar Anonymous committed abcdb14

Synced ft_wrap files with Pgreloaded.

Comments (0)

Files changed (3)

src/freetype/ft_wrap.c

     return error;
 }
 
-static unsigned long 
-_RWops_read(FT_Stream stream, unsigned long offset,
-	unsigned char *buffer, unsigned long count)
-{
-	SDL_RWops *src;
-
-	src = (SDL_RWops *)stream->descriptor.pointer;
-	SDL_RWseek(src, (int)offset, SEEK_SET);
-
-	if (count == 0)
-		return 0;
-
-	return SDL_RWread(src, buffer, 1, (int)count);
-}
 
 
 int _PGFT_Init_INTERNAL(FreeTypeInstance *ft, PyFreeTypeFont *font)
     return _PGFT_Init_INTERNAL(ft, font);
 }
 
+#ifdef HAVE_PYGAME_SDL_RWOPS
+static unsigned long 
+_RWops_read(FT_Stream stream, unsigned long offset,
+	unsigned char *buffer, unsigned long count)
+{
+	SDL_RWops *src;
+
+	src = (SDL_RWops *)stream->descriptor.pointer;
+	SDL_RWseek(src, (int)offset, SEEK_SET);
+
+	if (count == 0)
+		return 0;
+
+	return SDL_RWread(src, buffer, 1, (int)count);
+}
+
 int PGFT_TryLoadFont_RWops(FreeTypeInstance *ft, 
-        PyFreeTypeFont *font, SDL_RWops *src, int free_src,
-        int face_index)
+        PyFreeTypeFont *font, SDL_RWops *src, int face_index)
 {
     FT_Stream stream;
     int position;
 
     return _PGFT_Init_INTERNAL(ft, font);
 }
+#endif
 
 void
 PGFT_UnloadFont(FreeTypeInstance *ft, PyFreeTypeFont *font)
         free(PGFT_INTERNALS(font));
     }
 
-    free(font->id.open_args.pathname);
+    if (font->id.open_args.flags == FT_OPEN_STREAM)
+    {
+        free(font->id.open_args.pathname);
+    }
+    else if (font->id.open_args.flags == FT_OPEN_PATHNAME)
+    {
+        free(font->id.open_args.stream);
+    }
 }
 
 

src/freetype/ft_wrap.h

 const char *PGFT_GetError(FreeTypeInstance *);
 void        PGFT_Quit(FreeTypeInstance *);
 int         PGFT_Init(FreeTypeInstance **, int cache_size);
-int         PGFT_TryLoadFont_Filename(FreeTypeInstance *, 
-                PyFreeTypeFont *, const char *, int);
-int         PGFT_TryLoadFont_RWops(FreeTypeInstance *, 
-                PyFreeTypeFont *, SDL_RWops *, int, int);
-void        PGFT_UnloadFont(FreeTypeInstance *, PyFreeTypeFont *);
 
 int         PGFT_Face_GetHeight(FreeTypeInstance *ft, PyFreeTypeFont *);
 int         PGFT_Face_IsFixedWidth(FreeTypeInstance *ft, PyFreeTypeFont *);
 const char *PGFT_Face_GetName(FreeTypeInstance *ft, PyFreeTypeFont *);
 
+int         PGFT_TryLoadFont_Filename(FreeTypeInstance *, 
+                PyFreeTypeFont *, const char *, int);
+
+#ifdef HAVE_PYGAME_SDL_RWOPS
+int         PGFT_TryLoadFont_RWops(FreeTypeInstance *, 
+                PyFreeTypeFont *, SDL_RWops *, int);
+#endif
+
+void        PGFT_UnloadFont(FreeTypeInstance *, PyFreeTypeFont *);
+
 
 
 /********************************************************* Metrics management ****/

src/freetype/pgfreetype.h

 
 #define PGFT_PYGAME1_COMPAT
 #define HAVE_PYGAME_SDL_VIDEO
+#define HAVE_PYGAME_SDL_RWOPS
 
 #include "../pygame.h"
 #include "../pgcompat.h"
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 ProjectModifiedEvent.java.
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.