Commits

Lenard Lindstrom committed 9cac2ec

Partial fix of issue #144

Issue #144 uncovered two problems. This changeset addresses the first:
incorrect converion from FT_Fixed to an integer for an x86_64 Pygame build.
This patch ensures all masks within the FX_* macros declared in ft_wrap.h
are long identifiers, to match FT_Fixed.

Also, to be safe, surface width and height are redeclared 'int' within
ft_render.c for consistency with the SDL_CreateRGBSurface arguments.

Comments (0)

Files changed (2)

src/freetype/ft_render.c

 
 void
 _PGFT_GetRenderMetrics(const FontRenderMode *mode, FontText *text,
-                       unsigned *w, unsigned *h, FT_Vector *offset,
+                       int *w, int *h, FT_Vector *offset,
                        FT_Pos *underline_top, FT_Fixed *underline_size)
 {
     FT_Pos min_x = text->min_x;
 
     offset->x = -min_x;
     offset->y = -min_y;
-    *w = (unsigned)FX6_TRUNC(FX6_CEIL(max_x) - FX6_FLOOR(min_x));
-    *h = (unsigned)FX6_TRUNC(FX6_CEIL(max_y) - FX6_FLOOR(min_y));
+    *w = (int)FX6_TRUNC(FX6_CEIL(max_x) - FX6_FLOOR(min_x));
+    *h = (int)FX6_TRUNC(FX6_CEIL(max_y) - FX6_FLOOR(min_y));
 }
 
 
     int locked = 0;
     FT_UInt32 fillcolor;
     SDL_Surface *surface = 0;
-    FT_UInt32 bits_per_pixel =
+    int bits_per_pixel =
         (bgcolor || mode->render_flags & FT_RFLAG_ANTIALIAS) ? 32 : 8;
     FT_UInt32 surface_flags = SDL_SWSURFACE;
 
     FontSurface font_surf;
     FontText *font_text;
-    unsigned width;
-    unsigned height;
+    int width;
+    int height;
     FT_Vector offset;
     FT_Pos underline_top;
     FT_Fixed underline_size;

src/freetype/ft_wrap.h

  **********************************************************/
 
 /* Fixed point (26.6) math macros */
-#define FX6_ONE 64
-#define FX16_ONE 65536
-#define FX6_MIN ((FT_Pos)0x80000000)
-#define FX6_MAX ((FT_Pos)0x7FFFFFFF)
+#define FX6_ONE 64L
+#define FX16_ONE 65536L
+#define FX6_MAX (0x7FFFFFFFL)
+#define FX6_MIN (~FX6_MAX)
 
-#define FX6_FLOOR(x) ((x) & -64)
-#define FX6_CEIL(x) (((x) + 63) & -64)
-#define FX6_ROUND(x) (((x) + 32) & -64)
+#define FX6_FLOOR(x) ((x) & -64L)
+#define FX6_CEIL(x) (((x) + 63L) & -64L)
+#define FX6_ROUND(x) (((x) + 32L) & -64L)
 #define FX6_TRUNC(x)  ((x) >> 6)
-#define FX16_CEIL_TO_FX6(x) (((x) + 1023) >> 10)
+#define FX16_CEIL_TO_FX6(x) (((x) + 1023L) >> 10)
 #define INT_TO_FX6(i) ((FT_Fixed)((i) << 6))
 #define INT_TO_FX16(i) ((FT_Fixed)((i) << 16))
 #define FX16_TO_DBL(x) ((x) * 1.5259e-5 /* 65536.0^-1 */)
                      FT_UInt *, long *, long *, long *, long *,
                      double *, double *);
 void _PGFT_GetRenderMetrics(const FontRenderMode *, FontText *,
-                            unsigned *, unsigned *, FT_Vector *,
+                            int *, int *, FT_Vector *,
                             FT_Pos *, FT_Fixed *);