Commits

Lenard Lindstrom committed b0f518d

improve pygame.freetype.Font font size handling (towards Issue #75)

These changes may cause minor breakage, as the *ptsize* argument to the
pygame.freetype.Font constructor and several of its methods is renamed *size*.

Perform better error checking on the *size* (formerly *ptsize*) argument, and
use this size, now *face_size* within the C code, more consistently. Its
type now matches the width and height fields of the FTC_ScalerRect C struct.
The face size is a value expressed in 1/64th or points. It is a transition
to allowing a two-tuple of floats as Python *size* value, which separates the
width and height requirements.

Comments (0)

Files changed (11)

docs/reST/ref/freetype.rst

 .. class:: Font
 
    | :sl:`Create a new Font instance from a supported font file.`
-   | :sg:`Font(file, ptsize=-1, font_index=0, resolution=0, ucs4=False) -> Font`
+   | :sg:`Font(file, size=0, font_index=0, resolution=0, ucs4=False) -> Font`
 
    Argument *file* can be either a string representing the font's filename, a
    file-like object containing the font, or None; if None, the default, built-in font
    is used.
 
-   Optionally, a *ptsize* argument may be specified to set the default size in
+   Optionally, a *size* argument may be specified to set the default size in
    points, which will be used when rendering the font. The size can also be
    passed explicitly to each method call. Because of the way the caching
    system works, specifying a default size on the constructor doesn't imply a
 
       Read only. Returns the path of the loaded font file
 
-   .. attribute:: ptsize
+   .. attribute:: size
 
       | :sl:`The default point size used in rendering`
-      | :sg:`ptsize -> int`
+      | :sg:`size -> int`
 
       Get or set a default point size used by metric or render methods.
 
    .. method:: get_rect
 
       | :sl:`Return the size and offset of rendered text`
-      | :sg:`get_rect(text, style=STYLE_DEFAULT, rotation=0, ptsize=default) -> rect`
+      | :sg:`get_rect(text, style=STYLE_DEFAULT, rotation=0, size=0) -> rect`
 
       Gets the final dimensions and origin, in pixels, of 'text' using the
       current point size, style, rotation and orientation. These are either
    .. method:: get_metrics
 
       | :sl:`Return the glyph metrics for the given text`
-      | :sg:`get_metrics(text, ptsize=default) -> [(...), ...]`
+      | :sg:`get_metrics(text, size=0) -> [(...), ...]`
 
       Returns the glyph metrics for each character in 'text'.
 
    .. method:: render
 
       | :sl:`Return rendered text as a surface`
-      | :sg:`render(text, fgcolor, bgcolor=None, style=STYLE_DEFAULT, rotation=0, ptsize=default) -> (Surface, Rect)`
+      | :sg:`render(text, fgcolor, bgcolor=None, style=STYLE_DEFAULT, rotation=0, size=0) -> (Surface, Rect)`
 
       Returns a new :mod:`pygame.Surface`, with the text rendered to it
       in the color given by 'fgcolor'. If ``bgcolor`` is given, the surface
       The rendering is done using the font's default size in points and its
       default style, without any rotation, and taking into account fonts which
       are set to be drawn vertically via the :meth:`Font.vertical` attribute.
-      Optionally you may specify another point size to use via the 'ptsize'
+      Optionally you may specify another point size to use via the 'size'
       argument, a text rotation via the 'rotation' argument, or a new text
       style via the 'style' argument.
 
    .. method:: render_to
 
       | :sl:`Render text onto an existing surface`
-      | :sg:`render(surf, dest, text, fgcolor, bgcolor=None, style=STYLE_DEFAULT, rotation=0, ptsize=default) -> Rect`
+      | :sg:`render(surf, dest, text, fgcolor, bgcolor=None, style=STYLE_DEFAULT, rotation=0, size=0) -> Rect`
 
       Renders the string 'text' to a :mod:`pygame.Surface` 'surf',
       using the color 'fgcolor'.
    .. method:: render_raw
 
       | :sl:`Return rendered text as a string of bytes`
-      | :sg:`render_raw(text, style=STYLE_DEFAULT, rotation=0, ptsize=default, invert=False) -> (bytes, (int, int))`
+      | :sg:`render_raw(text, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> (bytes, (int, int))`
 
       Like ``Font.render()`` but the tuple returned is an 8 bit
       monochrome string of bytes and its size. The foreground color is 255, the
    .. method:: render_raw_to
 
       | :sl:`Render text into an array of ints`
-      | :sg:`render_raw_to(array, text, dest=None, style=STYLE_DEFAULT, rotation=0, ptsize=default, invert=False) -> (int, int)`
+      | :sg:`render_raw_to(array, text, dest=None, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> (int, int)`
 
       Render to an array object exposing an array struct interface. The array
       must be two dimensional with integer items. The default dest value, None,
                 kwds['resolution'] = 1
         else:
             resolution = 0
-        super(Font, self).__init__(file, ptsize=size, resolution=resolution)
+        super(Font, self).__init__(file, size=size, resolution=resolution)
         self.strength = 1.0 / 12.0
         self.kerning = False
         self.origin = True
 /*
  * Getters/setters
  */
-static PyObject *_ftfont_getptsize(PgFontObject *, void *);
-static int _ftfont_setptsize(PgFontObject *, PyObject *, void *);
+static PyObject *_ftfont_getsize(PgFontObject *, void *);
+static int _ftfont_setsize(PgFontObject *, PyObject *, void *);
 static PyObject *_ftfont_getstyle(PgFontObject *, void *);
 static int _ftfont_setstyle(PgFontObject *, PyObject *, void *);
 static PyObject *_ftfont_getname(PgFontObject *, void *);
                              PgFontObject *, PGFT_String *);
 static PyObject *load_font_res(const char *);
 static int parse_dest(PyObject *, int *, int *);
-
+static int obj_to_scale(PyObject *, void *);
 
 /*
  * Auxiliar defines
     return 0;
 }
 
+/* Point size PyArg_ParseTuple converter: int -> Scale_t */
+static int
+obj_to_scale(PyObject *o, void *p)
+{
+    long size;
+    PyObject *lower_limit = 0;
+    PyObject *upper_limit = 0;
+    int cmp_result;
+    int rval = 0;
+
+    if (PyLong_Check(o)) {
+        ;
+    }
+#if PY2
+    else if (PyInt_Check(o)) {
+        ;
+    }
+#endif
+    else {
+        PyErr_Format(PyExc_TypeError, "integer point size expected, got %s",
+                     Py_TYPE(o)->tp_name);
+        goto finish;
+    }
+    lower_limit = PyInt_FromLong(0);
+    if (!lower_limit) goto finish;
+    cmp_result = PyObject_RichCompareBool(o, lower_limit, Py_LT);
+    if (cmp_result == -1) goto finish;
+    if (cmp_result == 1) {
+        PyErr_SetString(PyExc_OverflowError,
+                        "point size is >= 0, got negative integer value");
+        goto finish;
+    }
+    upper_limit = PyInt_FromLong(FX6_TRUNC(~(Scale_t)0));
+    if (!upper_limit) goto finish;
+    cmp_result = PyObject_RichCompareBool(o, upper_limit, Py_GT);
+    if (cmp_result == -1) goto finish;
+    if (cmp_result == 1) {
+        PyErr_SetString(PyExc_OverflowError,
+                        "integer value too large"
+                        " to convert to a point size");
+        goto finish;
+    }
+    size = PyInt_AsLong(o);
+    if (size == -1) goto finish;
+    *(Scale_t *)p = (Scale_t)INT_TO_FX6(size);
+    rval = 1;
+
+  finish:
+    Py_XDECREF(lower_limit);
+    Py_XDECREF(upper_limit);
+    return rval;
+}
+
 /*
  * FREETYPE MODULE METHODS TABLE
  */
  */
 static PyGetSetDef _ftfont_getsets[] = {
     {
-        "ptsize",
-        (getter)_ftfont_getptsize,
-        (setter)_ftfont_setptsize,
-        DOC_FONTPTSIZE,
+        "size",
+        (getter)_ftfont_getsize,
+        (setter)_ftfont_setsize,
+        DOC_FONTSIZE,
         0
     },
     {
         obj->path = 0;
         obj->resolution = 0;
         obj->_internals = 0;
-        obj->ptsize = -1;
+        obj->face_size = 0;
         obj->style = FT_STYLE_NORMAL;
         obj->render_flags = FT_RFLAG_DEFAULTS;
         obj->strength = PGFT_DBL_DEFAULT_STRENGTH;
 _ftfont_init(PgFontObject *self, PyObject *args, PyObject *kwds)
 {
     static char *kwlist[] =  {
-        "file", "ptsize", "font_index", "resolution", "ucs4", 0
+        "file", "size", "font_index", "resolution", "ucs4", 0
     };
 
     PyObject *file, *original_file;
     long font_index = 0;
-    int ptsize = self->ptsize;
+    Scale_t face_size = self->face_size;
     int ucs4 = self->render_flags & FT_RFLAG_UCS4 ? 1 : 0;
     unsigned resolution = 0;
 
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, -1);
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|ilIi", kwlist,
-                                     &file, &ptsize, &font_index,
-                                     &resolution, &ucs4)) {
-        return -1;
-    }
-    if (ptsize > 0x7FFF) {
-        PyErr_SetString(PyExc_ValueError, "ptsize argument value too large");
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O&lIi", kwlist,
+                                     &file,
+                                     obj_to_scale, (void *)&face_size,
+                                     &font_index, &resolution, &ucs4)) {
         return -1;
     }
 
     Py_XDECREF(self->path);
     self->path = 0;
 
