Revision: 5071
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5071&view=rev
Author:   mdboom
Date:     2008-04-24 06:23:05 -0700 (Thu, 24 Apr 2008)

Log Message:
-----------
Remove a bunch of compiler warnings.

Modified Paths:
--------------
    trunk/matplotlib/CXX/WrapPython.h
    trunk/matplotlib/agg24/src/agg_curves.cpp
    trunk/matplotlib/src/_backend_agg.cpp
    trunk/matplotlib/src/_gtkagg.cpp
    trunk/matplotlib/src/_image.cpp
    trunk/matplotlib/src/_path.cpp
    trunk/matplotlib/src/_ttconv.cpp
    trunk/matplotlib/src/ft2font.cpp
    trunk/matplotlib/src/ft2font.h
    trunk/matplotlib/ttconv/pprdrv_tt.cpp

Modified: trunk/matplotlib/CXX/WrapPython.h
===================================================================
--- trunk/matplotlib/CXX/WrapPython.h   2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/CXX/WrapPython.h   2008-04-24 13:23:05 UTC (rev 5071)
@@ -38,12 +38,13 @@
 #ifndef __PyCXX_wrap_python_hxx__
 #define __PyCXX_wrap_python_hxx__
 
+// pull in python definitions
+#include <Python.h>
+
 // On some platforms we have to include time.h to get select defined
 #if !defined(__WIN32__) && !defined(WIN32) && !defined(_WIN32) && 
!defined(_WIN64)
 #include <sys/time.h>
 #endif
 
-// pull in python definitions
-#include <Python.h>
 
 #endif

Modified: trunk/matplotlib/agg24/src/agg_curves.cpp
===================================================================
--- trunk/matplotlib/agg24/src/agg_curves.cpp   2008-04-24 12:54:25 UTC (rev 
5070)
+++ trunk/matplotlib/agg24/src/agg_curves.cpp   2008-04-24 13:23:05 UTC (rev 
5071)
@@ -2,8 +2,8 @@
 // Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
-// Permission to copy, use, modify, sell and distribute this software 
-// is granted provided this copyright notice appears in all copies. 
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
 // This software is provided "as is" without express or implied
 // warranty, and with no claim as to its suitability for any purpose.
 //
@@ -29,20 +29,20 @@
 
 
     //------------------------------------------------------------------------
