Commits

Lenard Lindstrom committed fb5239a

freetype: make code style more consistent with PEP 7

  • Participants
  • Parent commits 64e5028

Comments (0)

Files changed (10)

File src/freetype.c

 #define RESOURCE_FUNC_NAME  "getResource"
 
 static PyObject *
-_PGFT_get_metrics(FreeTypeInstance *ft, FontRenderMode *render,
-          PyFreeTypeFont *font, PGFT_String *text);
+get_metrics(FreeTypeInstance *ft, FontRenderMode *render,
+	    PyFreeTypeFont *font, PGFT_String *text);
 
 static PyObject *
 load_font_res(const char *filename)
 
 #if PY3
     tmp = PyObject_GetAttrString(result, "name");
-    if (tmp != NULL)
-    {
+    if (tmp != NULL) {
         Py_DECREF(result);
         result = tmp;
     }
-    else 
-    {
+    else  {
         PyErr_Clear();
     }
 #else
-    if (PyFile_Check(result))
-    {
-        tmp = PyFile_Name(result);        
+    if (PyFile_Check(result)) {
+        tmp = PyFile_Name(result);
         Py_INCREF(tmp);
         Py_DECREF(result);
         result = tmp;
     PyObject *oj;
     int i, j;
 
-    if (!PySurface_Check(s))
-    {
+    if (!PySurface_Check(s)) {
         PyErr_Format(PyExc_TypeError,
                      "expected a Surface as element 0 of dest:"
                      " got type %.1024s",
         Py_DECREF(s);
         return -1;
     }
-    if (len == 2)
-    {
+    if (len == 2) {
         PyObject *size = PySequence_GetItem(dest, 1);
 
-        if (size == NULL)
-        {
+        if (size == NULL) {
             Py_DECREF(s);
             return -1;
         }
-        if (!PySequence_Check(size))
-        {
+        if (!PySequence_Check(size)) {
             PyErr_Format(PyExc_TypeError,
                          "expected an (x,y) position for element 1"
                          " of dest: got type %.1024s",
             return -1;
         }
         len = PySequence_Length(size);
-        if (len < 2)
-        {
+        if (len < 2) {
             PyErr_Format(PyExc_TypeError,
                          "expected at least a length 2 sequence for element 1"
                          " of dest: not length %d", len);
             return -1;
         }
         oi = PySequence_GetItem(size, 0);
-        if (oi == NULL)
-        {
+        if (oi == NULL) {
             Py_DECREF(s);
             Py_DECREF(size);
             return -1;
         }
         oj = PySequence_GetItem(size, 1);
         Py_DECREF(size);
-        if (oj == NULL)
-        {
+        if (oj == NULL) {
             Py_DECREF(s);
             Py_DECREF(oi);
             return -1;
         }
-        if (!PyNumber_Check(oi) || !PyNumber_Check(oj))
-        {
+        if (!PyNumber_Check(oi) || !PyNumber_Check(oj)) {
             Py_DECREF(s);
             Py_DECREF(oi);
             Py_DECREF(oj);
             return -1;
         }
     }
-    else if (len == 3)
-    {
+    else if (len == 3) {
         oi = PySequence_GetItem(dest, 1);
-        if (oi == NULL)
-        {
+        if (oi == NULL) {
             Py_DECREF(s);
             return -1;
         }
         oj = PySequence_GetItem(dest, 2);
-        if (oj == NULL)
-        {
+        if (oj == NULL) {
             Py_DECREF(oi);
             Py_DECREF(s);
             return -1;
         }
-        if (!PyNumber_Check(oi) || !PyNumber_Check(oj))
-        {
+        if (!PyNumber_Check(oi) || !PyNumber_Check(oj)) {
             Py_DECREF(s);
             PyErr_Format(PyExc_TypeError,
                          "for dest expected a pair of numbers"
             return -1;
         }
     }
-    else
-    {
+    else {
         Py_DECREF(s);
         PyErr_Format(PyExc_TypeError,
                      "for dest expected a sequence of either 2 or 3:"
                      " not length %d", len);
         return -1;
-    }              
+    }
     i = PyInt_AsLong(oi);
     Py_DECREF(oi);
-    if (i == -1 && PyErr_Occurred())
-    {
+    if (i == -1 && PyErr_Occurred()) {
         Py_DECREF(s);
         Py_DECREF(oj);
         return -1;
     }
     j = PyInt_AsLong(oj);
     Py_DECREF(oj);
-    if (j == -1 && PyErr_Occurred())
-    {
+    if (j == -1 && PyErr_Occurred()) {
         Py_DECREF(s);
         return -1;
     }
 /*
  * FREETYPE MODULE METHODS TABLE
  */
-static PyMethodDef _ft_methods[] = 
-{
-
-    {   
-        "__PYGAMEinit__", 
-        (PyCFunction) _ft_autoinit, 
+static PyMethodDef _ft_methods[] = {
+    {
+        "__PYGAMEinit__",
+        (PyCFunction) _ft_autoinit,
         METH_NOARGS,
-        "auto initialize function for font" 
+        "auto initialize function for font"
     },
-    { 
-        "init", 
-        (PyCFunction) _ft_init, 
-        METH_VARARGS | METH_KEYWORDS, 
+    {
+        "init",
+        (PyCFunction) _ft_init,
+        METH_VARARGS | METH_KEYWORDS,
         DOC_PYGAMEFREETYPEINIT
     },
-    { 
-        "quit", 
-        (PyCFunction) _ft_quit, 
-        METH_NOARGS, 
+    {
+        "quit",
+        (PyCFunction) _ft_quit,
+        METH_NOARGS,
         DOC_PYGAMEFREETYPEQUIT
     },
-    { 
-        "was_init", 
-        (PyCFunction) _ft_was_init, 
-        METH_NOARGS, 
+    {
+        "was_init",
+        (PyCFunction) _ft_was_init,
+        METH_NOARGS,
         DOC_PYGAMEFREETYPEWASINIT
     },
-    { 
-        "get_error", 
-        (PyCFunction) _ft_get_error, 
+    {
+        "get_error",
+        (PyCFunction) _ft_get_error,
         METH_NOARGS,
         DOC_PYGAMEFREETYPEGETERROR
     },
-    { 
-        "get_version", 
-        (PyCFunction) _ft_get_version, 
+    {
+        "get_version",
+        (PyCFunction) _ft_get_version,
         METH_NOARGS,
         DOC_PYGAMEFREETYPEGETVERSION
     },
 /*
  * FREETYPE FONT METHODS TABLE
  */
-static PyMethodDef _ftfont_methods[] = 
-{
+static PyMethodDef _ftfont_methods[] = {
     {
-        "get_sized_height", 
+        "get_sized_height",
         (PyCFunction) _ftfont_getsizedheight,
         METH_VARARGS,
         DOC_FONTGETSIZEDHEIGHT
         DOC_FONTGETSIZEDDESCENDER
     },
     {
-        "get_sized_glyph_height", 
+        "get_sized_glyph_height",
         (PyCFunction) _ftfont_getsizedglyphheight,
         METH_VARARGS,
         DOC_FONTGETSIZEDGLYPHHEIGHT
     },
     {
-        "get_rect", 
+        "get_rect",
         (PyCFunction) _ftfont_getrect,
         METH_VARARGS | METH_KEYWORDS,
         DOC_FONTGETRECT
     },
     {
-        "get_metrics", 
+        "get_metrics",
         (PyCFunction) _ftfont_getmetrics,
         METH_VARARGS | METH_KEYWORDS,
         DOC_FONTGETMETRICS
     },
-    { 
-        "render", 
-        (PyCFunction)_ftfont_render, 
+    {
+        "render",
+        (PyCFunction)_ftfont_render,
         METH_VARARGS | METH_KEYWORDS,
         DOC_FONTRENDER
     },
-    { 
-        "render_raw", 
-        (PyCFunction)_ftfont_render_raw, 
+    {
+        "render_raw",
+        (PyCFunction)_ftfont_render_raw,
         METH_VARARGS | METH_KEYWORDS,
         DOC_FONTRENDERRAW
     },
-    { 
-        "get_transform", 
-        (PyCFunction)_ftfont_gettransform, 
+    {
+        "get_transform",
+        (PyCFunction)_ftfont_gettransform,
         METH_NOARGS,
         DOC_FONTGETTRANSFORM
     },
-    { 
-        "set_transform", 
-        (PyCFunction)_ftfont_settransform, 
+    {
+        "set_transform",
+        (PyCFunction)_ftfont_settransform,
         METH_VARARGS,
         DOC_FONTSETTRANSFORM
     },
-    { 
-        "delete_transform", 
-        (PyCFunction)_ftfont_deletetransform, 
+    {
+        "delete_transform",
+        (PyCFunction)_ftfont_deletetransform,
         METH_NOARGS,
         DOC_FONTDELETETRANSFORM
     },
 /*
  * FREETYPE FONT GETTERS/SETTERS TABLE
  */
-static PyGetSetDef _ftfont_getsets[] = 
-{
-    { 
-        "style",    
-        _ftfont_getstyle,   
-        _ftfont_setstyle, 
+static PyGetSetDef _ftfont_getsets[] = {
+    {
+        "style",
+        _ftfont_getstyle,
+        _ftfont_setstyle,
         DOC_FONTSTYLE,
-        NULL 
+        NULL
     },
-    { 
+    {
         "height",
-        _ftfont_getheight,  
+        _ftfont_getheight,
         NULL,
         DOC_FONTHEIGHT,
         NULL
-    }, 
-    { 
+    },
+    {
         "ascender",
-        _ftfont_getascender,  
+        _ftfont_getascender,
         NULL,
         DOC_FONTASCENDER,
         NULL
     },
-    { 
+    {
         "descender",
-        _ftfont_getdescender,  
+        _ftfont_getdescender,
         NULL,
         DOC_FONTASCENDER,
         NULL
     },
-    { 
-        "name", 
-        _ftfont_getname, 
+    {
+        "name",
+        _ftfont_getname,
         NULL,
         DOC_FONTNAME,
-        NULL 
+        NULL
     },
-    { 
-        "path", 
-        _ftfont_getpath, 
+    {
+        "path",
+        _ftfont_getpath,
         NULL,
         DOC_FONTPATH,
-        NULL 
+        NULL
     },
     {
         "fixed_width",
  */
 #define FULL_TYPE_NAME MODULE_NAME FONT_TYPE_NAME
 
-PyTypeObject PyFreeTypeFont_Type =
-{
+PyTypeObject PyFreeTypeFont_Type = {
     TYPE_HEAD(NULL,0)
     FULL_TYPE_NAME,             /* tp_name */
     sizeof (PyFreeTypeFont),    /* tp_basicsize */
 _ftfont_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
 {
     PyFreeTypeFont *obj = (PyFreeTypeFont *)(subtype->tp_alloc(subtype, 0));
-    
-    if (obj != NULL)
-    {
+
+    if (obj != NULL) {
         obj->id.open_args.flags = 0;
         obj->id.open_args.pathname = NULL;
         obj->path = NULL;
    }
     return (PyObject *)obj;
 }
- 
+
 void
 _ftfont_dealloc(PyFreeTypeFont *self)
 {
     /* Always try to unload the font even if we cannot grab
      * a freetype instance. */
-    PGFT_UnloadFont(FREETYPE_STATE->freetype, self);
+    _PGFT_UnloadFont(FREETYPE_STATE->freetype, self);
 
     Py_XDECREF(self->path);
     ((PyObject *)self)->ob_type->tp_free((PyObject *)self);
 int
 _ftfont_init(PyObject *self, PyObject *args, PyObject *kwds)
 {
-    static char *kwlist[] = 
-    { 
+    static char *kwlist[] =  {
         "font", "ptsize", "style", "face_index", "vertical",
         "ucs4", "resolution", "origin", NULL
     };
 
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
-    
+
     PyObject *file, *original_file;
     int face_index = 0;
     int ptsize;
     vertical = font->vertical;
     origin = font->origin;
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|iiIiiIi", kwlist, 
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|iiIiiIi", kwlist,
                                      &file, &ptsize, &font_style, &face_index,
                                      &vertical, &ucs4, &resolution, &origin))
         return -1;
 
     original_file = file;
 
-    PGFT_UnloadFont(ft, font);
+    _PGFT_UnloadFont(ft, font);
     Py_XDECREF(font->path);
     font->path = NULL;
-    
-    if (PGFT_CheckStyle(font_style))
-    {
+
+    if (_PGFT_CheckStyle(font_style)) {
         PyErr_Format(PyExc_ValueError,
                      "Invalid style value %x", (int)font_style);
         return -1;
     font->ucs4 = ucs4 ? (FT_Byte)1 : (FT_Byte)0;
     font->vertical = vertical;
     font->origin = (FT_Byte)origin;
-    if (resolution)
-    {
+    if (resolution) {
         font->resolution = (FT_UInt)resolution;
     }
-    else
-    {
+    else {
         font->resolution = FREETYPE_STATE->resolution;
     }
-    if (file == Py_None)
-    {
+    if (file == Py_None) {
         file = load_font_res(DEFAULT_FONT_NAME);
 
-        if (file == NULL)
-        {
+        if (file == NULL) {
             PyErr_SetString(PyExc_RuntimeError, "Failed to find default font");
             goto end;
         }
     }
 
     file = RWopsEncodeFilePath(file, NULL);
-    if (file == NULL)
-    {
+    if (file == NULL) {
         return -1;
     }
-    if (Bytes_Check(file))
-    {
-        if (PGFT_TryLoadFont_Filename(ft, font, Bytes_AS_STRING(file),
-                                      face_index))
-        {
+    if (Bytes_Check(file)) {
+        if (_PGFT_TryLoadFont_Filename(ft, font, Bytes_AS_STRING(file),
+                                       face_index)) {
             goto end;
         }
 
-        if (PyUnicode_Check(original_file))
-        {
+        if (PyUnicode_Check(original_file)) {
             /* Make sure to save a pure Unicode object to prevent possible
              * cycles from a derived class. This means no tp_traverse or
              * tp_clear for the PyFreetypeFont type.
              */
             font->path = Object_Unicode(original_file);
         }
-        else
-        {
+        else {
             font->path = PyUnicode_FromEncodedObject(file, "raw_unicode_escape",
                                                      "replace");
         }
     }
-    else
-    {
+    else {
         SDL_RWops *source = RWopsFromFileObject(original_file);
         PyObject *str = NULL;
         PyObject *path = NULL;
 
-        if (source == NULL)
-        {
+        if (source == NULL) {
             goto end;
         }
 
-        if (PGFT_TryLoadFont_RWops(ft, font, source, face_index))
-        {
+        if (_PGFT_TryLoadFont_RWops(ft, font, source, face_index)) {
             goto end;
         }
 
         path = PyObject_GetAttrString(original_file, "name");
-        if (!path)
-        {
+        if (!path) {
             PyErr_Clear();
             str = Bytes_FromFormat("<%s instance at %p>",
                                    Py_TYPE(file)->tp_name, (void *)file);
-            if (str)
-            {
+            if (str) {
                 font->path = PyUnicode_FromEncodedObject(str,
                                                          "ascii", "strict");
                 Py_DECREF(str);
             }
         }
-        else if (PyUnicode_Check(path))
-        {
+        else if (PyUnicode_Check(path)) {
             /* Make sure to save a pure Unicode object to prevent possible
              * cycles from a derived class. This means no tp_traverse or
              * tp_clear for the PyFreetypeFont type.
              */
             font->path = Object_Unicode(path);
         }
-        else if (Bytes_Check(path))
-        {
+        else if (Bytes_Check(path)) {
             font->path = PyUnicode_FromEncodedObject(path,
                                                "unicode_escape", "replace");
         }
-        else
-        {
+        else {
             font->path = Object_Unicode(path);
         }
         Py_XDECREF(path);
 
 end:
 
-    if (file != original_file)
-    {
+    if (file != original_file) {
         Py_XDECREF(file);
     }
 
 {
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
 
-    if (PyFreeTypeFont_IS_ALIVE(font))
-    {
+    if (PyFreeTypeFont_IS_ALIVE(font)) {
 #if PY3
         return PyUnicode_FromFormat("Font('%.1024u')", font->path);
 #else
                                                   "replace");
         PyObject *rval = NULL;
 
-        if (str)
-        {
+        if (str) {
             rval = PyString_FromFormat("Font('%.1024s')",
                                        PyString_AS_STRING(str));
             Py_DECREF(str);
 _ftfont_getvertical(PyObject *self, void *closure)
 {
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
-    
+
     return PyBool_FromLong(font->vertical);
 }
 
 _ftfont_setvertical(PyObject *self, PyObject *value, void *closure)
 {
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
-    
-    if (!PyBool_Check(value))
-    {
+
+    if (!PyBool_Check(value)) {
         PyErr_SetString(PyExc_TypeError, "Expecting 'bool' type");
         return -1;
     }
 _ftfont_getantialias(PyObject *self, void *closure)
 {
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
-    
+
     return PyBool_FromLong(font->antialias);
 }
 
 _ftfont_setantialias(PyObject *self, PyObject *value, void *closure)
 {
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
-    
-    if (!PyBool_Check(value))
-    {
+
+    if (!PyBool_Check(value)) {
         PyErr_SetString(PyExc_TypeError, "Expecting 'bool' type");
         return -1;
     }
 _ftfont_getkerning(PyObject *self, void *closure)
 {
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
-    
+
     return PyBool_FromLong(font->kerning);
 }
 
 _ftfont_setkerning(PyObject *self, PyObject *value, void *closure)
 {
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
-    
-    if (!PyBool_Check(value))
-    {
+
+    if (!PyBool_Check(value)) {
         PyErr_SetString(PyExc_TypeError, "Expecting 'bool' type");
         return -1;
     }
     const int style_flag = (int)closure;
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
 
-    if (!PyBool_Check(value))
-    {
+    if (!PyBool_Check(value)) {
         PyErr_SetString(PyExc_TypeError,
                 "The style value must be a boolean");
         return -1;
     }
 
-    if (PyObject_IsTrue(value))
-    {
+    if (PyObject_IsTrue(value)) {
         font->style |= (FT_Byte)style_flag;
     }
-    else
-    {
+    else {
         font->style &= (FT_Byte)(~style_flag);
     }
 
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
     FT_UInt32 style;
 
-    if (!PyInt_Check(value))
-    {
-        PyErr_SetString(PyExc_TypeError, 
+    if (!PyInt_Check(value)) {
+        PyErr_SetString(PyExc_TypeError,
                 "The style value must be an integer"
                 " from the FT constants module");
         return -1;
 
     style = (FT_UInt32)PyInt_AsLong(value);
 
-    if (PGFT_CheckStyle(style) != 0)
-    {
+    if (_PGFT_CheckStyle(style) != 0) {
         PyErr_Format(PyExc_ValueError,
                      "Invalid style value %x", (int)style);
         return -1;
     ASSERT_GRAB_FREETYPE(ft, NULL);
 
     ASSERT_SELF_IS_ALIVE(self);
-    height = PGFT_Face_GetAscender(ft, (PyFreeTypeFont *)self);
-    if (!height && PyErr_Occurred())
-    {
+    height = _PGFT_Face_GetAscender(ft, (PyFreeTypeFont *)self);
+    if (!height && PyErr_Occurred()) {
         return NULL;
     }
     return PyInt_FromLong(height);
     ASSERT_GRAB_FREETYPE(ft, NULL);
 
     ASSERT_SELF_IS_ALIVE(self);
-    height = PGFT_Face_GetDescender(ft, (PyFreeTypeFont *)self);
-    if (!height && PyErr_Occurred())
-    {
+    height = _PGFT_Face_GetDescender(ft, (PyFreeTypeFont *)self);
+    if (!height && PyErr_Occurred()) {
         return NULL;
     }
     return PyInt_FromLong(height);
     ASSERT_GRAB_FREETYPE(ft, NULL);
 
     ASSERT_SELF_IS_ALIVE(self);
-    height = PGFT_Face_GetHeight(ft, (PyFreeTypeFont *)self);
-    if (!height && PyErr_Occurred())
-    {
+    height = _PGFT_Face_GetHeight(ft, (PyFreeTypeFont *)self);
+    if (!height && PyErr_Occurred()) {
         return NULL;
     }
     return PyInt_FromLong(height);
     const char *name;
     ASSERT_GRAB_FREETYPE(ft, NULL);
 
-    if (PyFreeTypeFont_IS_ALIVE(self))
-    {
-        name = PGFT_Face_GetName(ft, (PyFreeTypeFont *)self);
+    if (PyFreeTypeFont_IS_ALIVE(self)) {
+        name = _PGFT_Face_GetName(ft, (PyFreeTypeFont *)self);
         return name != NULL ? Text_FromUTF8(name) : NULL;
     }
     return PyObject_Repr(self);
 {
     PyObject *path = ((PyFreeTypeFont *)self)->path;
 
-    if (!path)
-    {
+    if (!path) {
         PyErr_SetString(PyExc_AttributeError, "path unavailable");
         return NULL;
     }
     ASSERT_GRAB_FREETYPE(ft, NULL);
 
     ASSERT_SELF_IS_ALIVE(self);
-    fixed_width = PGFT_Face_IsFixedWidth(ft, (PyFreeTypeFont *)self);
+    fixed_width = _PGFT_Face_IsFixedWidth(ft, (PyFreeTypeFont *)self);
     return fixed_width >= 0 ? PyBool_FromLong(fixed_width) : NULL;
 }
 
 _ftfont_getucs4(PyObject *self, void *closure)
 {
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
-    
+
     return PyBool_FromLong(font->ucs4);
 }
 
 _ftfont_setucs4(PyObject *self, PyObject *value, void *closure)
 {
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
-    
-    if (!PyBool_Check(value))
-    {
+
+    if (!PyBool_Check(value)) {
         PyErr_SetString(PyExc_TypeError, "Expecting 'bool' type");
         return -1;
     }
 _ftfont_getorigin(PyObject *self, void *closure)
 {
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
-    
+
     return PyBool_FromLong(font->origin);
 }
 
 _ftfont_setorigin(PyObject *self, PyObject *value, void *closure)
 {
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
-    
-    if (!PyBool_Check(value))
-    {
+
+    if (!PyBool_Check(value)) {
         PyErr_SetString(PyExc_TypeError, "Expecting 'bool' type");
         return -1;
     }
 _ftfont_getpad(PyObject *self, void *closure)
 {
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
-    
+
     return PyBool_FromLong(font->pad);
 }
 
 _ftfont_setpad(PyObject *self, PyObject *value, void *closure)
 {
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
-    
-    if (!PyBool_Check(value))
-    {
+
+    if (!PyBool_Check(value)) {
         PyErr_SetString(PyExc_TypeError, "Expecting 'bool' type");
         return -1;
     }
 _ftfont_getresolution(PyObject *self, void *closure)
 {
     PyFreeTypeFont *font = (PyFreeTypeFont *)self;
-    
+
     return PyLong_FromUnsignedLong((unsigned long)font->resolution);
 }
 
 
 /** testing and debugging */
-#if defined(PGFT_DEBUG_CACHE)
+#if defined(_PGFT_DEBUG_CACHE)
 static PyObject *
 _ftfont_getdebugcachestats(PyObject *self, void *closure)
 {
 /* MODIFIED
  */
     /* keyword list */
-    static char *kwlist[] = 
-    { 
+    static char *kwlist[] =  {
         "text", "style", "rotation", "ptsize", NULL
     };
 
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, NULL);
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|iii", kwlist, 
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|iii", kwlist,
                                      &textobj, &style, &rotation, &ptsize))
         return NULL;
 
     /* Encode text */
-    text = PGFT_EncodePyString(textobj, font->ucs4);
-    if (text == NULL)
-    {
+    text = _PGFT_EncodePyString(textobj, font->ucs4);
+    if (text == NULL) {
         return NULL;
     }
 
     ASSERT_SELF_IS_ALIVE(self);
 
     /* Build rendering mode, always anti-aliased by default */
-    if (PGFT_BuildRenderMode(ft, font, &render, 
-                             ptsize, style, rotation) != 0)
-    {
+    if (_PGFT_BuildRenderMode(ft, font, &render,
+                             ptsize, style, rotation) != 0) {
         return NULL;
     }
 
-    error = PGFT_GetTextRect(ft, font, &render, text, &r);
-    PGFT_FreeString(text);
+    error = _PGFT_GetTextRect(ft, font, &render, text, &r);
+    _PGFT_FreeString(text);
 
     if (!error)
         rectobj = PyRect_New(&r);
 }
 
 PyObject *
-_PGFT_get_metrics(FreeTypeInstance *ft, FontRenderMode *render,
+get_metrics(FreeTypeInstance *ft, FontRenderMode *render,
           PyFreeTypeFont *font, PGFT_String *text)
 {
     Py_ssize_t length = PGFT_String_GET_LENGTH(text);
         return NULL;
     }
     for (i = 0; i < length; ++i) {
-        if (PGFT_GetMetrics(ft, font, data[i], render,
-                &gindex, &minx, &maxx, &miny, &maxy,
-                &advance_x, &advance_y) == 0) {
-            if (gindex == 0)
-            {
+        if (_PGFT_GetMetrics(ft, font, data[i], render,
+                             &gindex, &minx, &maxx, &miny, &maxy,
+                             &advance_x, &advance_y) == 0) {
+            if (gindex == 0) {
                 Py_INCREF(Py_None);
                 item = Py_None;
             }
-            else
-            {
+            else {
                 item = Py_BuildValue("lllldd", minx, maxx, miny, maxy,
                                      advance_x, advance_y);
             }
 _ftfont_getmetrics(PyObject *self, PyObject *args, PyObject *kwds)
 {
     /* keyword list */
-    static char *kwlist[] = 
-    { 
+    static char *kwlist[] =  {
         "text", "ptsize", NULL
     };
 
         return NULL;
 
     /* Encode text */
-    text = PGFT_EncodePyString(textobj, font->ucs4);
-    if (text == NULL)
-    {
+    text = _PGFT_EncodePyString(textobj, font->ucs4);
+    if (text == NULL) {
         return NULL;
     }
 
      * Build the render mode with the given size and no
      * rotation/styles/vertical text
      */
-    if (PGFT_BuildRenderMode(ft, font, &render, ptsize, FT_STYLE_NORMAL, 0))
-    {
-        PGFT_FreeString(text);
+    if (_PGFT_BuildRenderMode(ft, font, &render, ptsize, FT_STYLE_NORMAL, 0)) {
+        _PGFT_FreeString(text);
         return NULL;
     }
 
     /* get metrics */
-    list = _PGFT_get_metrics(ft, &render, font, text);
+    list = get_metrics(ft, &render, font, text);
 
-    PGFT_FreeString(text);
+    _PGFT_FreeString(text);
     return list;
 }
 
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, NULL);
 
-    if (!PyArg_ParseTuple(args, "|i", &pt_size))
-    {
+    if (!PyArg_ParseTuple(args, "|i", &pt_size)) {
         return NULL;
     }
-    
-    if (pt_size == -1)
-    {
-        if (self->ptsize == -1)
-        {
+
+    if (pt_size == -1) {
+        if (self->ptsize == -1) {
             RAISE(PyExc_ValueError,
                   "No font point size specified"
                   " and no default font size in typeface");
         pt_size = self->ptsize;
     }
 
-    if (pt_size <= 0)
-    {
+    if (pt_size <= 0) {
         RAISE(PyExc_ValueError, "Invalid point size for font.");
         return NULL;
     }
-    value = (long)PGFT_Face_GetAscenderSized(ft, self, (FT_UInt16)pt_size);
-    if (!value && PyErr_Occurred())
-    {
+    value = (long)_PGFT_Face_GetAscenderSized(ft, self, (FT_UInt16)pt_size);
+    if (!value && PyErr_Occurred()) {
         return NULL;
     }
     return PyInt_FromLong(value);
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, NULL);
 
-    if (!PyArg_ParseTuple(args, "|i", &pt_size))
-    {
+    if (!PyArg_ParseTuple(args, "|i", &pt_size)) {
         return NULL;
     }
-    
-    if (pt_size == -1)
-    {
-        if (self->ptsize == -1)
-        {
+
+    if (pt_size == -1) {
+        if (self->ptsize == -1) {
             RAISE(PyExc_ValueError,
                   "No font point size specified"
                   " and no default font size in typeface");
         pt_size = self->ptsize;
     }
 
-    if (pt_size <= 0)
-    {
+    if (pt_size <= 0) {
         RAISE(PyExc_ValueError, "Invalid point size for font.");
         return NULL;
     }
-    value = (long)PGFT_Face_GetDescenderSized(ft, self, (FT_UInt16)pt_size);
-    if (!value && PyErr_Occurred())
-    {
+    value = (long)_PGFT_Face_GetDescenderSized(ft, self, (FT_UInt16)pt_size);
+    if (!value && PyErr_Occurred()) {
         return NULL;
     }
     return PyInt_FromLong(value);
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, NULL);
 
-    if (!PyArg_ParseTuple(args, "|i", &pt_size))
-    {
+    if (!PyArg_ParseTuple(args, "|i", &pt_size)) {
         return NULL;
     }
-    
-    if (pt_size == -1)
-    {
-        if (self->ptsize == -1)
-        {
+
+    if (pt_size == -1) {
+        if (self->ptsize == -1) {
             RAISE(PyExc_ValueError,
                   "No font point size specified"
                   " and no default font size in typeface");
         pt_size = self->ptsize;
     }
 
-    if (pt_size <= 0)
-    {
+    if (pt_size <= 0) {
         RAISE(PyExc_ValueError, "Invalid point size for font.");
         return NULL;
     }
-    value = PGFT_Face_GetHeightSized(ft, self, (FT_UInt16)pt_size);
-    if (!value && PyErr_Occurred())
-    {
+    value = _PGFT_Face_GetHeightSized(ft, self, (FT_UInt16)pt_size);
+    if (!value && PyErr_Occurred()) {
         return NULL;
     }
     return PyInt_FromLong(value);
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, NULL);
 
-    if (!PyArg_ParseTuple(args, "|i", &pt_size))
-    {
+    if (!PyArg_ParseTuple(args, "|i", &pt_size)) {
         return NULL;
     }
-    
-    if (pt_size == -1)
-    {
-        if (self->ptsize == -1)
-        {
+
+    if (pt_size == -1) {
+        if (self->ptsize == -1) {
             RAISE(PyExc_ValueError,
                   "No font point size specified"
                   " and no default font size in typeface");
         pt_size = self->ptsize;
     }
 
-    if (pt_size <= 0)
-    {
+    if (pt_size <= 0) {
         RAISE(PyExc_ValueError, "Invalid point size for font.");
         return NULL;
     }
-    value = (long)PGFT_Face_GetGlyphHeightSized(ft, self, (FT_UInt16)pt_size);
-    if (!value && PyErr_Occurred())
-    {
+    value = (long)_PGFT_Face_GetGlyphHeightSized(ft, self, (FT_UInt16)pt_size);
+    if (!value && PyErr_Occurred()) {
         return NULL;
     }
     return PyInt_FromLong(value);
 _ftfont_render_raw(PyObject *self, PyObject *args, PyObject *kwds)
 {
     /* keyword list */
-    static char *kwlist[] = 
-    { 
+    static char *kwlist[] =  {
         "text", "style", "rotation", "ptsize", NULL
     };
 
         return NULL;
 
     /* Encode text */
-    text = PGFT_EncodePyString(textobj, font->ucs4);
-    if (text == NULL)
-    {
+    text = _PGFT_EncodePyString(textobj, font->ucs4);
+    if (text == NULL) {
         return NULL;
     }
 
     ASSERT_SELF_IS_ALIVE(self);
-    
+
     /*
      * Build the render mode with the given size and no
      * rotation/styles/vertical text
      */
-    if (PGFT_BuildRenderMode(ft, font, 
-                &render, ptsize, style, rotation) != 0)
-    {
-        PGFT_FreeString(text);
+    if (_PGFT_BuildRenderMode(ft, font,
+                              &render, ptsize, style, rotation) != 0) {
+        _PGFT_FreeString(text);
         return NULL;
     }
 
-    rbuffer = PGFT_Render_PixelArray(ft, font, &render, text, &width, &height);
-    PGFT_FreeString(text);
+    rbuffer = _PGFT_Render_PixelArray(ft, font, &render, text, &width, &height);
+    _PGFT_FreeString(text);
 
-    if (!rbuffer)
-    {
+    if (!rbuffer) {
         return NULL;
     }
     rtuple = Py_BuildValue("O(ii)", rbuffer, width, height);
 {
 #ifndef HAVE_PYGAME_SDL_VIDEO
 
-    PyErr_SetString(PyExc_RuntimeError, "SDL support is missing. Cannot render on surfaces");
+    PyErr_SetString(PyExc_RuntimeError,
+		    "SDL support is missing. Cannot render on surfaces");
     return NULL;
 
 #else
     /* keyword list */
-    static char *kwlist[] = 
-    { 
-        "dest", "text", "fgcolor", "bgcolor", 
+    static char *kwlist[] =  {
+        "dest", "text", "fgcolor", "bgcolor",
         "style", "rotation", "ptsize", NULL
     };
 
                 &bg_color_obj, &style, &rotation, &ptsize)) /* optional */
         return NULL;
 
-    if (!RGBAFromColorObj(fg_color_obj, (Uint8 *)&fg_color))
-    {
+    if (!RGBAFromColorObj(fg_color_obj, (Uint8 *)&fg_color)) {
         PyErr_SetString(PyExc_TypeError, "fgcolor must be a Color");
         return NULL;
     }
 
-    if (bg_color_obj)
-    {
+    if (bg_color_obj) {
         if (bg_color_obj == Py_None)
             bg_color_obj = NULL;
-        
-        else if (!RGBAFromColorObj(bg_color_obj, (Uint8 *)&bg_color))
-        {
+
+        else if (!RGBAFromColorObj(bg_color_obj, (Uint8 *)&bg_color)) {
             PyErr_SetString(PyExc_TypeError, "bgcolor must be a Color");
             return NULL;
         }
     }
 
     /* Encode text */
-    text = PGFT_EncodePyString(textobj, font->ucs4);
-    if (text == NULL)
-    {
+    text = _PGFT_EncodePyString(textobj, font->ucs4);
+    if (text == NULL) {
         return NULL;
     }
 
     ASSERT_SELF_IS_ALIVE(self);
 
-    if (PGFT_BuildRenderMode(ft, font, 
-                &render, ptsize, style, rotation) != 0)
-    {
-        PGFT_FreeString(text);
+    if (_PGFT_BuildRenderMode(ft, font,
+                              &render, ptsize, style, rotation) != 0) {
+        _PGFT_FreeString(text);
         return NULL;
     }
 
-    if (dest == Py_None)
-    {
+    if (dest == Py_None) {
         SDL_Surface *r_surface = NULL;
 
-        r_surface = PGFT_Render_NewSurface(ft, font, &render, text,
-                        &fg_color, bg_color_obj ? &bg_color : NULL, &r);
-        PGFT_FreeString(text);
+        r_surface = _PGFT_Render_NewSurface(ft, font, &render, text, &fg_color,
+                                            bg_color_obj ? &bg_color : NULL,
+                                            &r);
+        _PGFT_FreeString(text);
 
-        if (!r_surface)
-        {
+        if (!r_surface) {
             return NULL;
         }
 
         surface_obj = PySurface_New(r_surface);
-        if (!surface_obj)
-        {
+        if (!surface_obj) {
             return NULL;
         }
     }
     else if (PySequence_Check(dest) &&  /* conditional and */
-             PySequence_Size(dest) > 1)
-    {
+             PySequence_Size(dest) > 1) {
         SDL_Surface *surface = NULL;
         int rcode;
 
-        if (parse_dest(dest, &surface_obj, &xpos, &ypos))
-        {
-            PGFT_FreeString(text);
+        if (parse_dest(dest, &surface_obj, &xpos, &ypos)) {
+            _PGFT_FreeString(text);
             return NULL;
         }
 
         surface = PySurface_AsSurface(surface_obj);
 
-        rcode = PGFT_Render_ExistingSurface(ft, font, &render, 
-                        text, surface, xpos, ypos,
-                        &fg_color,
-                        bg_color_obj ? &bg_color : NULL, &r);
-        PGFT_FreeString(text);
-        if (rcode)
-        {
+        rcode = _PGFT_Render_ExistingSurface(ft, font, &render, text, surface,
+                                             xpos, ypos, &fg_color,
+                                             bg_color_obj ? &bg_color : NULL,
+                                             &r);
+        _PGFT_FreeString(text);
+        if (rcode) {
             Py_DECREF(surface_obj);
             return NULL;
         }
     }
-    else
-    {
-        PGFT_FreeString(text);
+    else {
+        _PGFT_FreeString(text);
         return PyErr_Format(PyExc_TypeError,
-                            "Expected a (surface, posn) or None for dest argument:"
+                            "Expected a (surface, posn) or None for"
+			    " dest argument:"
                             " got type %.1024s",
                             Py_TYPE(dest)->tp_name);
     }
     rect_obj = PyRect_New(&r);
-    if (rect_obj != NULL)
-    {
+    if (rect_obj != NULL) {
         rtuple = PyTuple_Pack(2, surface_obj, rect_obj);
         Py_DECREF(rect_obj);
     }
 static PyObject *
 _ftfont_gettransform(PyFreeTypeFont *self)
 {
-    const double scale_factor = 1.5259e-5; /* 1 / 65536.0 */ 
+    const double scale_factor = 1.5259e-5; /* 1 / 65536.0 */
 
-    if (!self->do_transform)
-    {
+    if (!self->do_transform) {
         Py_RETURN_NONE;
     }
     return Py_BuildValue("dddd",
     double yx;
     double yy;
 
-    if (!PyArg_ParseTuple(args, "dddd", &xx, &xy, &yx, &yy))
-    {
+    if (!PyArg_ParseTuple(args, "dddd", &xx, &xy, &yx, &yy)) {
         return NULL;
     }
     /* Sanity check: only accept numbers between -2.0 and 2.0 inclusive */
     if (xx < -2.0 || xx > 2.0 || xy < -2.0 || xy > 2.0 ||
-        yx < -2.0 || yx > 2.0 || yy < -2.0 || yy > 2.0)
-    {
+        yx < -2.0 || yx > 2.0 || yy < -2.0 || yy > 2.0) {
         PyErr_SetString(PyExc_ValueError,
                         "received a value outside range [-2.0,2.0]");
         return NULL;
     }
-    self->transform.xx = (FT_Fixed)(xx * scale_factor);  
+    self->transform.xx = (FT_Fixed)(xx * scale_factor);
     self->transform.xy = (FT_Fixed)(xy * scale_factor);
     self->transform.yx = (FT_Fixed)(yx * scale_factor);
     self->transform.yy = (FT_Fixed)(yy * scale_factor);
     if (!font)
         return NULL;
 
-    if (PGFT_TryLoadFont_Filename(ft, font, filename, face_index) != 0)
-    {
+    if (_PGFT_TryLoadFont_Filename(ft, font, filename, face_index) != 0) {
         return NULL;
     }
 
 {
     FT_Error result = 1;
 
-    if (FREETYPE_MOD_STATE(self)->freetype == NULL)
-    {
-        result = (PGFT_Init(&(FREETYPE_MOD_STATE(self)->freetype), 
+    if (FREETYPE_MOD_STATE(self)->freetype == NULL) {
+        result = (_PGFT_Init(&(FREETYPE_MOD_STATE(self)->freetype),
                             FREETYPE_MOD_STATE(self)->cache_size) == 0);
         if (!result)
             return NULL;
 PyObject *
 _ft_quit(PyObject *self)
 {
-    if (FREETYPE_MOD_STATE(self)->freetype != NULL)
-    {
-        PGFT_Quit(FREETYPE_MOD_STATE(self)->freetype);
+    if (FREETYPE_MOD_STATE(self)->freetype != NULL) {
+        _PGFT_Quit(FREETYPE_MOD_STATE(self)->freetype);
         FREETYPE_MOD_STATE(self)->freetype = NULL;
     }
     Py_RETURN_NONE;
 PyObject *
 _ft_init(PyObject *self, PyObject *args, PyObject *kwds)
 {
-    static char *kwlist[] = 
-    { 
+    static char *kwlist[] =  {
         "cache_size", "resolution", NULL
     };
 
                                      &cache_size, &resolution))
         return NULL;
 
-    if (!state->freetype)
-    {
+    if (!state->freetype) {
         state->resolution = (resolution ?
                              (FT_UInt)resolution : PGFT_DEFAULT_RESOLUTION);
         result = _ft_autoinit(self);
 
-        if (!PyObject_IsTrue(result))
-        {
-            PyErr_SetString(PyExc_RuntimeError, 
+        if (!PyObject_IsTrue(result)) {
+            PyErr_SetString(PyExc_RuntimeError,
                             "Failed to initialize the FreeType2 library");
             return NULL;
         }
     FreeTypeInstance *ft;
     ASSERT_GRAB_FREETYPE(ft, NULL);
 
-    if (ft->_error_msg[0])
-    {
+    if (ft->_error_msg[0]) {
         return Text_FromUTF8(ft->_error_msg);
     }
 
 static int
 _ft_clear (PyObject *mod)
 {
-    if (FREETYPE_MOD_STATE(mod)->freetype)
-    {
-        PGFT_Quit(FREETYPE_MOD_STATE(mod)->freetype);
+    if (FREETYPE_MOD_STATE(mod)->freetype) {
+        _PGFT_Quit(FREETYPE_MOD_STATE(mod)->freetype);
         FREETYPE_MOD_STATE(mod)->freetype = NULL;
     }
     return 0;
  * FREETYPE MODULE DECLARATION
  ****************************************************/
 #if PY3
-struct PyModuleDef _freetypemodule = 
+struct PyModuleDef _freetypemodule =
 {
     PyModuleDef_HEAD_INIT,
     MODULE_NAME,
     DOC_PYGAMEFREETYPE,
     sizeof(_FreeTypeState),
     _ft_methods,
-    NULL, 
-    _ft_traverse, 
-    _ft_clear, 
+    NULL,
+    _ft_traverse,
+    _ft_clear,
     NULL
 };
 #else
     static void* c_api[PYGAMEAPI_FREETYPE_NUMSLOTS];
 
     import_pygame_base();
-    if (PyErr_Occurred())
-    {   
+    if (PyErr_Occurred()) {
         MODINIT_ERROR;
     }
 
     import_pygame_surface();
-    if (PyErr_Occurred()) 
-    {
+    if (PyErr_Occurred())  {
         MODINIT_ERROR;
     }
 
     import_pygame_color();
-    if (PyErr_Occurred()) 
-    {
+    if (PyErr_Occurred())  {
         MODINIT_ERROR;
     }
 
     import_pygame_rwobject();
-    if (PyErr_Occurred()) 
-    {
+    if (PyErr_Occurred())  {
         MODINIT_ERROR;
     }
 
     import_pygame_rect();
-    if (PyErr_Occurred()) 
-    {
+    if (PyErr_Occurred())  {
         MODINIT_ERROR;
     }
 
     }
 
     /* type preparation */
-    if (PyType_Ready(&PyFreeTypeFont_Type) < 0) 
-    {
+    if (PyType_Ready(&PyFreeTypeFont_Type) < 0)  {
         Py_DECREF(pygame_register_quit);
         MODINIT_ERROR;
     }
     module = PyModule_Create(&_freetypemodule);
 #else
     /* TODO: DOC */
-    module = Py_InitModule3(MODULE_NAME, _ft_methods, DOC_PYGAMEFREETYPE); 
+    module = Py_InitModule3(MODULE_NAME, _ft_methods, DOC_PYGAMEFREETYPE);
 #endif
 
-    if (module == NULL) 
-    {
+    if (module == NULL)  {
         Py_DECREF(pygame_register_quit);
         MODINIT_ERROR;
     }
     FREETYPE_MOD_STATE(module)->freetype = NULL;
     FREETYPE_MOD_STATE(module)->cache_size = PGFT_DEFAULT_CACHE_SIZE;
     FREETYPE_MOD_STATE(module)->resolution = PGFT_DEFAULT_RESOLUTION;
-    
+
     Py_INCREF((PyObject *)&PyFreeTypeFont_Type);
     if (PyModule_AddObject(module, FONT_TYPE_NAME,
-                           (PyObject *)&PyFreeTypeFont_Type) == -1) 
-    {
+                           (PyObject *)&PyFreeTypeFont_Type) == -1)  {
         Py_DECREF(pygame_register_quit);
         Py_DECREF((PyObject *) &PyFreeTypeFont_Type);
         DECREF_MOD(module);
     c_api[1] = &PyFreeTypeFont_New;
 
     apiobj = encapsulate_api(c_api, "freetype");
-    if (apiobj == NULL) 
-    {
+    if (apiobj == NULL)  {
         Py_DECREF (pygame_register_quit);
         DECREF_MOD(module);
         MODINIT_ERROR;
     }
 
-    if (PyModule_AddObject(module, PYGAMEAPI_LOCAL_ENTRY, apiobj) == -1) 
-    {
+    if (PyModule_AddObject(module, PYGAMEAPI_LOCAL_ENTRY, apiobj) == -1)  {
         Py_DECREF(pygame_register_quit);
         Py_DECREF(apiobj);
         DECREF_MOD(module);

File src/freetype.h

 #   define IS_PYTHON_3
 #endif
 
-#include <ft2build.h>  
-#include FT_FREETYPE_H 
+#include <ft2build.h>
+#include FT_FREETYPE_H
 #include FT_CACHE_H
 #include FT_XFREE86_H
 #include FT_TRIGONOMETRY_H
  * Global module types
  **********************************************************/
 
-typedef struct
-{
+typedef struct {
     int face_index;
     FT_Open_Args open_args;
 } FontId;
 
-typedef struct
-{
+typedef struct {
     PyObject_HEAD
     FontId id;
     PyObject *path;

File src/freetype/ft_cache.c

 #define MINKEYLEN (sizeof(PGFT_char) + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 4)
 #define KEYLEN ((MINKEYLEN + 3) & 0xFFFC)
 
-typedef union __cachenodekey
-{
+typedef union cachenodekey_ {
     FT_Byte bytes[KEYLEN];
     FT_UInt32 dwords[KEYLEN / 4];
 } CacheNodeKey;
 
-typedef struct __cachenode
-{
+typedef struct cachenode_ {
     FontGlyph glyph;
-    struct __cachenode *next;
+    struct cachenode_ *next;
     CacheNodeKey key;
     FT_UInt32 hash;
 } FontCacheNode;
 
-static FT_UInt32 cache_hash(const CacheNodeKey *key);
-
-static FontCacheNode *Cache_AllocateNode(FontCache *,
-                                         const FontRenderMode *, FT_UInt, void *);
-static void Cache_FreeNode(FontCache *, FontCacheNode *);
-static void set_node_key(CacheNodeKey *key, PGFT_char ch,
-                         const FontRenderMode *render);
-static int equal_node_keys(const CacheNodeKey *a, const CacheNodeKey *b);
+static FT_UInt32 get_hash(const CacheNodeKey *);
+static FontCacheNode *allocate_node(FontCache *,
+                                    const FontRenderMode *,
+                                    FT_UInt, void *);
+static void free_node(FontCache *, FontCacheNode *);
+static void set_node_key(CacheNodeKey *, PGFT_char, const FontRenderMode *);
+static int equal_node_keys(const CacheNodeKey *, const CacheNodeKey *);
 
 const int render_flags_mask = (FT_RFLAG_ANTIALIAS |
                                FT_RFLAG_HINTED |
 {
     int i;
 
-    for (i = 0; i < sizeof(a->dwords) / 4; ++i)
-    {
-        if (a->dwords[i] != b->dwords[i])
-        {
+    for (i = 0; i < sizeof(a->dwords) / 4; ++i) {
+        if (a->dwords[i] != b->dwords[i]) {
             return 0;
         }
     }
 }
 
 static FT_UInt32
-cache_hash(const CacheNodeKey *key)
+get_hash(const CacheNodeKey *key)
 {
     /*
      * Based on the 32 bit x86 MurmurHash3, with the key size a multiple of 4.
 
     int i;
 
-    for (i = (sizeof(key->dwords) / 4); i; --i)
-    {
+    for (i = (sizeof(key->dwords) / 4); i; --i) {
         k1 = blocks[i];
 
         k1 *= c1;
     }
 
     h1 ^= sizeof(key->dwords);
-    
+
     h1 ^= h1 >> 16;
     h1 *= 0x85EBCA6B;
     h1 ^= h1 >> 13;
 }
 
 int
-PGFT_Cache_Init(FreeTypeInstance *ft, FontCache *cache)
+_PGFT_Cache_Init(FreeTypeInstance *ft, FontCache *cache)
 {
     int cache_size = MAX(ft->cache_size - 1, PGFT_MIN_CACHE_SIZE - 1);
     int i;
     for (i=0; i < cache_size; ++i)
         cache->nodes[i] = NULL;
     cache->depths = _PGFT_malloc((size_t)cache_size);
-    if (!cache->depths)
-    {
+    if (!cache->depths) {
         _PGFT_free(cache->nodes);
         cache->nodes = NULL;
         return -1;
     return 0;
 }
 
-void 
-PGFT_Cache_Destroy(FontCache *cache)
+void
+_PGFT_Cache_Destroy(FontCache *cache)
 {
     FT_UInt i;
     FontCacheNode *node, *next;
      * to examine _debug fields.
      */
 
-    if (cache->nodes != NULL)
-    {
-        for (i = 0; i <= cache->size_mask; ++i)
-        {
+    if (cache->nodes != NULL) {
+        for (i = 0; i <= cache->size_mask; ++i) {
             node = cache->nodes[i];
 
-            while (node)
-            {
+            while (node) {
                 next = node->next;
-                Cache_FreeNode(cache, node);
+                free_node(cache, node);
                 node = next;
             }
         }
 }
 
 void
-PGFT_Cache_Cleanup(FontCache *cache)
+_PGFT_Cache_Cleanup(FontCache *cache)
 {
     const FT_Byte MAX_BUCKET_DEPTH = 2;
     FontCacheNode *node, *prev;
     FT_UInt32 i;
 
-    for (i = 0; i <= cache->size_mask; ++i)
-    {
-        while (cache->depths[i] > MAX_BUCKET_DEPTH)
-        {
+    for (i = 0; i <= cache->size_mask; ++i) {
+        while (cache->depths[i] > MAX_BUCKET_DEPTH) {
             node = cache->nodes[i];
             prev = NULL;
 
-            for (;;)
-            {
-                if (!node->next)
-                {
+            for (;;) {
+                if (!node->next) {
 #ifdef PGFT_DEBUG_CACHE
                     cache->_debug_delete_count++;
 #endif
 
-                    prev->next = NULL; 
-                    Cache_FreeNode(cache, node);
+                    prev->next = NULL;
+                    free_node(cache, node);
                     break;
                 }
 
 }
 
 FontGlyph *
-PGFT_Cache_FindGlyph(PGFT_char character, const FontRenderMode *render,
+_PGFT_Cache_FindGlyph(PGFT_char character, const FontRenderMode *render,
                      FontCache *cache, void *internal)
 {
     FontCacheNode **nodes = cache->nodes;
 
     FT_UInt32 hash;
     FT_UInt32 bucket;
-    
+
     set_node_key(&key, character, render);
-    hash = cache_hash(&key);
+    hash = get_hash(&key);
     bucket = hash & cache->size_mask;
     node = nodes[bucket];
     prev = NULL;
 #ifdef PGFT_DEBUG_CACHE
     cache->_debug_access++;
 #endif
-    
-    while (node)
-    {
-        if (equal_node_keys(&node->key, &key))
-        {
-            if (prev)
-            {
+
+    while (node) {
+        if (equal_node_keys(&node->key, &key)) {
+            if (prev) {
                 prev->next = node->next;
                 node->next = nodes[bucket];
                 nodes[bucket] = node;
         node = node->next;
     }
 
-    node = Cache_AllocateNode(cache, render, character, internal);
+    node = allocate_node(cache, render, character, internal);
 
 #ifdef PGFT_DEBUG_CACHE
     cache->_debug_miss++;
 }
 
 static void
-Cache_FreeNode(FontCache *cache, FontCacheNode *node)
+free_node(FontCache *cache, FontCacheNode *node)
 {
     if (node == NULL)
         return;
 }
 
 static FontCacheNode *
-Cache_AllocateNode(FontCache *cache, const FontRenderMode *render, PGFT_char character, void *internal)
+allocate_node(FontCache *cache, const FontRenderMode *render,
+              PGFT_char character, void *internal)
 {
     FontCacheNode *node = _PGFT_malloc(sizeof(FontCacheNode));
     FT_UInt32 bucket;
 
-    if (!node)
-    {
+    if (!node) {
         return NULL;
     }
     memset(node, 0, sizeof(FontCacheNode));
 
-    if (PGFT_LoadGlyph(&node->glyph, character, render, internal))
-    {
+    if (_PGFT_LoadGlyph(&node->glyph, character, render, internal)) {
         goto cleanup;
     }
 
     set_node_key(&node->key, character, render);
-    node->hash = cache_hash(&node->key);
+    node->hash = get_hash(&node->key);
     bucket = node->hash & cache->size_mask;
     node->next = cache->nodes[bucket];
     cache->nodes[bucket] = node;

File src/freetype/ft_pixel.h

     (g) = ((g) << (fmt)->Gloss) + ((g) >> (8 - ((fmt)->Gloss << 1)));   \
     (b) = ((pixel) & (fmt)->Bmask) >> (fmt)->Bshift;                    \
     (b) = ((b) << (fmt)->Bloss) + ((b) >> (8 - ((fmt)->Bloss << 1)));   \
-    if ((fmt)->Amask)                                                   \
-    {                                                                   \
+    if ((fmt)->Amask) {                                                 \
         (a) = ((pixel) & (fmt)->Amask) >> (fmt)->Ashift;                \
         (a) = ((a) << (fmt)->Aloss) + ((a) >> (8 - ((fmt)->Aloss << 1))); \
     }                                                                   \
     (sa) = 255;
 
 #define GET_PIXEL_VALS(pixel, fmt, r, g, b, a)          \
-    if ((fmt)->palette == NULL)                         \
-    {                                                   \
+    if ((fmt)->palette == NULL) {                       \
         GET_RGB_VALS(pixel, fmt, r, g, b, a);           \
     }                                                   \
-    else                                                \
-    {                                                   \
+    else {                                              \
         GET_PALETTE_VALS (pixel, fmt, r, g, b, a);      \
     }
 

File src/freetype/ft_render.c

 #include FT_MODULE_H
 #include FT_OUTLINE_H
 
-static int _PGFT_Render_INTERNAL(FreeTypeInstance *ft, PyFreeTypeFont *font, 
-                                 FontText *text, const FontRenderMode *render,
-                                 FontColor *fg_color, FontSurface *surface);
+static int render(FreeTypeInstance *, PyFreeTypeFont *,
+                  FontText *, const FontRenderMode *,
+                  FontColor *, FontSurface *);
 
-int PGFT_CheckStyle(FT_UInt32 style)
+int
+_PGFT_CheckStyle(FT_UInt32 style)
 {
     const FT_UInt32 max_style =
         FT_STYLE_NORMAL |
         FT_STYLE_UNDERSCORE |
         FT_STYLE_WIDE;
 
-    return (style > max_style);
+    return style > max_style;
 }
 
-int 
-PGFT_BuildRenderMode(FreeTypeInstance *ft, 
-        PyFreeTypeFont *font, FontRenderMode *mode, 
-        int pt_size, int style, int rotation)
+int
+_PGFT_BuildRenderMode(FreeTypeInstance *ft, 
+                      PyFreeTypeFont *font, FontRenderMode *mode, 
+                      int pt_size, int style, int rotation)
 {
     int angle;
 
-    if (pt_size == -1)
-    {
-        if (font->ptsize == -1)
-        {
+    if (pt_size == -1) {
+        if (font->ptsize == -1) {
             RAISE(PyExc_ValueError,
                   "No font point size specified"
                   " and no default font size in typeface");
         pt_size = font->ptsize;
     }
 
-    if (pt_size <= 0)
-    {
+    if (pt_size <= 0) {
         RAISE(PyExc_ValueError, "Invalid point size for font.");
         return -1;
     }
 
     mode->pt_size = (FT_UInt16)pt_size;
 
-    if (style == FT_STYLE_DEFAULT)
-    {
+    if (style == FT_STYLE_DEFAULT) {
         mode->style = (FT_Byte)font->style;
     }
-    else
-    {
-        if (PGFT_CheckStyle((FT_UInt32)style) != 0)
-        {
+    else {
+        if (_PGFT_CheckStyle((FT_UInt32)style) != 0) {
             RAISE(PyExc_ValueError, "Invalid style value");
             return -1;
         }
         mode->render_flags |= FT_RFLAG_TRANSFORM;
     mode->transform = font->transform;
 
-    if (mode->rotation_angle != 0)
-    {
-        if (mode->style & FT_STYLE_WIDE)
-        {
+    if (mode->rotation_angle != 0) {
+        if (mode->style & FT_STYLE_WIDE) {
             RAISE(PyExc_ValueError,
                   "the wide style is unsupported for rotated text");
             return -1;
         }
-        if (mode->style & FT_STYLE_UNDERLINE)
-        {
+        if (mode->style & FT_STYLE_UNDERLINE) {
             RAISE(PyExc_ValueError,
                   "the underline style is unsupported for rotated text");
             return -1;
         }
-        if (mode->style & FT_STYLE_UNDERSCORE)
-        {
+        if (mode->style & FT_STYLE_UNDERSCORE) {
             RAISE(PyExc_ValueError,
                   "the underscore style is unsupported for rotated text");
             return -1;
         }
-        if (mode->render_flags & FT_RFLAG_PAD) 
-        {
+        if (mode->render_flags & FT_RFLAG_PAD) {
             RAISE(PyExc_ValueError,
                   "padding is unsupported for rotated text");
             return -1;
         }
     }
 
-    if (mode->render_flags & FT_RFLAG_VERTICAL)
-    {
-        if (mode->style & FT_STYLE_UNDERLINE)
-        {
+    if (mode->render_flags & FT_RFLAG_VERTICAL) {
+        if (mode->style & FT_STYLE_UNDERLINE) {
             RAISE(PyExc_ValueError,
                   "the underline style is unsupported for vertical text");
             return -1;
         }
-        if (mode->style & FT_STYLE_UNDERSCORE)
-        {
+        if (mode->style & FT_STYLE_UNDERSCORE) {
             RAISE(PyExc_ValueError,
                   "the underscore style is unsupported for vertical text");
             return -1;
  *
  *********************************************************/
 #ifdef HAVE_PYGAME_SDL_VIDEO
-int PGFT_Render_ExistingSurface(
-    FreeTypeInstance *ft, PyFreeTypeFont *font,
-    const FontRenderMode *render, PGFT_String *text, SDL_Surface *surface,
-    int x, int y, FontColor *fgcolor, FontColor *bgcolor, SDL_Rect *r)
+int
+_PGFT_Render_ExistingSurface(FreeTypeInstance *ft, PyFreeTypeFont *font,
+                             const FontRenderMode *mode, PGFT_String *text,
+                             SDL_Surface *surface, int x, int y,
+                             FontColor *fgcolor, FontColor *bgcolor,
+                             SDL_Rect *r)
 {
-    static const FontRenderPtr __SDLrenderFuncs[] =
-    {
+    static const FontRenderPtr __SDLrenderFuncs[] = {
         NULL,
         __render_glyph_RGB1,
         __render_glyph_RGB2,
         __render_glyph_RGB4
     };
 
-    static const FontRenderPtr __MONOrenderFuncs[] =
-    {
+    static const FontRenderPtr __MONOrenderFuncs[] = {
         NULL,
         __render_glyph_MONO1,
         __render_glyph_MONO2,
         __render_glyph_MONO4
     };
 
-    static const FontFillPtr __RGBfillFuncs[] =
-    {
+    static const FontFillPtr __RGBfillFuncs[] = {
         NULL,
         __fill_glyph_RGB1,
         __fill_glyph_RGB2,
         __fill_glyph_RGB4
     };
 
-    int         locked = 0;
-    int         width, height;
+    int locked = 0;
+    int width, height;
 
     FontSurface font_surf;
-    FontText    *font_text;
+    FontText *font_text;
 
-    if (PGFT_String_GET_LENGTH(text) == 0)
-    {
+    if (PGFT_String_GET_LENGTH(text) == 0) {
         /* No rendering */
         r->x = 0;
         r->y = 0;
         r->w = 0;
-        r->h = PGFT_Face_GetHeightSized(ft, font, render->pt_size);
+        r->h = _PGFT_Face_GetHeightSized(ft, font, mode->pt_size);
         return 0;
     }
 
-    if (SDL_MUSTLOCK(surface))
-    {
-        if (SDL_LockSurface(surface) == -1)
-        {
+    if (SDL_MUSTLOCK(surface)) {
+        if (SDL_LockSurface(surface) == -1) {
             SDL_FreeSurface(surface);
             RAISE(PyExc_SDLError, SDL_GetError());
             return -1;
     }
 
     /* build font text */
-    font_text = PGFT_LoadFontText(ft, font, render, text);
+    font_text = _PGFT_LoadFontText(ft, font, mode, text);
 
-    if (!font_text)
-    {
+    if (!font_text) {
         if (locked)
             SDL_UnlockSurface(surface);
         return -1;
 
     width = font_text->width;
     height = font_text->height;
-    if (PGFT_GetSurfaceSize(ft, font, render, font_text, &width, &height) != 0)
-    {
+    if (_PGFT_GetSurfaceSize(ft, font, mode, font_text, &width, &height)) {
         if (locked)
             SDL_UnlockSurface(surface);
         return -1;
     }
 
-    if (width <= 0 || height <= 0)
-    {
+    if (width <= 0 || height <= 0) {
         /* Nothing more to do. */
         if (locked)
             SDL_UnlockSurface(surface);
-	r->x = 0;
-	r->y = 0;
-	r->w = 0;
-        r->h = PGFT_Face_GetHeightSized(ft, font, render->pt_size);
+        r->x = 0;
+        r->y = 0;
+        r->w = 0;
+        r->h = _PGFT_Face_GetHeightSized(ft, font, mode->pt_size);
         return 0;
     }
-    
+
     /*
      * Setup target surface struct
      */
     font_surf.buffer = surface->pixels;
     font_surf.offset.x = PGFT_INT_TO_6(x);
     font_surf.offset.y = PGFT_INT_TO_6(y);
-    if (font->origin)
-    {
+    if (font->origin) {
         x -= PGFT_TRUNC(PGFT_CEIL(font_text->offset.x));
         y -= PGFT_TRUNC(PGFT_CEIL(font_text->offset.y));
     }
-    else
-    {
+    else {
         font_surf.offset.x += font_text->offset.x;
         font_surf.offset.y += font_text->offset.y;
     }
     font_surf.render_mono = __MONOrenderFuncs[surface->format->BytesPerPixel];
     font_surf.fill = __RGBfillFuncs[surface->format->BytesPerPixel];
 
-    /* 
-     * if bg color exists, paint background 
+    /*
+     * if bg color exists, paint background
      */
-    if (bgcolor)
-    {
-        if (bgcolor->a == 0xFF)
-        {
-            SDL_Rect    bg_fill; 
+    if (bgcolor) {
+        if (bgcolor->a == 0xFF) {
+            SDL_Rect    bg_fill;
             FT_UInt32   fillcolor;
 
-            fillcolor = SDL_MapRGBA(surface->format, 
+            fillcolor = SDL_MapRGBA(surface->format,
                     bgcolor->r, bgcolor->g, bgcolor->b, bgcolor->a);
 
             bg_fill.x = (FT_Int16)x;
 
             SDL_FillRect(surface, &bg_fill, fillcolor);
         }
-        else
-        {
+        else {
             font_surf.fill(x, y, width, height, &font_surf, bgcolor);
         }
     }
     /*
      * Render!
      */
-    if (_PGFT_Render_INTERNAL(ft, font, font_text, render, fgcolor, &font_surf))
-    {
+    if (render(ft, font, font_text, mode, fgcolor, &font_surf)) {
         if (locked)
             SDL_UnlockSurface(surface);
         return -1;
     return 0;
 }
 
-SDL_Surface *PGFT_Render_NewSurface(FreeTypeInstance *ft, PyFreeTypeFont *font, 
-    const FontRenderMode *render, PGFT_String *text,
-    FontColor *fgcolor, FontColor *bgcolor, SDL_Rect *r)
+SDL_Surface *_PGFT_Render_NewSurface(FreeTypeInstance *ft, PyFreeTypeFont *font,