-    self->ptsize = (FT_Int16)((ptsize > 0) ? ptsize : -1);
+    self->face_size = face_size;
     if (ucs4) {
         self->render_flags |= FT_RFLAG_UCS4;
     }
 }
 
 static PyObject *
-_ftfont_getptsize(PgFontObject *self, void *closure)
+_ftfont_getsize(PgFontObject *self, void *closure)
 {
-    return PyInt_FromLong(self->ptsize);
+    return PyInt_FromLong(FX6_TRUNC(self->face_size));
 }
 
 static int
-_ftfont_setptsize(PgFontObject *self, PyObject *value, void *closure)
+_ftfont_setsize(PgFontObject *self, PyObject *value, void *closure)
 {
-    PyObject *ptsizeobj = PyNumber_Int(value);
-    long ptsize;
+    Scale_t face_size;
 
-    if (!ptsizeobj) {
-        return -1;
-    }
-    ptsize = PyInt_AsLong(ptsizeobj);
-    Py_DECREF(ptsizeobj);
-    if (ptsize == -1 && PyErr_Occurred()) {
-        return -1;
-    }
-    if (ptsize > 0x7FFFL) {
-        PyErr_SetString(PyExc_ValueError, "ptsize value too large");
-        return -1;
-    }
-    self->ptsize = (FT_Int16)(ptsize > 0 ? ptsize : -1);
+    if (!obj_to_scale(value, &face_size)) goto error;
+    self->face_size = face_size;
     return 0;
+
+  error:
+    return -1;
 }
 
 static PyObject *
  */
     /* keyword list */
     static char *kwlist[] =  {
-        "text", "style", "rotation", "ptsize", 0
+        "text", "style", "rotation", "size", 0
     };
 
     PyObject *textobj;
     PGFT_String *text;
     PyObject *rectobj = 0;
     FT_Error error;
-    int ptsize = -1;
+    int face_size = 0;
     SDL_Rect r;
 
     FontRenderMode render;
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, 0);
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|iii", kwlist,
-                                     &textobj, &style, &rotation, &ptsize)) {
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|iiO&", kwlist,
+                                     &textobj, &style, &rotation,
+                                     obj_to_scale, (void *)&face_size)) {
         return 0;
     }
 
 
     /* Build rendering mode, always anti-aliased by default */
     if (_PGFT_BuildRenderMode(ft, self, &render,
-                             ptsize, style, rotation)) {
+                              face_size, style, rotation)) {
         return 0;
     }
 
 {
     /* keyword list */
     static char *kwlist[] =  {
-        "text", "ptsize", 0
+        "text", "size", 0
     };
 
     FontRenderMode render;
     /* arguments */
     PyObject *textobj;
     PGFT_String *text;
-    int ptsize = -1;
+    Scale_t face_size = 0;
 
     /* grab freetype */
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, 0);
 
     /* parse args */
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist,
-                                     &textobj, &ptsize)) {
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O&", kwlist, &textobj,
+                                     obj_to_scale, (void *)&face_size)) {
         return 0;
     }
 
      * Build the render mode with the given size and no
      * rotation/styles/vertical text
      */