-    void curve3_inc::approximation_scale(double s) 
-    { 
+    void curve3_inc::approximation_scale(double s)
+    {
         m_scale = s;
     }
 
     //------------------------------------------------------------------------
-    double curve3_inc::approximation_scale() const 
-    { 
+    double curve3_inc::approximation_scale() const
+    {
         return m_scale;
     }
 
     //------------------------------------------------------------------------
-    void curve3_inc::init(double x1, double y1, 
-                          double x2, double y2, 
+    void curve3_inc::init(double x1, double y1,
+                          double x2, double y2,
                           double x3, double y3)
     {
         m_start_x = x1;
@@ -55,13 +55,13 @@
         double dx2 = x3 - x2;
         double dy2 = y3 - y2;
 
-        double len = sqrt(dx1 * dx1 + dy1 * dy1) + sqrt(dx2 * dx2 + dy2 * 
dy2); 
+        double len = sqrt(dx1 * dx1 + dy1 * dy1) + sqrt(dx2 * dx2 + dy2 * dy2);
 
         m_num_steps = uround(len * 0.25 * m_scale);
 
         if(m_num_steps < 4)
         {
-            m_num_steps = 4;   
+            m_num_steps = 4;
         }
 
         double subdivide_step  = 1.0 / m_num_steps;
@@ -72,7 +72,7 @@
 
         m_saved_fx = m_fx = x1;
         m_saved_fy = m_fy = y1;
-        
+
         m_saved_dfx = m_dfx = tmpx + (x2 - x1) * (2.0 * subdivide_step);
         m_saved_dfy = m_dfy = tmpy + (y2 - y1) * (2.0 * subdivide_step);
 
@@ -115,10 +115,10 @@
             --m_step;
             return path_cmd_line_to;
         }
-        m_fx  += m_dfx; 
+        m_fx  += m_dfx;
         m_fy  += m_dfy;
-        m_dfx += m_ddfx; 
-        m_dfy += m_ddfy; 
+        m_dfx += m_ddfx;
+        m_dfy += m_ddfy;
         *x = m_fx;
         *y = m_fy;
         --m_step;
@@ -126,8 +126,8 @@
     }
 
     //------------------------------------------------------------------------
-    void curve3_div::init(double x1, double y1, 
-                          double x2, double y2, 
+    void curve3_div::init(double x1, double y1,
+                          double x2, double y2,
                           double x3, double y3)
     {
         m_points.remove_all();
@@ -138,19 +138,19 @@
     }
 
     //------------------------------------------------------------------------
-    void curve3_div::recursive_bezier(double x1, double y1, 
-                                      double x2, double y2, 
+    void curve3_div::recursive_bezier(double x1, double y1,
+                                      double x2, double y2,
                                       double x3, double y3,
                                       unsigned level)
     {
-        if(level > curve_recursion_limit) 
+        if(level > curve_recursion_limit)
         {
             return;
         }
 
         // Calculate all the mid-points of the line segments
         //----------------------
-        double x12   = (x1 + x2) / 2;                
+        double x12   = (x1 + x2) / 2;
         double y12   = (y1 + y2) / 2;
         double x23   = (x2 + x3) / 2;
         double y23   = (y2 + y3) / 2;
@@ -163,7 +163,7 @@
         double da;
 
         if(d > curve_collinearity_epsilon)
-        { 
+        {
             // Regular case
             //-----------------
             if(d * d <= m_distance_tolerance_square * (dx*dx + dy*dy))
@@ -187,7 +187,7 @@
                     // Finally we can stop the recursion
                     //----------------------
                     m_points.add(point_d(x123, y123));
-                    return;                 
+                    return;
                 }
             }
         }
@@ -222,13 +222,13 @@
 
         // Continue subdivision
         //----------------------
-        recursive_bezier(x1, y1, x12, y12, x123, y123, level + 1); 
-        recursive_bezier(x123, y123, x23, y23, x3, y3, level + 1); 
+        recursive_bezier(x1, y1, x12, y12, x123, y123, level + 1);
+        recursive_bezier(x123, y123, x23, y23, x3, y3, level + 1);
     }
 
     //------------------------------------------------------------------------
-    void curve3_div::bezier(double x1, double y1, 
-                            double x2, double y2, 
+    void curve3_div::bezier(double x1, double y1,
+                            double x2, double y2,
                             double x3, double y3)
     {
         m_points.add(point_d(x1, y1));
@@ -241,23 +241,25 @@
 
 
     //------------------------------------------------------------------------
-    void curve4_inc::approximation_scale(double s) 
-    { 
+    void curve4_inc::approximation_scale(double s)
+    {
         m_scale = s;
     }
 
     //------------------------------------------------------------------------
-    double curve4_inc::approximation_scale() const 
-    { 
+    double curve4_inc::approximation_scale() const
+    {
         return m_scale;
     }
 
     //------------------------------------------------------------------------
+#if defined(_MSC_VER) && _MSC_VER <= 1200
     static double MSC60_fix_ICE(double v) { return v; }
+#endif
 
     //------------------------------------------------------------------------
-    void curve4_inc::init(double x1, double y1, 
-                          double x2, double y2, 
+    void curve4_inc::init(double x1, double y1,
+                          double x2, double y2,
                           double x3, double y3,
                           double x4, double y4)
     {
@@ -273,8 +275,8 @@
         double dx3 = x4 - x3;
         double dy3 = y4 - y3;
 
-        double len = (sqrt(dx1 * dx1 + dy1 * dy1) + 
-                      sqrt(dx2 * dx2 + dy2 * dy2) + 
+        double len = (sqrt(dx1 * dx1 + dy1 * dy1) +
+                      sqrt(dx2 * dx2 + dy2 * dy2) +
                       sqrt(dx3 * dx3 + dy3 * dy3)) * 0.25 * m_scale;
 
 #if defined(_MSC_VER) && _MSC_VER <= 1200
@@ -285,7 +287,7 @@
 
         if(m_num_steps < 4)
         {
-            m_num_steps = 4;   
+            m_num_steps = 4;
         }
 
         double subdivide_step  = 1.0 / m_num_steps;
@@ -296,7 +298,7 @@
         double pre2 = 3.0 * subdivide_step2;
         double pre4 = 6.0 * subdivide_step2;
         double pre5 = 6.0 * subdivide_step3;
-       
+
         double tmp1x = x1 - x2 * 2.0 + x3;
         double tmp1y = y1 - y2 * 2.0 + y3;
 
@@ -357,10 +359,10 @@
 
         m_fx   += m_dfx;
         m_fy   += m_dfy;
-        m_dfx  += m_ddfx; 
-        m_dfy  += m_ddfy; 
-        m_ddfx += m_dddfx; 
-        m_ddfy += m_dddfy; 
+        m_dfx  += m_ddfx;
+        m_dfy  += m_ddfy;
+        m_ddfx += m_dddfx;
+        m_ddfy += m_dddfy;
 
         *x = m_fx;
         *y = m_fy;
@@ -372,8 +374,8 @@
 
 
     //------------------------------------------------------------------------
-    void curve4_div::init(double x1, double y1, 
-                          double x2, double y2, 
+    void curve4_div::init(double x1, double y1,
+                          double x2, double y2,
                           double x3, double y3,
                           double x4, double y4)
     {
@@ -385,13 +387,13 @@
     }
 
     //------------------------------------------------------------------------
-    void curve4_div::recursive_bezier(double x1, double y1, 
-                                      double x2, double y2, 
-                                      double x3, double y3, 
+    void curve4_div::recursive_bezier(double x1, double y1,
+                                      double x2, double y2,
+                                      double x3, double y3,
                                       double x4, double y4,
                                       unsigned level)
     {
-        if(level > curve_recursion_limit) 
+        if(level > curve_recursion_limit)
         {
             return;
         }
@@ -542,7 +544,7 @@
             }
             break;
 
-        case 3: 
+        case 3:
             // Regular case
             //-----------------
             if((d2 + d3)*(d2 + d3) <= m_distance_tolerance_square * (dx*dx + 
dy*dy))
@@ -592,14 +594,14 @@
 
         // Continue subdivision
         //----------------------
-        recursive_bezier(x1, y1, x12, y12, x123, y123, x1234, y1234, level + 
1); 
-        recursive_bezier(x1234, y1234, x234, y234, x34, y34, x4, y4, level + 
1); 
+        recursive_bezier(x1, y1, x12, y12, x123, y123, x1234, y1234, level + 
1);
+        recursive_bezier(x1234, y1234, x234, y234, x34, y34, x4, y4, level + 
1);
     }
 
     //------------------------------------------------------------------------
-    void curve4_div::bezier(double x1, double y1, 
-                            double x2, double y2, 
-                            double x3, double y3, 
+    void curve4_div::bezier(double x1, double y1,
+                            double x2, double y2,
+                            double x3, double y3,
                             double x4, double y4)
     {
         m_points.add(point_d(x1, y1));

Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp       2008-04-24 12:54:25 UTC (rev 
5070)
+++ trunk/matplotlib/src/_backend_agg.cpp       2008-04-24 13:23:05 UTC (rev 
5071)
@@ -1,12 +1,22 @@
 /* A rewrite of _backend_agg using PyCXX to handle ref counting, etc..
  */
+#include <png.h>
 
+// To remove a gcc warning
+#ifdef _POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#endif
+
+#include "ft2font.h"
+#include "_image.h"
+#include "_backend_agg.h"
+#include "mplutils.h"
+
 #include <iostream>
 #include <fstream>
 #include <cmath>
 #include <cstdio>
 #include <stdexcept>
-#include <png.h>
 #include <time.h>
 #include <algorithm>
 
@@ -23,11 +33,6 @@
 #include "agg_conv_shorten_path.h"
 #include "util/agg_color_conv_rgb8.h"
 
-#include "ft2font.h"
-#include "_image.h"
-#include "_backend_agg.h"
-#include "mplutils.h"
-
 #include "swig_runtime.h"
 #include "MPL_isnan.h"
 
@@ -295,8 +300,8 @@
 
 SnapData
 SafeSnap::snap (const float& x, const float& y) {
-  xsnap = (int)x + 0.5;
-  ysnap = (int)y + 0.5;
+  xsnap = (int)(x + 0.5f);
+  ysnap = (int)(y + 0.5f);
 
   if ( first || ( (xsnap!=lastxsnap) || (ysnap!=lastysnap) ) ) {
     lastxsnap = xsnap;
@@ -737,8 +742,8 @@
 
   args.verify_length(4, 6);
 
-  float x = Py::Float(args[0]);
-  float y = Py::Float(args[1]);
+  double x = Py::Float(args[0]);
+  double y = Py::Float(args[1]);
   Image *image = static_cast<Image*>(args[2].ptr());
   Py::Object box_obj = args[3];
   Py::Object clippath;

Modified: trunk/matplotlib/src/_gtkagg.cpp
===================================================================
--- trunk/matplotlib/src/_gtkagg.cpp    2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/src/_gtkagg.cpp    2008-04-24 13:23:05 UTC (rev 5071)
@@ -1,3 +1,6 @@
+#include <pygobject.h>
+#include <pygtk/pygtk.h>
+
 #include <cstring>
 #include <cerrno>
 #include <cstdio>
@@ -6,10 +9,6 @@
 #include <utility>
 #include <fstream>
 
-
-#include <pygobject.h>
-#include <pygtk/pygtk.h>
-
 #include "agg_basics.h"
 #include "_backend_agg.h"
 #define PY_ARRAY_TYPES_PREFIX NumPy

Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp     2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/src/_image.cpp     2008-04-24 13:23:05 UTC (rev 5071)
@@ -1,3 +1,6 @@
+#include "Python.h" //after png.h due to setjmp bug
+#include <string>
+
 #include <iostream>
 #include <fstream>
 #include <cmath>
@@ -4,9 +7,6 @@
 #include <cstdio>
 #include <png.h>
 
-#include "Python.h" //after png.h due to setjmp bug
-#include <string>
-
 #define PY_ARRAY_TYPES_PREFIX NumPy
 #include "numpy/arrayobject.h"
 
@@ -936,10 +936,10 @@
       png_byte* ptr = (rgba) ? &(row[x*4]) : &(row[x*3]);
       size_t offset = y*A->strides[0] + x*A->strides[1];
       //if ((y<10)&&(x==10)) std::cout << "r = " << ptr[0] << " " << 
ptr[0]/255.0 << std::endl;
-      *(float*)(A->data + offset + 0*A->strides[2]) = ptr[0]/255.0;
-      *(float*)(A->data + offset + 1*A->strides[2]) = ptr[1]/255.0;
-      *(float*)(A->data + offset + 2*A->strides[2]) = ptr[2]/255.0;
-      *(float*)(A->data + offset + 3*A->strides[2]) = rgba ? ptr[3]/255.0 : 
1.0;
+      *(float*)(A->data + offset + 0*A->strides[2]) = (float)(ptr[0]/255.0f);
+      *(float*)(A->data + offset + 1*A->strides[2]) = (float)(ptr[1]/255.0f);
+      *(float*)(A->data + offset + 2*A->strides[2]) = (float)(ptr[2]/255.0f);
+      *(float*)(A->data + offset + 3*A->strides[2]) = rgba ? 
(float)(ptr[3]/255.0f) : 1.0f;
     }
   }
 
@@ -1434,7 +1434,7 @@
       while(xs2 != xl && xo > xm) {
           xs1 = xs2;
           xs2 = xs1+1;
-          xm = 0.5*(*xs1 + *xs2);
+          xm = 0.5f*(*xs1 + *xs2);
           j++;
       }
       *colstart = j - j_last;
@@ -1447,7 +1447,7 @@
       while(ys2 != yl && yo > ym) {
           ys1 = ys2;
           ys2 = ys1+1;
-          ym = 0.5*(*ys1 + *ys2);
+          ym = 0.5f*(*ys1 + *ys2);
           j++;
       }
       *rowstart = j - j_last;

Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp      2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/src/_path.cpp      2008-04-24 13:23:05 UTC (rev 5071)
@@ -1,9 +1,9 @@
+#include "agg_py_path_iterator.h"
+#include "agg_py_transforms.h"
+
 #include <limits>
 #include <math.h>
 
-#include "agg_py_path_iterator.h"
-#include "agg_py_transforms.h"
-
 #include "CXX/Extensions.hxx"
 
 #include "agg_conv_curve.h"

Modified: trunk/matplotlib/src/_ttconv.cpp
===================================================================
--- trunk/matplotlib/src/_ttconv.cpp    2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/src/_ttconv.cpp    2008-04-24 13:23:05 UTC (rev 5071)
@@ -83,11 +83,11 @@
   int                  fonttype;
   std::vector<int>     glyph_ids;
 
-  static const char *kwlist[] = { 
+  static const char *kwlist[] = {
     "filename", "output", "fonttype", "glyph_ids", NULL };
   if (! PyArg_ParseTupleAndKeywords
-      (args, kwds, 
-       "sO&i|O&:convert_ttf_to_ps", 
+      (args, kwds,
+       "sO&i|O&:convert_ttf_to_ps",
        (char**)kwlist,
        &filename,
        fileobject_to_PythonFileWriter,
@@ -96,9 +96,9 @@
        pyiterable_to_vector_int,
        &glyph_ids))
     return NULL;
-  
+
   if (fonttype != 3 && fonttype != 42) {
-    PyErr_SetString(PyExc_ValueError, 
+    PyErr_SetString(PyExc_ValueError,
                    "fonttype must be either 3 (raw Postscript) or 42 "
                    "(embedded Truetype)");
     return NULL;
@@ -109,7 +109,7 @@
   } catch (TTException& e) {
     PyErr_SetString(PyExc_RuntimeError, e.getMessage());
     return NULL;
-  } catch (PythonExceptionOccurred& e) {
+  } catch (PythonExceptionOccurred& ) {
     return NULL;
   } catch (...) {
     PyErr_SetString(PyExc_RuntimeError, "Unknown C++ exception");
@@ -144,8 +144,8 @@
 
   static const char *kwlist[] = { "filename", "glyph_ids", NULL };
   if (! PyArg_ParseTupleAndKeywords
-      (args, kwds, 
-       "s|O&:convert_ttf_to_ps", 
+      (args, kwds,
+       "s|O&:convert_ttf_to_ps",
        (char **)kwlist,
        &filename,
        pyiterable_to_vector_int,
@@ -163,7 +163,7 @@
   } catch (TTException& e) {
     PyErr_SetString(PyExc_RuntimeError, e.getMessage());
     return NULL;
-  } catch (PythonExceptionOccurred& e) {
+  } catch (PythonExceptionOccurred& ) {
     return NULL;
   } catch (...) {
     PyErr_SetString(PyExc_RuntimeError, "Unknown C++ exception");
@@ -174,7 +174,7 @@
 }
 
 static PyMethodDef ttconv_methods[] = {
-  {"convert_ttf_to_ps", (PyCFunction)convert_ttf_to_ps, METH_KEYWORDS, 
+  {"convert_ttf_to_ps", (PyCFunction)convert_ttf_to_ps, METH_KEYWORDS,
    "convert_ttf_to_ps(filename, output, fonttype, glyph_ids)\n"
    "\n"
    "Converts the Truetype font into a Type 3 or Type 42 Postscript font, "
@@ -191,7 +191,7 @@
    "then all glyphs will be included.  If any of the glyphs specified are "
    "composite glyphs, then the component glyphs will also be included."
   },
-  {"get_pdf_charprocs", (PyCFunction)py_get_pdf_charprocs, METH_KEYWORDS, 
+  {"get_pdf_charprocs", (PyCFunction)py_get_pdf_charprocs, METH_KEYWORDS,
    "get_pdf_charprocs(filename, glyph_ids)\n"
    "\n"
    "Given a Truetype font file, returns a dictionary containing the PDF Type 
3\n"
@@ -211,7 +211,7 @@
 #define PyMODINIT_FUNC void
 #endif
 PyMODINIT_FUNC
-initttconv(void) 
+initttconv(void)
 {
     PyObject* m;
 

Modified: trunk/matplotlib/src/ft2font.cpp
===================================================================
--- trunk/matplotlib/src/ft2font.cpp    2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/src/ft2font.cpp    2008-04-24 13:23:05 UTC (rev 5071)
@@ -1,6 +1,6 @@
-#include <sstream>
 #include "ft2font.h"
 #include "mplutils.h"
+#include <sstream>
 
 #define FIXED_MAJOR(val) (*((short *) &val+1))
 #define FIXED_MINOR(val) (*((short *) &val+0))

Modified: trunk/matplotlib/src/ft2font.h
===================================================================
--- trunk/matplotlib/src/ft2font.h      2008-04-24 12:54:25 UTC (rev 5070)
+++ trunk/matplotlib/src/ft2font.h      2008-04-24 13:23:05 UTC (rev 5071)
@@ -1,6 +1,8 @@
 /* A python interface to freetype2 */
 #ifndef _FT2FONT_H
 #define _FT2FONT_H
+#include "CXX/Extensions.hxx"
+#include "CXX/Objects.hxx"
 #include <iostream>
 #include <vector>
 #include <string>
@@ -15,8 +17,6 @@
 #include FT_TYPE1_TABLES_H
 #include FT_TRUETYPE_TABLES_H
 }
-#include "CXX/Extensions.hxx"
-#include "CXX/Objects.hxx"
 
 
 // the freetype string rendered into a width, height buffer

Modified: trunk/matplotlib/ttconv/pprdrv_tt.cpp
===================================================================
--- trunk/matplotlib/ttconv/pprdrv_tt.cpp       2008-04-24 12:54:25 UTC (rev 
5070)
+++ trunk/matplotlib/ttconv/pprdrv_tt.cpp       2008-04-24 13:23:05 UTC (rev 
5071)
@@ -16,7 +16,7 @@
 ** documentation.  This software is provided "as is" without express or
 ** implied warranty.
 **
-** TrueType font support.  These functions allow PPR to generate 
+** TrueType font support.  These functions allow PPR to generate
 ** PostScript fonts from Microsoft compatible TrueType font files.
 **
 ** Last revised 19 December 1995.
@@ -31,7 +31,7 @@
 #include <sstream>
 
 /*==========================================================================
-** Convert the indicated Truetype font file to a type 42 or type 3 
+** Convert the indicated Truetype font file to a type 42 or type 3
 ** PostScript font and insert it in the output stream.
 **
 ** All the routines from here to the end of file file are involved
@@ -42,7 +42,7 @@
 ** Endian conversion routines.
 ** These routines take a BYTE pointer
 ** and return a value formed by reading
-** bytes starting at that point. 
+** bytes starting at that point.
 **
 ** These routines read the big-endian
 ** values which are used in TrueType
@@ -55,14 +55,14 @@
 ULONG getULONG(BYTE *p)
     {
     int x;
-    ULONG val=0;    
+    ULONG val=0;
 
     for(x=0; x<4; x++)
        {
        val *= 0x100;
-       val += p[x];    
+       val += p[x];
        }
-    
+
     return val;
     } /* end of ftohULONG() */
 
@@ -72,14 +72,14 @@
 USHORT getUSHORT(BYTE *p)
     {
     int x;
-    USHORT val=0;    
+    USHORT val=0;
 
     for(x=0; x<2; x++)
        {
        val *= 0x100;
-       val += p[x];    
+       val += p[x];
        }
-    
+
     return val;
     } /* end of getUSHORT() */
 
@@ -92,7 +92,7 @@
     Fixed val={0,0};
 
     val.whole = ((s[0] * 256) + s[1]);
-    val.fraction = ((s[2] * 256) + s[3]);    
+    val.fraction = ((s[2] * 256) + s[3]);
 
     return val;
     } /* end of getFixed() */
@@ -102,16 +102,16 @@
 ** The font's "file" and "offset_table" fields must be set before this
 ** routine is called.
 **
-** This first argument is a TrueType font structure, the second 
+** This first argument is a TrueType font structure, the second
 ** argument is the name of the table to retrieve.  A table name
-** is always 4 characters, though the last characters may be 
+** is always 4 characters, though the last characters may be
 ** padding spaces.
 -----------------------------------------------------------------------*/
 BYTE *GetTable(struct TTFONT *font, const char *name)
     {
     BYTE *ptr;
     ULONG x;
-    
+
     #ifdef DEBUG_TRUETYPE
     debug("GetTable(file,font,\"%s\")",name);
     #endif
@@ -127,20 +127,20 @@
            BYTE *table;
 
            offset = getULONG( ptr + 8 );
-           length = getULONG( ptr + 12 );          
+           length = getULONG( ptr + 12 );
            table = (BYTE*)calloc( sizeof(BYTE), length );
 
            try {
 #ifdef DEBUG_TRUETYPE
              debug("Loading table \"%s\" from offset %d, %d 
bytes",name,offset,length);
 #endif
-             
+
              if( fseek( font->file, (long)offset, SEEK_SET ) )
                throw TTException("TrueType font may be corrupt (reason 3)");
-             
+
              if( fread(table,sizeof(BYTE),length,font->file) != (sizeof(BYTE) 
* length))
                throw TTException("TrueType font may be corrupt (reason 4)");
-           } catch (TTException& e) {
+           } catch (TTException& ) {
              free(table);
              throw;
            }
@@ -156,7 +156,7 @@
     } /* end of GetTable() */
 
 /*--------------------------------------------------------------------
-** Load the 'name' table, get information from it, 
+** Load the 'name' table, get information from it,
 ** and store that information in the font structure.
 **
 ** The 'name' table contains information such as the name of
@@ -171,7 +171,7 @@
     int platform,encoding;             /* Current platform id, encoding id, */
     int language,nameid;               /* language id, name id, */
     int offset,length;                 /* offset and length of string. */
-    
+
     #ifdef DEBUG_TRUETYPE
     debug("Read_name()");
     #endif
@@ -188,7 +188,7 @@
     try {
       numrecords = getUSHORT( table_ptr + 2 ); /* number of names */
       strings = table_ptr + getUSHORT( table_ptr + 4 );        /* start of 
string storage */
-    
+
       ptr2 = table_ptr + 6;
       for(x=0; x < numrecords; x++,ptr2+=12)
        {
@@ -202,7 +202,7 @@
 #ifdef DEBUG_TRUETYPE
          debug("platform %d, encoding %d, language 0x%x, name %d, offset %d, 
length %d",
                platform,encoding,language,nameid,offset,length);
-#endif         
+#endif
 
          /* Copyright notice */
          if( platform == 1 && nameid == 0 )
@@ -211,14 +211,14 @@
              strncpy(font->Copyright,(const char*)strings+offset,length);
              font->Copyright[length]=(char)NULL;
              replace_newlines_with_spaces(font->Copyright);
-             
+
 #ifdef DEBUG_TRUETYPE
              debug("font->Copyright=\"%s\"",font->Copyright);
 #endif
              continue;
            }
-       
 
+
          /* Font Family name */
          if( platform == 1 && nameid == 1 )
            {
@@ -226,7 +226,7 @@
              strncpy(font->FamilyName,(const char*)strings+offset,length);
              font->FamilyName[length]=(char)NULL;
              replace_newlines_with_spaces(font->FamilyName);
-           
+
 #ifdef DEBUG_TRUETYPE
              debug("font->FamilyName=\"%s\"",font->FamilyName);
 #endif
@@ -241,14 +241,14 @@
              strncpy(font->Style,(const char*)strings+offset,length);
              font->Style[length]=(char)NULL;
              replace_newlines_with_spaces(font->Style);
-             
+
 #ifdef DEBUG_TRUETYPE
              debug("font->Style=\"%s\"",font->Style);
 #endif
              continue;
            }
-         
-         
+
+
          /* Full Font name */
          if( platform == 1 && nameid == 4 )
            {
@@ -256,14 +256,14 @@
              strncpy(font->FullName,(const char*)strings+offset,length);
              font->FullName[length]=(char)NULL;
              replace_newlines_with_spaces(font->FullName);
-             
+
 #ifdef DEBUG_TRUETYPE
              debug("font->FullName=\"%s\"",font->FullName);
 #endif
              continue;
            }
-         
-         
+
+
          /* Version string */
          if( platform == 1 && nameid == 5 )
            {
@@ -277,8 +277,8 @@
 #endif
              continue;
            }
-         
-         
+
+
          /* PostScript name */
          if( platform == 1 && nameid == 6 )
            {
@@ -292,8 +292,8 @@
 #endif
              continue;
            }
-         
-         
+
+
          /* Trademark string */
          if( platform == 1 && nameid == 7 )
            {
@@ -301,15 +301,15 @@
              strncpy(font->Trademark,(const char*)strings+offset,length);
              font->Trademark[length]=(char)NULL;
              replace_newlines_with_spaces(font->Trademark);
-             
+
 #ifdef DEBUG_TRUETYPE
              debug("font->Trademark=\"%s\"",font->Trademark);
 #endif
              continue;
            }
-         
+
        }
-    } catch (TTException& e) {
+    } catch (TTException& ) {
       free(table_ptr);
       throw;
     }
@@ -443,20 +443,20 @@
     /* Some information from the "post" table. */
     ItalicAngle = getFixed( font->post_table + 4 );
     stream.printf("/ItalicAngle %d.%d 
def\n",ItalicAngle.whole,ItalicAngle.fraction);
-    stream.printf("/isFixedPitch %s def\n", getULONG( font->post_table + 12 ) 
? "true" : "false" );    
+    stream.printf("/isFixedPitch %s def\n", getULONG( font->post_table + 12 ) 
? "true" : "false" );
     stream.printf("/UnderlinePosition %d def\n", (int)getFWord( 
font->post_table + 8 ) );
-    stream.printf("/UnderlineThickness %d def\n", (int)getFWord( 
font->post_table + 10 ) );    
-    stream.putline("end readonly def");    
-    } /* end of ttfont_FontInfo() */ 
+    stream.printf("/UnderlineThickness %d def\n", (int)getFWord( 
font->post_table + 10 ) );
+    stream.putline("end readonly def");
+    } /* end of ttfont_FontInfo() */
 
 /*-------------------------------------------------------------------
 ** sfnts routines
-** These routines generate the PostScript "sfnts" array which 
+** These routines generate the PostScript "sfnts" array which
 ** contains one or more strings which contain a reduced version
 ** of the TrueType font.
 **
 ** A number of functions are required to accomplish this rather
-** complicated task. 
+** complicated task.
 -------------------------------------------------------------------*/
 int string_len;
 int line_len;
@@ -498,9 +498,9 @@
        stream.putchar('\n');
        line_len=0;
        }
-       
+
     } /* end of sfnts_pputBYTE() */
-   
+
 /*
 ** Write a USHORT as a hexadecimal value as part of the sfnts array.
 */
@@ -516,7 +516,7 @@
 void sfnts_pputULONG(TTStreamWriter& stream, ULONG n)
     {
     int x1,x2,x3;
-    
+
     x1 = n % 256;
     n /= 256;
     x2 = n % 256;
@@ -531,7 +531,7 @@
     } /* end of sfnts_pputULONG() */
 
 /*
-** This is called whenever it is 
+** This is called whenever it is
 ** necessary to end a string in the sfnts array.
 **
 ** (The array must be broken into strings which are
@@ -542,7 +542,7 @@
     if(in_string)
        {
        string_len=0;           /* fool sfnts_pputBYTE() */
-       
+
        #ifdef DEBUG_TRUETYPE_INLINE
        puts("\n% dummy byte:\n");
        #endif
@@ -562,7 +562,7 @@
 */
 void sfnts_new_table(TTStreamWriter& stream, ULONG length)
     {
-    if( (string_len + length) > 65528 )    
+    if( (string_len + length) > 65528 )
       sfnts_end_string(stream);
     } /* end of sfnts_new_table() */
 
@@ -615,7 +615,7 @@
        /* Start new string if necessary. */
        sfnts_new_table( stream, (int)length );
 
-       /* 
+       /*
        ** Make sure the glyph is padded out to a
        ** two byte boundary.
        */
@@ -627,16 +627,16 @@
            {
            if( (c = fgetc(font->file)) == EOF )
                throw TTException("TrueType font may be corrupt (reason 6)");
-           
+
            sfnts_pputBYTE(stream, c);
            total++;            /* add to running total */
-           }       
+           }
 
        }
 
     free(font->loca_table);
     font->loca_table = NULL;
-    
+
     /* Pad out to full length from table directory */
     while( total < correct_total_length )
        {
@@ -649,7 +649,7 @@
 /*
 ** Here is the routine which ties it all together.
 **
-** Create the array called "sfnts" which 
+** Create the array called "sfnts" which
 ** holds the actual TrueType data.
 */
 void ttfont_sfnts(TTStreamWriter& stream, struct TTFONT *font)
@@ -673,7 +673,7 @@
        ULONG length;
        ULONG checksum;
        } tables[9];
-       
+
     BYTE *ptr;                 /* A pointer into the origional table 
directory. */
     ULONG x,y;                 /* General use loop countes. */
     int c;                     /* Input character. */
@@ -684,8 +684,8 @@
     ptr = font->offset_table + 12;
     nextoffset=0;
     count=0;
-    
-    /* 
+
+    /*
     ** Find the tables we want and store there vital
     ** statistics in tables[].
     */
@@ -697,7 +697,7 @@
            if( diff > 0 )              /* If we are past it. */
                {
                tables[x].length = 0;
-               diff = 0;               
+               diff = 0;
                }
            else if( diff < 0 )         /* If we haven't hit it yet. */
                {
@@ -711,12 +711,12 @@
                tables[x].length = getULONG( ptr + 12 );
                nextoffset += ( ((tables[x].length + 3) / 4) * 4 );
                count++;
-               ptr += 16;              
+               ptr += 16;
                }
            } while(diff != 0);
-       
+
        } /* end of for loop which passes over the table directory */
-    
+
     /* Begin the sfnts array. */
     sfnts_start(stream);
 
@@ -724,10 +724,10 @@
     /* Start by copying the TrueType version number. */
     ptr = font->offset_table;
     for(x=0; x < 4; x++)
-       { 
+       {
          sfnts_pputBYTE( stream,  *(ptr++) );
        }
-    
+
     /* Now, generate those silly numTables numbers. */
     sfnts_pputUSHORT(stream, count);           /* number of tables */
     if( count == 9 )
@@ -735,11 +735,11 @@
          sfnts_pputUSHORT(stream, 7);          /* searchRange */
          sfnts_pputUSHORT(stream, 3);          /* entrySelector */
          sfnts_pputUSHORT(stream, 81);         /* rangeShift */
-       }    
+       }
     #ifdef DEBUG_TRUETYPE
     else
        {
-       debug("only %d tables selected",count);         
+       debug("only %d tables selected",count);
        }
     #endif
 
@@ -754,13 +754,13 @@
        sfnts_pputBYTE( stream, table_names[x][1] );
        sfnts_pputBYTE( stream, table_names[x][2] );
        sfnts_pputBYTE( stream, table_names[x][3] );
-       
+
        /* Checksum */
        sfnts_pputULONG( stream, tables[x].checksum );
 
        /* Offset */
        sfnts_pputULONG( stream, tables[x].newoffset + 12 + (count * 16) );
-       
+
        /* Length */
        sfnts_pputULONG( stream, tables[x].length );
        }
@@ -770,7 +770,7 @@
        {
        if( tables[x].length == 0 )     /* skip tables that aren't there */
            continue;
-           
+
        #ifdef DEBUG_TRUETYPE
        debug("emmiting table '%s'",table_names[x]);
        #endif
@@ -783,22 +783,22 @@
        else                    /* Other tables may not exceed */
            {                   /* 65535 bytes in length. */
            if( tables[x].length > 65535 )
-               throw TTException("TrueType font has a table which is too 
long");           
-           
+               throw TTException("TrueType font has a table which is too 
long");
+
            /* Start new string if necessary. */
            sfnts_new_table(stream, tables[x].length);
 
            /* Seek to proper position in the file. */
            fseek( font->file, tables[x].oldoffset, SEEK_SET );
-       
+
            /* Copy the bytes of the table. */
            for( y=0; y < tables[x].length; y++ )
                {
                if( (c = fgetc(font->file)) == EOF )
                    throw TTException("TrueType font may be corrupt (reason 
7)");
-           
+
                sfnts_pputBYTE(stream, c);
-               }           
+               }
            }
 
        /* Padd it out to a four byte boundary. */
@@ -815,39 +815,39 @@
        } /* End of loop for all tables */
 
     /* Close the array. */
-    sfnts_end_string(stream);    
+    sfnts_end_string(stream);
     stream.putline("]def");
     } /* end of ttfont_sfnts() */
-    
-/*-------------------------------------------------------------- 
-** Create the CharStrings dictionary which will translate 
-** PostScript character names to TrueType font character 
+
+/*--------------------------------------------------------------
+** Create the CharStrings dictionary which will translate
+** PostScript character names to TrueType font character
 ** indexes.
 **
 ** If we are creating a type 3 instead of a type 42 font,
 ** this array will instead convert PostScript character names
 ** to executable proceedures.
 --------------------------------------------------------------*/
-const char *Apple_CharStrings[]={ 
-".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign", 
-"dollar","percent","ampersand","quotesingle","parenleft","parenright", 
+const char *Apple_CharStrings[]={
+".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign",
+"dollar","percent","ampersand","quotesingle","parenleft","parenright",
 "asterisk","plus", "comma","hyphen","period","slash","zero","one","two",
-"three","four","five","six","seven","eight","nine","colon","semicolon", 
+"three","four","five","six","seven","eight","nine","colon","semicolon",
 "less","equal","greater","question","at","A","B","C","D","E","F","G","H","I",
 "J","K", "L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
 "bracketleft","backslash","bracketright","asciicircum","underscore","grave",
-"a","b","c","d","e","f","g","h","i","j","k", "l","m","n","o","p","q","r","s", 
+"a","b","c","d","e","f","g","h","i","j","k", "l","m","n","o","p","q","r","s",
 "t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde",
 "Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis",
 "aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla",
-"eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex", 
+"eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex",
 "idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde",
 "uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent",
 "sterling","section","bullet","paragraph","germandbls","registered",
 "copyright","trademark","acute","dieresis","notequal","AE","Oslash",
 "infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff",
 "summation","product","pi","integral","ordfeminine","ordmasculine","Omega",
-"ae","oslash","questiondown","exclamdown","logicalnot","radical","florin", 
+"ae","oslash","questiondown","exclamdown","logicalnot","radical","florin",
 "approxequal","Delta","guillemotleft","guillemotright","ellipsis",
 "nobreakspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash",
 "quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge",
@@ -861,7 +861,7 @@
 "Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior",
 "twosuperior","threesuperior","onehalf","onequarter","threequarters","franc",
 "Gbreve","gbreve","Idot","Scedilla","scedilla","Cacute","cacute","Ccaron",
-"ccaron","dmacron","markingspace","capslock","shift","propeller","enter", 
+"ccaron","dmacron","markingspace","capslock","shift","propeller","enter",
 "markingtabrtol","markingtabltor","control","markingdeleteltor",
 "markingdeletertol","option","escape","parbreakltor","parbreakrtol",
 "newpage","checkmark","linebreakltor","linebreakrtol","markingnobreakspace",
@@ -879,7 +879,7 @@
     ULONG len;
 
     GlyphIndex = (int)getUSHORT( font->post_table + 34 + (charindex * 2) );
-       
+
     if( GlyphIndex <= 257 )            /* If a standard Apple name, */
        {
        return Apple_CharStrings[GlyphIndex];
@@ -887,7 +887,7 @@
     else                               /* Otherwise, use one */
        {                               /* of the pascal strings. */
        GlyphIndex -= 258;
-           
+
        /* Set pointer to start of Pascal strings. */
        ptr = (char*)(font->post_table + 34 + (font->numGlyphs * 2));
 
@@ -897,7 +897,7 @@
            ptr += len;
            len = (ULONG)*(ptr++);
            }
-               
+
        if( len >= sizeof(temp) )
            throw TTException("TrueType font file contains a very long 
PostScript name");
 
@@ -914,16 +914,16 @@
 void ttfont_CharStrings(TTStreamWriter& stream, struct TTFONT *font, 
std::vector<int>& glyph_ids)
     {
     Fixed post_format;
-    
+
     /* The 'post' table format number. */
     post_format = getFixed( font->post_table );
-    
+
     if( post_format.whole != 2 || post_format.fraction != 0 )
        throw TTException("TrueType fontdoes not have a format 2.0 'post' 
table");
 
     /* Emmit the start of the PostScript code to define the dictionary. */
     stream.printf("/CharStrings %d dict dup begin\n", glyph_ids.size());
-    
+
     /* Emmit one key-value pair for each glyph. */
     for(std::vector<int>::const_iterator i = glyph_ids.begin();
        i != glyph_ids.end(); ++i)
@@ -935,13 +935,13 @@
        else                            /* type 3 */
            {
            stream.printf("/%s{",ttfont_CharStrings_getname(font, *i));
-               
+
            tt_type3_charproc(stream, font, *i);
-       
+
            stream.putline("}_d");      /* "} bind def" */
            }
        }
-    
+
     stream.putline("end readonly def");
     } /* end of ttfont_CharStrings() */
 
@@ -971,8 +971,8 @@
        stream.putline("/BuildChar {");
        stream.putline(" 1 index /Encoding get exch get");
        stream.putline(" 1 index /BuildGlyph get exec");
-       stream.putline("}_d");          
-       
+       stream.putline("}_d");
+
        stream.putchar('\n');
        }
 
@@ -999,7 +999,7 @@
        stream.putline("{/TrueDict where{pop}{(%%[ Error: no TrueType 
rasterizer ]%%)= flush}ifelse");
 
        /* Since we are expected to use Apple's TrueDict TrueType */
-       /* reasterizer, change the font type to 3. */           
+       /* reasterizer, change the font type to 3. */
        stream.putline("/FontType 3 def");
 
        /* Define a string to hold the state of the Apple */
@@ -1035,7 +1035,7 @@
 
        /* Exchange the CharStrings dictionary and the charname, */
        /* but if the answer was false, replace the character name */
-       /* with ".notdef". */ 
+       /* with ".notdef". */
        stream.putline("    {exch}{exch pop /.notdef}ifelse");
                /* stack: CharStrings charname */
 
@@ -1060,7 +1060,7 @@
        stream.putline(" /BuildChar{");
        stream.putline("  1 index /Encoding get exch get");
        stream.putline("  1 index /BuildGlyph get exec");
-       stream.putline(" }bind def");           
+       stream.putline(" }bind def");
 
        /* Here we close the condition which is true */
        /* if the printer has no built-in TrueType */
@@ -1071,7 +1071,7 @@
 
     stream.putline("FontName currentdict end definefont pop");
     stream.putline("%%EOF");
-    } /* end of ttfont_trailer() */    
+    } /* end of ttfont_trailer() */
 
 /*------------------------------------------------------------------
 ** This is the externally callable routine which inserts the font.
@@ -1080,7 +1080,7 @@
 void read_font(const char *filename, font_type_enum target_type, 
std::vector<int>& glyph_ids, TTFONT& font)
     {
     BYTE *ptr;
-    
+
     /* Decide what type of PostScript font we will be generating. */
     font.target_type = target_type;
 
@@ -1094,24 +1094,24 @@
     /* Allocate space for the unvarying part of the offset table. */
     assert(font.offset_table == NULL);
     font.offset_table = (BYTE*)calloc( 12, sizeof(BYTE) );
-    
+
     /* Read the first part of the offset table. */
     if( fread( font.offset_table, sizeof(BYTE), 12, font.file ) != 12 )
        throw TTException("TrueType font may be corrupt (reason 1)");
-    
+
     /* Determine how many directory entries there are. */
     font.numTables = getUSHORT( font.offset_table + 4 );
     #ifdef DEBUG_TRUETYPE
     debug("numTables=%d",(int)font.numTables);
     #endif
-    
+
     /* Expand the memory block to hold the whole thing. */
     font.offset_table = (BYTE*)realloc( font.offset_table, sizeof(BYTE) * (12 
+ font.numTables * 16) );
-    
+
     /* Read the rest of the table directory. */
     if( fread( font.offset_table + 12, sizeof(BYTE), (font.numTables*16), 
font.file ) != (font.numTables*16) )
        throw TTException("TrueType font may be corrupt (reason 2)");
-    
+
     /* Extract information from the "Offset" table. */
     font.TTVersion = getFixed( font.offset_table );
 
@@ -1133,7 +1133,7 @@
        throw TTException("TrueType font is unusable because indexToLocFormat 
!= 0");
       if( getSHORT(ptr+52) != 0 )
        throw TTException("TrueType font is unusable because glyphDataFormat != 
0");
-    } catch (TTException& e) {
+    } catch (TTException& ) {
       free(ptr);
       throw;
     }
@@ -1177,7 +1177,7 @@
 
     } /* end of insert_ttfont() */
 
-void insert_ttfont(const char *filename, TTStreamWriter& stream, 
+void insert_ttfont(const char *filename, TTStreamWriter& stream,
                   font_type_enum target_type, std::vector<int>& glyph_ids)
     {
     struct TTFONT font;
@@ -1233,9 +1233,9 @@
 }
 
 TTFONT::TTFONT() :
-    file(NULL), 
+    file(NULL),
     PostName(NULL),
-    FullName(NULL), 
+    FullName(NULL),
     FamilyName(NULL),
     Style(NULL),
     Copyright(NULL),


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to