-    if (_PGFT_BuildRenderMode(ft, self, &render, ptsize, FT_STYLE_NORMAL, 0)) {
+    if (_PGFT_BuildRenderMode(ft, self, &render, face_size, FT_STYLE_NORMAL, 0)) {
         _PGFT_FreeString(text);
         return 0;
     }
 static PyObject *
 _ftfont_getsizedascender(PgFontObject *self, PyObject *args)
 {
-    int pt_size = -1;
+    Scale_t face_size = 0;
     long value;
 
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, 0);
 
-    if (!PyArg_ParseTuple(args, "|i", &pt_size)) {
+    if (!PyArg_ParseTuple(args, "|O&", obj_to_scale, (void *)&face_size)) {
         return 0;
     }
 
-    if (pt_size == -1) {
-        if (self->ptsize == -1) {
+    if (face_size == 0) {
+        if (self->face_size == 0) {
             RAISE(PyExc_ValueError,
                   "No font point size specified"
                   " and no default font size in typefont");
             return 0;
         }
 
-        pt_size = self->ptsize;
+        face_size = self->face_size;
     }
-
-    if (pt_size <= 0) {
-        RAISE(PyExc_ValueError, "Invalid point size for font.");
-        return 0;
-    }
-    value = (long)_PGFT_Font_GetAscenderSized(ft, self, (FT_UInt16)pt_size);
+    value = (long)_PGFT_Font_GetAscenderSized(ft, self, face_size);
     if (!value && PyErr_Occurred()) {
         return 0;
     }
 static PyObject *
 _ftfont_getsizeddescender(PgFontObject *self, PyObject *args)
 {
-    int pt_size = -1;
+    Scale_t face_size = 0;
     long value;
 
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, 0);
 
-    if (!PyArg_ParseTuple(args, "|i", &pt_size)) {
+    if (!PyArg_ParseTuple(args, "|O&", obj_to_scale, (void *)&face_size)) {
         return 0;
     }
 
-    if (pt_size == -1) {
-        if (self->ptsize == -1) {
+    if (face_size == 0) {
+        if (self->face_size == 0) {
             RAISE(PyExc_ValueError,
                   "No font point size specified"
                   " and no default font size in typefont");
             return 0;
         }
 
-        pt_size = self->ptsize;
+        face_size = self->face_size;
     }
-
-    if (pt_size <= 0) {
-        RAISE(PyExc_ValueError, "Invalid point size for font.");
-        return 0;
-    }
-    value = (long)_PGFT_Font_GetDescenderSized(ft, self, (FT_UInt16)pt_size);
+    value = (long)_PGFT_Font_GetDescenderSized(ft, self, face_size);
     if (!value && PyErr_Occurred()) {
         return 0;
     }
 static PyObject *
 _ftfont_getsizedheight(PgFontObject *self, PyObject *args)
 {
-    int pt_size = -1;
+    Scale_t face_size = 0;
     long value;
 
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, 0);
 
-    if (!PyArg_ParseTuple(args, "|i", &pt_size)) {
+    if (!PyArg_ParseTuple(args, "|O&", obj_to_scale, (void *)&face_size)) {
         return 0;
     }
 
-    if (pt_size == -1) {
-        if (self->ptsize == -1) {
+    if (face_size == 0) {
+        if (self->face_size == 0) {
             RAISE(PyExc_ValueError,
                   "No font point size specified"
                   " and no default font size in typeface");
             return 0;
         }
 
-        pt_size = self->ptsize;
+        face_size = self->face_size;
     }
-
-    if (pt_size <= 0) {
-        RAISE(PyExc_ValueError, "Invalid point size for font.");
-        return 0;
-    }
-    value = _PGFT_Font_GetHeightSized(ft, self, (FT_UInt16)pt_size);
+    value = _PGFT_Font_GetHeightSized(ft, self, face_size);
     if (!value && PyErr_Occurred()) {
         return 0;
     }
 static PyObject *
 _ftfont_getsizedglyphheight(PgFontObject *self, PyObject *args)
 {
-    int pt_size = -1;
+    Scale_t face_size = -1;
     long value;
 
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, 0);
 
-    if (!PyArg_ParseTuple(args, "|i", &pt_size)) {
+    if (!PyArg_ParseTuple(args, "|O&", obj_to_scale, (void *)&face_size)) {
         return 0;
     }
 
-    if (pt_size == -1) {
-        if (self->ptsize == -1) {
+    if (face_size == 0) {
+        if (self->face_size == 0) {
             RAISE(PyExc_ValueError,
                   "No font point size specified"
                   " and no default font size in typeface");
             return 0;
         }
 
-        pt_size = self->ptsize;
+        face_size = self->face_size;
     }
-
-    if (pt_size <= 0) {
-        RAISE(PyExc_ValueError, "Invalid point size for font.");
-        return 0;
-    }
-    value = (long)_PGFT_Font_GetGlyphHeightSized(ft, self, (FT_UInt16)pt_size);
+    value = (long)_PGFT_Font_GetGlyphHeightSized(ft, self, face_size);
     if (!value && PyErr_Occurred()) {
         return 0;
     }
     int nsizes;
     unsigned i;
     int rc;
-    long ptsize = 0;
+    long size = 0;
     long height = 0, width = 0;
     double x_ppem = 0.0, y_ppem = 0.0;
     PyObject *size_list = 0;
     if (!size_list) goto error;
     for (i = 0; i < nsizes; ++i) {
         rc = _PGFT_Font_GetAvailableSize(ft, self, i,
-                                         &ptsize, &height, &width,
+                                         &size, &height, &width,
                                          &x_ppem, &y_ppem);
         if (rc < 0) goto error;
         assert(rc > 0);
         size_item = Py_BuildValue("llldd",
-                                  ptsize, height, width, x_ppem, y_ppem);
+                                  size, height, width, x_ppem, y_ppem);
         if (!size_item) goto error;
         PyList_SET_ITEM(size_list, i, size_item);
     }
 {
     /* keyword list */
     static char *kwlist[] =  {
-        "text", "style", "rotation", "ptsize", "invert", 0
+        "text", "style", "rotation", "size", "invert", 0
     };
 
     FontRenderMode mode;
     PGFT_String *text;
     int style = FT_STYLE_DEFAULT;
     int rotation = 0;
-    int ptsize = -1;
+    Scale_t face_size = 0;
     int invert = 0;
 
     /* output arguments */
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, 0);
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|iiii", kwlist,
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|iiO&i", kwlist,
                                      &textobj,
-                                     &style, &rotation, &ptsize, &invert)) {
+                                     &style, &rotation,
+                                     obj_to_scale, (void *)&face_size,
+                                     &invert)) {
         return 0;
     }
 
      * Build the render mode with the given size and no
      * rotation/styles/vertical text
      */
-    if (_PGFT_BuildRenderMode(ft, self, &mode, ptsize, style, rotation)) {
+    if (_PGFT_BuildRenderMode(ft, self, &mode, face_size, style, rotation)) {
         _PGFT_FreeString(text);
         return 0;
     }
 {
     /* keyword list */
     static char *kwlist[] =  {
-        "array", "text", "dest", "style", "rotation", "ptsize", "invert", 0
+        "array", "text", "dest", "style", "rotation", "size", "invert", 0
     };
 
     FontRenderMode mode;
     int ypos = 0;
     int style = FT_STYLE_DEFAULT;
     int rotation = 0;
-    int ptsize = -1;
+    Scale_t face_size = 0;
     int invert = 0;
 
     /* output arguments */
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, 0);
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|Oiiii", kwlist,
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|OiiO&i", kwlist,
                                      &arrayobj, &textobj,
                                      &dest, &style, &rotation,
-                                     &ptsize, &invert)) {
+                                     obj_to_scale, (void *)&face_size,
+                                     &invert)) {
         return 0;
     }
 
      * Build the render mode with the given size and no
      * rotation/styles/vertical text
      */
-    if (_PGFT_BuildRenderMode(ft, self, &mode, ptsize, style, rotation)) {
+    if (_PGFT_BuildRenderMode(ft, self, &mode, face_size, style, rotation)) {
         _PGFT_FreeString(text);
         return 0;
     }
 #else
     /* keyword list */
     static char *kwlist[] =  {
-        "text", "fgcolor", "bgcolor", "style", "rotation", "ptsize", 0
+        "text", "fgcolor", "bgcolor", "style", "rotation", "size", 0
     };
 
     /* input arguments */
     PyObject *textobj = 0;
     PGFT_String *text;
-    int ptsize = -1;
+    Scale_t face_size = 0;
     PyObject *fg_color_obj = 0;
     PyObject *bg_color_obj = 0;
     int rotation = 0;
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, 0);
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|Oiii", kwlist,
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|OiiO&", kwlist,
                                      /* required */
                                      &textobj, &fg_color_obj,
                                      /* optional */
                                      &bg_color_obj, &style,
-                                     &rotation, &ptsize)) {
+                                     &rotation,
+                                     obj_to_scale, (void *)&face_size)) {
         return 0;
     }
 
 
     ASSERT_SELF_IS_ALIVE(self);
 
-    if (_PGFT_BuildRenderMode(ft, self, &render, ptsize, style, rotation)) {
+    if (_PGFT_BuildRenderMode(ft, self, &render, face_size, style, rotation)) {
         _PGFT_FreeString(text);
         return 0;
     }
     /* keyword list */
     static char *kwlist[] =  {
         "surf", "dest", "text", "fgcolor", "bgcolor",
-        "style", "rotation", "ptsize", 0
+        "style", "rotation", "size", 0
     };
 
     /* input arguments */
     PyObject *surface_obj = 0;
     PyObject *textobj = 0;
     PGFT_String *text;
-    int ptsize = -1;
+    Scale_t face_size = 0;
     PyObject *dest = 0;
     int xpos = 0;
     int ypos = 0;
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, 0);
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!OOO|Oiii", kwlist,
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!OOO|OiiO&", kwlist,
                                      /* required */
                                      &PySurface_Type, &surface_obj, &dest,
                                      &textobj, &fg_color_obj,
                                      /* optional */
                                      &bg_color_obj, &style,
-                                     &rotation, &ptsize)) {
+                                     &rotation,
+                                     obj_to_scale, (void *)&face_size)) {
         return 0;
     }
 
         return 0;
     }
 
-    if (_PGFT_BuildRenderMode(ft, self, &render, ptsize, style, rotation)) {
+    if (_PGFT_BuildRenderMode(ft, self, &render, face_size, style, rotation)) {
         _PGFT_FreeString(text);
         return 0;
     }

src/doc/freetype_doc.h

 
 #define DOC_PYGAMEFREETYPEGETDEFAULTFONT "get_default_font() -> string\nGet the filename of the default font"
 
-#define DOC_PYGAMEFREETYPEFONT "Font(file, ptsize=-1, font_index=0, resolution=0, ucs4=False) -> Font\nCreate a new Font instance from a supported font file."
+#define DOC_PYGAMEFREETYPEFONT "Font(file, size=0, font_index=0, resolution=0, ucs4=False) -> Font\nCreate a new Font instance from a supported font file."
 
 #define DOC_FONTNAME "name -> string\nProper font name."
 
 #define DOC_FONTPATH "path -> unicode\nFont file path"
 
-#define DOC_FONTPTSIZE "ptsize -> int\nThe default point size used in rendering"
+#define DOC_FONTSIZE "size -> int\nThe default point size used in rendering"
 
-#define DOC_FONTGETRECT "get_rect(text, style=STYLE_DEFAULT, rotation=0, ptsize=default) -> rect\nReturn the size and offset of rendered text"
+#define DOC_FONTGETRECT "get_rect(text, style=STYLE_DEFAULT, rotation=0, size=0) -> rect\nReturn the size and offset of rendered text"
 
-#define DOC_FONTGETMETRICS "get_metrics(text, ptsize=default) -> [(...), ...]\nReturn the glyph metrics for the given text"
+#define DOC_FONTGETMETRICS "get_metrics(text, size=0) -> [(...), ...]\nReturn the glyph metrics for the given text"
 
 #define DOC_FONTHEIGHT "height -> int\nThe unscaled height of the font in font units"
 
 
 #define DOC_FONTGETSIZES "get_sizes() -> [(int, int, int, float, float), ...]\nget_sizes() -> []\nreturn the available sizes of embedded bitmaps"
 
-#define DOC_FONTRENDER "render(text, fgcolor, bgcolor=None, style=STYLE_DEFAULT, rotation=0, ptsize=default) -> (Surface, Rect)\nReturn rendered text as a surface"
+#define DOC_FONTRENDER "render(text, fgcolor, bgcolor=None, style=STYLE_DEFAULT, rotation=0, size=0) -> (Surface, Rect)\nReturn rendered text as a surface"
 
-#define DOC_FONTRENDERTO "render(surf, dest, text, fgcolor, bgcolor=None, style=STYLE_DEFAULT, rotation=0, ptsize=default) -> Rect\nRender text onto an existing surface"
+#define DOC_FONTRENDERTO "render(surf, dest, text, fgcolor, bgcolor=None, style=STYLE_DEFAULT, rotation=0, size=0) -> Rect\nRender text onto an existing surface"
 
-#define DOC_FONTRENDERRAW "render_raw(text, style=STYLE_DEFAULT, rotation=0, ptsize=default, invert=False) -> (bytes, (int, int))\nReturn rendered text as a string of bytes"
+#define DOC_FONTRENDERRAW "render_raw(text, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> (bytes, (int, int))\nReturn rendered text as a string of bytes"
 
-#define DOC_FONTRENDERRAWTO "render_raw_to(array, text, dest=None, style=STYLE_DEFAULT, rotation=0, ptsize=default, invert=False) -> (int, int)\nRender text into an array of ints"
+#define DOC_FONTRENDERRAWTO "render_raw_to(array, text, dest=None, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> (int, int)\nRender text into an array of ints"
 
 #define DOC_FONTSTYLE "style -> int\nThe font's style flags"
 
 Get the filename of the default font
 
 pygame.freetype.Font
- Font(file, ptsize=-1, font_index=0, resolution=0, ucs4=False) -> Font
+ Font(file, size=0, font_index=0, resolution=0, ucs4=False) -> Font
 Create a new Font instance from a supported font file.
 
 pygame.freetype.Font.name
  path -> unicode
 Font file path
 
-pygame.freetype.Font.ptsize
- ptsize -> int
+pygame.freetype.Font.size
+ size -> int
 The default point size used in rendering
 
 pygame.freetype.Font.get_rect
- get_rect(text, style=STYLE_DEFAULT, rotation=0, ptsize=default) -> rect
+ get_rect(text, style=STYLE_DEFAULT, rotation=0, size=0) -> rect
 Return the size and offset of rendered text
 
 pygame.freetype.Font.get_metrics
- get_metrics(text, ptsize=default) -> [(...), ...]
+ get_metrics(text, size=0) -> [(...), ...]
 Return the glyph metrics for the given text
 
 pygame.freetype.Font.height
 return the available sizes of embedded bitmaps
 
 pygame.freetype.Font.render
- render(text, fgcolor, bgcolor=None, style=STYLE_DEFAULT, rotation=0, ptsize=default) -> (Surface, Rect)
+ render(text, fgcolor, bgcolor=None, style=STYLE_DEFAULT, rotation=0, size=0) -> (Surface, Rect)
 Return rendered text as a surface
 
 pygame.freetype.Font.render_to
- render(surf, dest, text, fgcolor, bgcolor=None, style=STYLE_DEFAULT, rotation=0, ptsize=default) -> Rect
+ render(surf, dest, text, fgcolor, bgcolor=None, style=STYLE_DEFAULT, rotation=0, size=0) -> Rect
 Render text onto an existing surface
 
 pygame.freetype.Font.render_raw
- render_raw(text, style=STYLE_DEFAULT, rotation=0, ptsize=default, invert=False) -> (bytes, (int, int))
+ render_raw(text, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> (bytes, (int, int))
 Return rendered text as a string of bytes
 
 pygame.freetype.Font.render_raw_to
- render_raw_to(array, text, dest=None, style=STYLE_DEFAULT, rotation=0, ptsize=default, invert=False) -> (int, int)
+ render_raw_to(array, text, dest=None, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> (int, int)
 Render text into an array of ints
 
 pygame.freetype.Font.style
  * Global module types
  **********************************************************/
 
+typedef FT_UInt Scale_t;
+
 typedef struct {
     FT_Long font_index;
     FT_Open_Args open_args;
     PgFontId id;
     PyObject *path;
 
-    FT_Int16 ptsize;
+    Scale_t face_size;
     FT_Int16 style;
     FT_Int16 render_flags;
     double strength;

src/freetype/ft_cache.c

 
 typedef struct keyfields_ {
     PGFT_char ch;
-    unsigned short pt_size;
+    Scale_t face_size;
     unsigned short style;
     unsigned short render_flags;
     unsigned short rotation;
 
     memset(key, 0, sizeof(key));
     fields->ch = ch;
-    fields->pt_size = mode->pt_size;
+    fields->face_size = mode->face_size;
     fields->style = mode->style & style_mask;
     fields->render_flags = mode->render_flags & rflag_mask;
     fields->rotation = rot;

src/freetype/ft_layout.c

     FT_Error    error = 0;
 
     /* load our sized font */
-    font = _PGFT_GetFontSized(ft, fontobj, mode->pt_size);
+    font = _PGFT_GetFontSized(ft, fontobj, mode->face_size);
     if (!font) {
         PyErr_SetString(PyExc_SDLError, _PGFT_GetError(ft));
         return 0;
     FT_Face     font;
 
     /* load our sized font */
-    font = _PGFT_GetFontSized(ft, fontobj, mode->pt_size);
+    font = _PGFT_GetFontSized(ft, fontobj, mode->face_size);
     if (!font) {
         return -1;
     }

src/freetype/ft_render.c

 int
 _PGFT_BuildRenderMode(FreeTypeInstance *ft,
                       PgFontObject *fontobj, FontRenderMode *mode,
-                      int pt_size, int style, int rotation)
+                      Scale_t face_size, int style, int rotation)
 {
     int angle;
 
-    if (pt_size == -1) {
-        if (fontobj->ptsize == -1) {
+    if (face_size == 0) {
+        if (fontobj->face_size == 0) {
             PyErr_SetString(PyExc_ValueError,
                   "No font point size specified"
                   " and no default font size in typeface");
             return -1;
         }
 
-        pt_size = fontobj->ptsize;
+        face_size = fontobj->face_size;
     }
-    if (pt_size <= 0) {
-        PyErr_SetString(PyExc_ValueError, "Invalid point size for font.");
-        return -1;
-    }
-    mode->pt_size = (FT_UInt16)pt_size;
+    mode->face_size = face_size;
 
     if (style == FT_STYLE_DEFAULT) {
         mode->style = fontobj->style;
         r->x = 0;
         r->y = 0;
         r->w = 0;
-        r->h = _PGFT_Font_GetHeightSized(ft, fontobj, mode->pt_size);
+        r->h = _PGFT_Font_GetHeightSized(ft, fontobj, mode->face_size);
         return 0;
     }
 
         r->x = 0;
         r->y = 0;
         r->w = 0;
-        r->h = _PGFT_Font_GetHeightSized(ft, fontobj, mode->pt_size);
+        r->h = _PGFT_Font_GetHeightSized(ft, fontobj, mode->face_size);
         return 0;
     }
     surf_offset.x = INT_TO_FX6(x);
     }
     else {
         width = 1;
-        height = _PGFT_Font_GetHeightSized(ft, fontobj, mode->pt_size);
+        height = _PGFT_Font_GetHeightSized(ft, fontobj, mode->face_size);
         offset.x = -font_text->min_x;
         offset.y = -font_text->min_y;
     }
         r->x = 0;
         r->y = 0;
         r->w = 0;
-        r->h = _PGFT_Font_GetHeightSized(ft, fontobj, mode->pt_size);
+        r->h = _PGFT_Font_GetHeightSized(ft, fontobj, mode->face_size);
         return 0;
     }
 
         r->x = 0;
         r->y = 0;
         r->w = 0;
-        r->h = _PGFT_Font_GetHeightSized(ft, fontobj, mode->pt_size);
+        r->h = _PGFT_Font_GetHeightSized(ft, fontobj, mode->face_size);
         return 0;
     }
     array_offset.x = INT_TO_FX6(x);

src/freetype/ft_wrap.c

 
 int
 _PGFT_Font_GetAvailableSize(FreeTypeInstance *ft, PgFontObject *fontobj,
-                            unsigned n, long *ptsize_p,
+                            unsigned n, long *size_p,
                             long *height_p, long *width_p,
                             double *x_ppem_p, double *y_ppem_p)
 {
         return 0;
     }
     bitmap_size_p = font->available_sizes + n;
-    *ptsize_p = FX6_TRUNC(FX6_ROUND(bitmap_size_p->size));
+    *size_p = (long)FX6_TRUNC(FX6_ROUND(bitmap_size_p->size));
     *height_p = (long)bitmap_size_p->height;
     *width_p = (long)bitmap_size_p->width;
     *x_ppem_p = FX6_TO_DBL(bitmap_size_p->x_ppem);
 
 long
 _PGFT_Font_GetHeightSized(FreeTypeInstance *ft, PgFontObject *fontobj,
-                          FT_UInt16 ptsize)
+                          Scale_t face_size)
 {
-    FT_Face font = _PGFT_GetFontSized(ft, fontobj, ptsize);
+    FT_Face font = _PGFT_GetFontSized(ft, fontobj, face_size);
 
     if (!font) {
         RAISE(PyExc_RuntimeError, _PGFT_GetError(ft));
 
 long
 _PGFT_Font_GetAscenderSized(FreeTypeInstance *ft, PgFontObject *fontobj,
-                           FT_UInt16 ptsize)
+                            Scale_t face_size)
 {
-    FT_Face font = _PGFT_GetFontSized(ft, fontobj, ptsize);
+    FT_Face font = _PGFT_GetFontSized(ft, fontobj, face_size);
 
     if (!font) {
         RAISE(PyExc_RuntimeError, _PGFT_GetError(ft));
 
 long
 _PGFT_Font_GetDescenderSized(FreeTypeInstance *ft, PgFontObject *fontobj,
-                             FT_UInt16 ptsize)
+                             Scale_t face_size)
 {
-    FT_Face font = _PGFT_GetFontSized(ft, fontobj, ptsize);
+    FT_Face font = _PGFT_GetFontSized(ft, fontobj, face_size);
 
     if (!font) {
         RAISE(PyExc_RuntimeError, _PGFT_GetError(ft));
 
 long
 _PGFT_Font_GetGlyphHeightSized(FreeTypeInstance *ft, PgFontObject *fontobj,
-                               FT_UInt16 ptsize)
+                               Scale_t face_size)
 {
     /*
      * Based on the SDL_ttf height calculation.
      */
-    FT_Face font = _PGFT_GetFontSized(ft, fontobj, ptsize);
+    FT_Face font = _PGFT_GetFontSized(ft, fontobj, face_size);
     FT_Size_Metrics *metrics;
 
     if (!font) {
 FT_Face
 _PGFT_GetFontSized(FreeTypeInstance *ft,
     PgFontObject *fontobj,
-    int font_size)
+    Scale_t face_size)
 {
     FT_Error error;
     FTC_ScalerRec scale;
     FT_Size _fts;
 
-    _PGFT_BuildScaler(fontobj, &scale, font_size);
+    _PGFT_BuildScaler(fontobj, &scale, face_size);
 
     error = FTC_Manager_LookupSize(ft->cache_manager,
         &scale, &_fts);
  *
  *********************************************************/
 void
-_PGFT_BuildScaler(PgFontObject *fontobj, FTC_Scaler scale, int size)
+_PGFT_BuildScaler(PgFontObject *fontobj, FTC_Scaler scale, Scale_t face_size)
 {
     scale->face_id = (FTC_FaceID)(&fontobj->id);
-    scale->width = scale->height = (FT_UInt32)(size * 64);
+    scale->width = scale->height = (FT_UInt)face_size;
     scale->pixel = 0;
     scale->x_res = scale->y_res = fontobj->resolution;
 }

src/freetype/ft_wrap.h

 } FontColor;
 
 typedef struct rendermode_ {
-    FT_UInt16 pt_size;
+    Scale_t face_size;
     FT_Angle rotation_angle;
     FT_UInt16 render_flags;
     FT_UInt16 style;
 int _PGFT_Init(FreeTypeInstance **, int);
 long _PGFT_Font_GetAscender(FreeTypeInstance *, PgFontObject *);
 long _PGFT_Font_GetAscenderSized(FreeTypeInstance *, PgFontObject *,
-                                 FT_UInt16);
+                                 Scale_t);
 long _PGFT_Font_GetDescender(FreeTypeInstance *, PgFontObject *);
 long _PGFT_Font_GetDescenderSized(FreeTypeInstance *, PgFontObject *,
-                                  FT_UInt16);
+                                  Scale_t);
 long _PGFT_Font_GetHeight(FreeTypeInstance *, PgFontObject *);
 long _PGFT_Font_GetHeightSized(FreeTypeInstance *, PgFontObject *,
-                               FT_UInt16);
+                               Scale_t);
 long _PGFT_Font_GetGlyphHeightSized(FreeTypeInstance *, PgFontObject *,
-                                    FT_UInt16);
+                                    Scale_t);
 int _PGFT_Font_IsScalable(FreeTypeInstance *, PgFontObject *);
 int _PGFT_Font_IsFixedWidth(FreeTypeInstance *, PgFontObject *);
 int _PGFT_Font_NumFixedSizes(FreeTypeInstance *, PgFontObject *);
                        const FontRenderMode *, PyObject *,
                        PGFT_String *, int, int, int, SDL_Rect *);
 int _PGFT_BuildRenderMode(FreeTypeInstance *, PgFontObject *,
-                          FontRenderMode *, int, int, int);
+                          FontRenderMode *, Scale_t, int, int);
 int _PGFT_CheckStyle(FT_UInt32);
 
 
 /**************************************** Internals **************************/
 void _PGFT_SetError(FreeTypeInstance *, const char *, FT_Error);
 FT_Face _PGFT_GetFont(FreeTypeInstance *, PgFontObject *);
-FT_Face _PGFT_GetFontSized(FreeTypeInstance *, PgFontObject *, int);
-void _PGFT_BuildScaler(PgFontObject *, FTC_Scaler, int);
+FT_Face _PGFT_GetFontSized(FreeTypeInstance *, PgFontObject *, Scale_t);
+void _PGFT_BuildScaler(PgFontObject *, FTC_Scaler, Scale_t);
 #define _PGFT_malloc PyMem_Malloc
 #define _PGFT_free   PyMem_Free
 

test/freetype_test.py

 import sys
 import os
+import ctypes
 if __name__ == '__main__':
     pkg_dir = os.path.split(os.path.abspath(__file__))[0]
     parent_dir, pkg_name = os.path.split(pkg_dir)
     """return an uninitialized font instance"""
     return ft.Font.__new__(ft.Font)
 
+max_point_size = 0
+for i in range(0, ctypes.sizeof(ctypes.c_uint)):
+    max_point_size <<= 8
+    max_point_size |= 0xff
+max_point_size >>= 6
+
 class FreeTypeFontTest(unittest.TestCase):
 
     _fixed_path = os.path.join(FONTDIR, 'test_fixed.otf')
         self.assertTrue(isinstance(f, ft.Font))
 
         # Test keyword arguments
-        f = ft.Font(ptsize=22, file=None)
-        self.assertEqual(f.ptsize, 22)
+        f = ft.Font(size=22, file=None)
+        self.assertEqual(f.size, 22)
         f = ft.Font(font_index=0, file=None)
         self.assertNotEqual(ft.get_default_resolution(), 100)
         f = ft.Font(resolution=100, file=None)
         self.assertEqual(f.resolution, 100)
         f = ft.Font(ucs4=True, file=None)
         self.assertTrue(f.ucs4)
-        self.assertRaises(ValueError, ft.Font, file=None, ptsize=0x8000)
-        f = ft.Font(None, ptsize=-0x10000)
-        self.assertEqual(f.ptsize, -1)
+        self.assertRaises(OverflowError, ft.Font, file=None,
+                          size=(max_point_size + 1))
+        self.assertRaises(OverflowError, ft.Font, file=None, size=-1)
 
-        f = ft.Font(None, ptsize=24)
+        f = ft.Font(None, size=24)
         self.assert_(f.height > 0)
         self.assertRaises(IOError, f.__init__,
                           os.path.join(FONTDIR, 'nonexistant.ttf'))
-        self.assertRaises(RuntimeError, f.get_rect, 'a', ptsize=24)
+        self.assertRaises(RuntimeError, f.get_rect, 'a', size=24)
         
         # Test attribute preservation during reinitalization
-        f = ft.Font(self._sans_path, ptsize=24, ucs4=True)
+        f = ft.Font(self._sans_path, size=24, ucs4=True)
         self.assertEqual(f.name, 'Liberation Sans')
         self.assertTrue(f.scalable)
         self.assertFalse(f.fixed_width)
             self.assertTrue(f.use_bitmap_strikes)
 
             # bitmap compatible properties
-            s_strike, sz = f.render_raw('A', ptsize=19)
+            s_strike, sz = f.render_raw('A', size=19)
             try:
                 f.vertical = True
-                s_strike_vert, sz = f.render_raw('A', ptsize=19)
+                s_strike_vert, sz = f.render_raw('A', size=19)
             finally:
                 f.vertical = False
             try:
                 f.wide = True
-                s_strike_wide, sz = f.render_raw('A', ptsize=19)
+                s_strike_wide, sz = f.render_raw('A', size=19)
             finally:
                 f.wide = False
             try:
                 f.underline = True
-                s_strike_underline, sz = f.render_raw('A', ptsize=19)
+                s_strike_underline, sz = f.render_raw('A', size=19)
             finally:
                 f.underline = False
 
             # bitmap incompatible properties
-            s_strike_rot45, sz = f.render_raw('A', ptsize=19, rotation=45)
+            s_strike_rot45, sz = f.render_raw('A', size=19, rotation=45)
             try:
                 f.strong = True
-                s_strike_strong, sz = f.render_raw('A', ptsize=19)
+                s_strike_strong, sz = f.render_raw('A', size=19)
             finally:
                 f.strong = False
             try:
                 f.oblique = True
-                s_strike_oblique, sz = f.render_raw('A', ptsize=19)
+                s_strike_oblique, sz = f.render_raw('A', size=19)
             finally:
                 f.oblique = False
 
             self.assertFalse(f.use_bitmap_strikes)
 
             # bitmap compatible properties
-            s_outline, sz = f.render_raw('A', ptsize=19)
+            s_outline, sz = f.render_raw('A', size=19)
             self.assertNotEqual(s_outline, s_strike)
             try:
                 f.vertical = True
-                s_outline, sz = f.render_raw('A', ptsize=19)
+                s_outline, sz = f.render_raw('A', size=19)
                 self.assertNotEqual(s_outline, s_strike_vert)
             finally:
                 f.vertical = False
             try:
                 f.wide = True
-                s_outline, sz = f.render_raw('A', ptsize=19)
+                s_outline, sz = f.render_raw('A', size=19)
                 self.assertNotEqual(s_outline, s_strike_wide)
             finally:
                 f.wide = False
             try:
                 f.underline = True
-                s_outline, sz = f.render_raw('A', ptsize=19)
+                s_outline, sz = f.render_raw('A', size=19)
                 self.assertNotEqual(s_outline, s_strike_underline)
             finally:
                 f.underline = False
 
             # bitmap incompatible properties
-            s_outline, sz = f.render_raw('A', ptsize=19, rotation=45)
+            s_outline, sz = f.render_raw('A', size=19, rotation=45)
             self.assertEqual(s_outline, s_strike_rot45)
             try:
                 f.strong = True
-                s_outline, sz = f.render_raw('A', ptsize=19)
+                s_outline, sz = f.render_raw('A', size=19)
                 self.assertEqual(s_outline, s_strike_strong)
             finally:
                 f.strong = False
             try:
                 f.oblique = True
-                s_outline, sz = f.render_raw('A', ptsize=19)
+                s_outline, sz = f.render_raw('A', size=19)
                 self.assertEqual(s_outline, s_strike_oblique)
             finally:
                 f.oblique = False
 
         font = self._TEST_FONTS['sans']
 
-        metrics = font.get_metrics('ABCD', ptsize=24)
+        metrics = font.get_metrics('ABCD', size=24)
         self.assertEqual(len(metrics), len('ABCD'))
         self.assertTrue(isinstance(metrics, list))
 
                 self.assertTrue(isinstance(m, float))
 
         # test for empty string
-        metrics = font.get_metrics('', ptsize=24)
+        metrics = font.get_metrics('', size=24)
         self.assertEqual(metrics, [])
 
         # test for invalid string
 
         # raises exception when uninitalized
         self.assertRaises(RuntimeError, nullfont().get_metrics,
-                          'a', ptsize=24)
+                          'a', size=24)
 
     def test_freetype_Font_get_rect(self):
 
         def test_rect(r):
             self.assertTrue(isinstance(r, pygame.Rect))
 
-        rect_default = font.get_rect("ABCDabcd", ptsize=24)
+        rect_default = font.get_rect("ABCDabcd", size=24)
         test_rect(rect_default)
         self.assertTrue(rect_default.size > (0, 0))
         self.assertTrue(rect_default.width > rect_default.height)
 
-        rect_bigger = font.get_rect("ABCDabcd", ptsize=32)
+        rect_bigger = font.get_rect("ABCDabcd", size=32)
         test_rect(rect_bigger)
         self.assertTrue(rect_bigger.size > rect_default.size)
 
-        rect_strong = font.get_rect("ABCDabcd", ptsize=24, style=ft.STYLE_STRONG)
+        rect_strong = font.get_rect("ABCDabcd", size=24, style=ft.STYLE_STRONG)
         test_rect(rect_strong)
         self.assertTrue(rect_strong.size > rect_default.size)
 
         font.vertical = True
-        rect_vert = font.get_rect("ABCDabcd", ptsize=24)
+        rect_vert = font.get_rect("ABCDabcd", size=24)
         test_rect(rect_vert)
         self.assertTrue(rect_vert.width < rect_vert.height)
         font.vertical = False
 
-        rect_oblique = font.get_rect("ABCDabcd", ptsize=24, style=ft.STYLE_OBLIQUE)
+        rect_oblique = font.get_rect("ABCDabcd", size=24, style=ft.STYLE_OBLIQUE)
         test_rect(rect_oblique)
         self.assertTrue(rect_oblique.width > rect_default.width)
         self.assertTrue(rect_oblique.height == rect_default.height)
 
-        rect_under = font.get_rect("ABCDabcd", ptsize=24, style=ft.STYLE_UNDERLINE)
+        rect_under = font.get_rect("ABCDabcd", size=24, style=ft.STYLE_UNDERLINE)
         test_rect(rect_under)
         self.assertTrue(rect_under.width == rect_default.width)
         self.assertTrue(rect_under.height > rect_default.height)
 
-#        size_utf32 = font.get_size(as_unicode(r'\U000130A7'), ptsize=24)
-#        size_utf16 = font.get_size(as_unicode(r'\uD80C\uDCA7'), ptsize=24)
+#        size_utf32 = font.get_size(as_unicode(r'\U000130A7'), size=24)
+#        size_utf16 = font.get_size(as_unicode(r'\uD80C\uDCA7'), size=24)
 #        self.assertEqual(size_utf16[0], size_utf32[0]);
 #        font.utf16_surrogates = False
 #        try:
-#            size_utf16 = font.get_size(as_unicode(r'\uD80C\uDCA7'), ptsize=24)
+#            size_utf16 = font.get_size(as_unicode(r'\uD80C\uDCA7'), size=24)
 #        finally:
 #            font.utf16_surrogates = True
 #        self.assertNotEqual(size_utf16[0], size_utf32[0]);
         
         self.assertRaises(RuntimeError,
-                          nullfont().get_rect, 'a', ptsize=24)
+                          nullfont().get_rect, 'a', size=24)
 
     def test_freetype_Font_height(self):
 
         nf = nullfont()
         self.assertEqual(nf.name, repr(nf))
 
-    def test_freetype_Font_ptsize(self):
+    def test_freetype_Font_size(self):
 
-        f = ft.Font(None, ptsize=12)
-        self.assertEqual(f.ptsize, 12)
-        f.ptsize = 22
-        self.assertEqual(f.ptsize, 22)
-        for i in [0, -1, -2, -0x10000]:
-            f.ptsize = i
-            self.assertEqual(f.ptsize, -1)
-        self.assertRaises(ValueError, setattr, f, 'ptsize', 0x8000)
+        f = ft.Font(None, size=12)
+        self.assertEqual(f.size, 12)
+        f.size = 22
+        self.assertEqual(f.size, 22)
+        f.size = 0
+        self.assertEqual(f.size, 0)
+        f.size = max_point_size
+        self.assertEqual(f.size, max_point_size)
+        self.assertRaises(OverflowError, setattr, f, 'size', -1)
+        self.assertRaises(OverflowError, setattr, f, 'size',
+                          (max_point_size + 1))
+        self.assertRaises(TypeError, setattr, f, 'size', 0.0)
 
     def test_freetype_Font_render_to(self):
         # Rendering to an existing target surface is equivalent to
         color = pygame.Color(0, 0, 0)
 
         rrect = font.render_to(surf, (32, 32),
-                               'FoobarBaz', color, None, ptsize=24)
+                               'FoobarBaz', color, None, size=24)
         self.assertTrue(isinstance(rrect, pygame.Rect))
         self.assertEqual(rrect.top, rrect.height)
 ##        self.assertEqual(rrect.left, something or other)
         self.assertTrue(surf.get_rect().contains(rcopy))
         
         rect = pygame.Rect(20, 20, 2, 2)
-        rrect = font.render_to(surf, rect, 'FoobarBax', color, None, ptsize=24)
+        rrect = font.render_to(surf, rect, 'FoobarBax', color, None, size=24)
         self.assertEqual(rrect.top, rrect.height)
         self.assertNotEqual(rrect.size, rect.size)
         rrect = font.render_to(surf, (20.1, 18.9), 'FoobarBax',
-                               color, None, ptsize=24)
+                               color, None, size=24)
 ##        self.assertEqual(tuple(rend[1].topleft), (20, 18))
 
-        rrect = font.render_to(surf, rect, '', color, None, ptsize=24)
+        rrect = font.render_to(surf, rect, '', color, None, size=24)
         self.assertFalse(rrect)
         self.assertEqual(rrect.height, font.get_sized_height(24))
 
                      (), (1,), ('a', 2), (1, 'a'), (1+2j, 2), (1, 1+2j),
                      (1, int), (int, 1)]: 
             self.assertRaises(TypeError, font.render,
-                              surf, dest, 'foobar', color, ptsize=24)
+                              surf, dest, 'foobar', color, size=24)
 
         # misc parameter test
         self.assertRaises(ValueError, font.render_to, surf, (0, 0),
                           'foobar', color)
         self.assertRaises(TypeError, font.render_to, surf, (0, 0),
-                          'foobar', color, "", ptsize=24)
+                          'foobar', color, "", size=24)
         self.assertRaises(ValueError, font.render_to, surf, (0, 0),
-                          'foobar', color, None, style=42, ptsize=24)
+                          'foobar', color, None, style=42, size=24)
         self.assertRaises(TypeError, font.render_to, surf, (0, 0),
-                          'foobar', color, None, style=None, ptsize=24)
+                          'foobar', color, None, style=None, size=24)
         self.assertRaises(ValueError, font.render_to, surf, (0, 0),
-                          'foobar', color, None, style=97, ptsize=24)
+                          'foobar', color, None, style=97, size=24)
 
 
     def test_freetype_Font_render(self):
         self.assertRaises(TypeError, font.render, 'FoobarBaz')
         self.assertRaises(TypeError, font.render, 'FoobarBaz', None)
 
-        rend = font.render('FoobarBaz', pygame.Color(0, 0, 0), None, ptsize=24)
+        rend = font.render('FoobarBaz', pygame.Color(0, 0, 0), None, size=24)
         self.assertTrue(isinstance(rend, tuple))
         self.assertEqual(len(rend), 2)
         self.assertTrue(isinstance(rend[0], pygame.Surface))
         self.assertTrue(isinstance(rend[1], pygame.Rect))
         self.assertEqual(rend[0].get_rect().size, rend[1].size)
-        s, r = font.render('', pygame.Color(0, 0, 0), None, ptsize=24)
+        s, r = font.render('', pygame.Color(0, 0, 0), None, size=24)
         self.assertEqual(r.width, 1)
         self.assertEqual(r.height, font.get_sized_height(24))
         self.assertEqual(s.get_size(), r.size)
         # misc parameter test
         self.assertRaises(ValueError, font.render, 'foobar', color)
         self.assertRaises(TypeError, font.render, 'foobar', color, "",
-                          ptsize=24)
+                          size=24)
         self.assertRaises(ValueError, font.render, 'foobar', color, None,
-                          style=42, ptsize=24)
+                          style=42, size=24)
         self.assertRaises(TypeError, font.render, 'foobar', color, None,
-                          style=None, ptsize=24)
+                          style=None, size=24)
         self.assertRaises(ValueError, font.render, 'foobar', color, None,
-                          style=97, ptsize=24)
+                          style=97, size=24)
 
         # valid surrogate pairs
         font2 = self._TEST_FONTS['mono']
         ucs4 = font2.ucs4
         try:
             font2.ucs4 = False
-            rend1 = font2.render(as_unicode(r'\uD80C\uDC79'), color, ptsize=24)
-            rend2 = font2.render(as_unicode(r'\U00013079'), color, ptsize=24)
+            rend1 = font2.render(as_unicode(r'\uD80C\uDC79'), color, size=24)
+            rend2 = font2.render(as_unicode(r'\U00013079'), color, size=24)
             self.assertEqual(rend1[1], rend2[1])
             font2.ucs4 = True
-            rend1 = font2.render(as_unicode(r'\uD80C\uDC79'), color, ptsize=24)
+            rend1 = font2.render(as_unicode(r'\uD80C\uDC79'), color, size=24)
             self.assertNotEqual(rend1[1], rend2[1])
         finally:
             font2.ucs4 = ucs4
             
         # malformed surrogate pairs
         self.assertRaises(UnicodeEncodeError, font.render,
-                          as_unicode(r'\uD80C'), color, ptsize=24)
+                          as_unicode(r'\uD80C'), color, size=24)
         self.assertRaises(UnicodeEncodeError, font.render,
-                          as_unicode(r'\uDCA7'), color, ptsize=24)
+                          as_unicode(r'\uDCA7'), color, size=24)
         self.assertRaises(UnicodeEncodeError, font.render,
-                          as_unicode(r'\uD7FF\uDCA7'), color, ptsize=24)
+                          as_unicode(r'\uD7FF\uDCA7'), color, size=24)
         self.assertRaises(UnicodeEncodeError, font.render,
-                          as_unicode(r'\uDC00\uDCA7'), color, ptsize=24)
+                          as_unicode(r'\uDC00\uDCA7'), color, size=24)
         self.assertRaises(UnicodeEncodeError, font.render,
-                          as_unicode(r'\uD80C\uDBFF'), color, ptsize=24)
+                          as_unicode(r'\uD80C\uDBFF'), color, size=24)
         self.assertRaises(UnicodeEncodeError, font.render,
-                          as_unicode(r'\uD80C\uE000'), color, ptsize=24)
+                          as_unicode(r'\uD80C\uE000'), color, size=24)
 
         # raises exception when uninitalized
         self.assertRaises(RuntimeError, nullfont().render,
-                          'a', (0, 0, 0), ptsize=24)
+                          'a', (0, 0, 0), size=24)
 
         # *** need more unicode testing to ensure the proper glyphs are rendered
 
         save_antialiased = font.antialiased
         font.antialiased = False
         try:
-            surf, r = font.render(text, color, ptsize=24)
+            surf, r = font.render(text, color, size=24)
             self.assertEqual(surf.get_bitsize(), 8)
             flags = surf.get_flags()
             self.assertTrue(flags & pygame.SRCCOLORKEY)
 
             translucent_color = pygame.Color(*color)
             translucent_color.a = 55
-            surf, r = font.render(text, translucent_color, ptsize=24)
+            surf, r = font.render(text, translucent_color, size=24)
             self.assertEqual(surf.get_bitsize(), 8)
             flags = surf.get_flags()
             self.assertTrue(flags & (pygame.SRCCOLORKEY | pygame.SRCALPHA))
             self.assertEqual(surf.get_colorkey(), colorkey)
             self.assertEqual(surf.get_alpha(), translucent_color.a)
 
-            surf, r = font.render(text, color, colorkey, ptsize=24)
+            surf, r = font.render(text, color, colorkey, size=24)
             self.assertEqual(surf.get_bitsize(), 32)
         finally:
             font.antialiased = save_antialiased
         # color is alpha blitted to the background.
         font = self._TEST_FONTS['sans']
         text = " ."
-        rect = font.get_rect(text, ptsize=24)
+        rect = font.get_rect(text, size=24)
         size = rect.size
         fg = pygame.Surface((1, 1), pygame.SRCALPHA, 32)
         bg = pygame.Surface((1, 1), pygame.SRCALPHA, 32)
                 r_fg_color = surf.get_at((0, 0))
                 surf.set_at((0, 0), fill_color)
                 rrect = font.render_to(surf, (0, 0), text, fg_color,
-                                       ptsize=24)
+                                       size=24)
                 bottomleft = 0, rrect.height - 1
                 self.assertEqual(surf.get_at(bottomleft), fill_color)
                 bottomright = rrect.width - 1, rrect.height - 1
                     r_fg_color = surf.get_at((0, 0))
                     surf.set_at((0, 0), fill_color)
                 rrect = font.render_to(surf, (0, 0), text, fg_color,
-                                       bg_color, ptsize=24)
+                                       bg_color, size=24)
                 bottomleft = 0, rrect.height - 1
                 self.assertEqual(surf.get_at(bottomleft), r_bg_color)
                 bottomright = rrect.width - 1, rrect.height - 1
         font = self._TEST_FONTS['sans']
         
         text = "abc"
-        size = font.get_rect(text, ptsize=24).size
-        rend = font.render_raw(text, ptsize=24)
+        size = font.get_rect(text, size=24).size
+        rend = font.render_raw(text, size=24)
         self.assertTrue(isinstance(rend, tuple))
         self.assertEqual(len(rend), 2)
         r, s = rend
         self.assertEqual(s, size)
         self.assertEqual(len(r), w * h)
         
-        r, (w, h) = font.render_raw('', ptsize=24)
+        r, (w, h) = font.render_raw('', size=24)
         self.assertEqual(w, 0)
         self.assertEqual(h, font.height)
         self.assertEqual(len(r), 0)
         
         # bug with decenders: this would crash
-        rend = font.render_raw('render_raw', ptsize=24)
+        rend = font.render_raw('render_raw', size=24)
 
         # bug with non-printable characters: this would cause a crash
         # because the text length was not adjusted for skipped characters.
         text = unicode_("").join([unichr_(i) for i in range(31, 64)])
-        rend = font.render_raw(text, ptsize=10)
+        rend = font.render_raw(text, size=10)
 
     def test_freetype_Font_render_raw_to(self):
 
         text = "abc"
 
         # No frills antialiased render to int1 (__render_glyph_INT)
-        srect = font.get_rect(text, ptsize=24)
+        srect = font.get_rect(text, size=24)
         surf = pygame.Surface(srect.size, 0, 8)
-        rrect = font.render_raw_to(surf.get_view('2'), text, ptsize=24)
+        rrect = font.render_raw_to(surf.get_view('2'), text, size=24)
         self.assertEqual(rrect, srect)
 
         for bpp in [24, 32]:
             surf = pygame.Surface(srect.size, 0, bpp)
-            rrect = font.render_raw_to(surf.get_view('r'), text, ptsize=24)
+            rrect = font.render_raw_to(surf.get_view('r'), text, size=24)
             self.assertEqual(rrect, srect)
 
         # Underlining to int1 (__fill_glyph_INT)
-        srect = font.get_rect(text, ptsize=24, style=ft.STYLE_UNDERLINE)
+        srect = font.get_rect(text, size=24, style=ft.STYLE_UNDERLINE)
         surf = pygame.Surface(srect.size, 0, 8)
-        rrect = font.render_raw_to(surf.get_view('2'), text, ptsize=24,
+        rrect = font.render_raw_to(surf.get_view('2'), text, size=24,
                                   style=ft.STYLE_UNDERLINE)
         self.assertEqual(rrect, srect)
 
         for bpp in [24, 32]:
             surf = pygame.Surface(srect.size, 0, bpp)
-            rrect = font.render_raw_to(surf.get_view('r'), text, ptsize=24,
+            rrect = font.render_raw_to(surf.get_view('r'), text, size=24,
                                        style=ft.STYLE_UNDERLINE)
             self.assertEqual(rrect, srect)
 
         # Unaliased (mono) rendering to int1 (__render_glyph_MONO_as_INT)
         font.antialiased = False
         try:
-            srect = font.get_rect(text, ptsize=24)
+            srect = font.get_rect(text, size=24)
             surf = pygame.Surface(srect.size, 0, 8)
-            rrect = font.render_raw_to(surf.get_view('2'), text, ptsize=24)
+            rrect = font.render_raw_to(surf.get_view('2'), text, size=24)
             self.assertEqual(rrect, srect)
 
             for bpp in [24, 32]:
                 surf = pygame.Surface(srect.size, 0, bpp)
-                rrect = font.render_raw_to(surf.get_view('r'), text, ptsize=24)
+                rrect = font.render_raw_to(surf.get_view('r'), text, size=24)
                 self.assertEqual(rrect, srect)
         finally:
             font.antialiased = True
 
         # Antialiased render to ints sized greater than 1 byte
         # (__render_glyph_INT)
-        srect = font.get_rect(text, ptsize=24)
+        srect = font.get_rect(text, size=24)
 
         for bpp in [16, 24, 32]:
             surf = pygame.Surface(srect.size, 0, bpp)
-            rrect = font.render_raw_to(surf.get_view('2'), text, ptsize=24)
+            rrect = font.render_raw_to(surf.get_view('2'), text, size=24)
             self.assertEqual(rrect, srect)
 
         # Underline render to ints sized greater than 1 byte
         # (__fill_glyph_INT)
-        srect = font.get_rect(text, ptsize=24, style=ft.STYLE_UNDERLINE)
+        srect = font.get_rect(text, size=24, style=ft.STYLE_UNDERLINE)
 
         for bpp in [16, 24, 32]:
             surf = pygame.Surface(srect.size, 0, bpp)
-            rrect = font.render_raw_to(surf.get_view('2'), text, ptsize=24,
+            rrect = font.render_raw_to(surf.get_view('2'), text, size=24,
                                        style=ft.STYLE_UNDERLINE)
             self.assertEqual(rrect, srect)
 
         # (__render_glyph_MONO_as_INT)
         font.antialiased = False
         try:
-            srect = font.get_rect(text, ptsize=24)
+            srect = font.get_rect(text, size=24)
 
             for bpp in [16, 24, 32]:
                 surf = pygame.Surface(srect.size, 0, bpp)
                 rrect = font.render_raw_to(surf.get_view('2'),
-                                           text, ptsize=24)
+                                           text, size=24)
                 self.assertEqual(rrect, srect)
         finally:
             font.antialiased = True
     def NEWBUF_test_newbuf(self):
         Exporter = self.buftools.Exporter
         font = self._TEST_FONTS['sans']
-        srect = font.get_rect("Hi", ptsize=12)
+        srect = font.get_rect("Hi", size=12)
         for format in ['b', 'B', 'h', 'H', 'i', 'I', 'l', 'L', 'q', 'Q',
                        'x', '1x', '2x', '3x', '4x', '5x', '6x', '7x',
                        '8x', '9x', '<h', '>h', '=h', '@h', '!h', '1h', '=1h']:
             newbuf = Exporter(srect.size, format=format)
-            rrect = font.render_raw_to(newbuf, "Hi", ptsize=12)
+            rrect = font.render_raw_to(newbuf, "Hi", size=12)
             self.assertEqual(rrect, srect)
         # Some unsupported formats
         for format in ['f', 'd', '2h', '?', 'hh']:
             newbuf = Exporter(srect.size, format=format, itemsize=4)
             self.assertRaises(ValueError, font.render_raw_to,
-                              newbuf, "Hi", ptsize=12)
+                              newbuf, "Hi", size=12)
 
     def test_freetype_Font_style(self):
 
         resolution = ft.get_default_resolution()
         new_font = ft.Font(self._sans_path, resolution=2 * resolution)
         self.assertEqual(new_font.resolution, 2 * resolution)
-        size_normal = self._TEST_FONTS['sans'].get_rect(text, ptsize=24).size
-        size_scaled = new_font.get_rect(text, ptsize=24).size
+        size_normal = self._TEST_FONTS['sans'].get_rect(text, size=24).size
+        size_scaled = new_font.get_rect(text, size=24).size
         size_by_2 = size_normal[0] * 2
         self.assertTrue(size_by_2 + 2 >= size_scaled[0] >= size_by_2 - 2,
                         "%i not equal %i" % (size_scaled[1], size_by_2))
         hit = 0
         miss = 0
 
-        f = ft.Font(None, ptsize=24, font_index=0, resolution=72, ucs4=False)
+        f = ft.Font(None, size=24, font_index=0, resolution=72, ucs4=False)
         f.style = ft.STYLE_NORMAL
         f.antialiased = True
 
         count += glen
         access += glen
         miss += glen
-        f.render_raw(glyphs, ptsize=12)
+        f.render_raw(glyphs, size=12)
         self.assertEqual(f._debug_cache_stats, (count, 0, access, hit, miss))
         # Underline style does not
         access += oglen
         count += 2 * mglen
         access += 2 * mglen
         miss += 2 * mglen
-        f.get_metrics(many_glyphs, ptsize=8)
-        f.get_metrics(many_glyphs, ptsize=10)
+        f.get_metrics(many_glyphs, size=8)
+        f.get_metrics(many_glyphs, size=10)
         ccount, cdelete_count, caccess, chit, cmiss = f._debug_cache_stats
         print (ccount, cdelete_count, caccess, chit, cmiss)
         self.assertTrue(ccount < count)
         # of None.
         font = self._TEST_FONTS['sans']
 
-        img, size1 = font.render(unichr_(1), (0, 0, 0), ptsize=24)
-        img, size0 = font.render("", (0, 0, 0), ptsize=24)
+        img, size1 = font.render(unichr_(1), (0, 0, 0), size=24)
+        img, size0 = font.render("", (0, 0, 0), size=24)
         self.assertTrue(size1.width > size0.width )
 
-        metrics = font.get_metrics(unichr_(1) + unichr_(48), ptsize=24)
+        metrics = font.get_metrics(unichr_(1) + unichr_(48), size=24)
         self.assertEqual(len(metrics), 2)
         self.assertTrue(metrics[0] is None)
         self.assertTrue(isinstance(metrics[1], tuple))
         # was to have the raised exception disappear before Font.render
         # returned to Python level.
         #
-        font = ft.Font(None, ptsize=64)
+        font = ft.Font(None, size=64)
         s = 'M' * 100000  # Way too long for an SDL surface
         self.assertRaises(pygame.error, font.render, s, (0, 0, 0))