Index: src/placement_finder.cpp
===================================================================
--- src/placement_finder.cpp	(revision 656)
+++ src/placement_finder.cpp	(working copy)
@@ -549,6 +549,7 @@
       const double initial_distance = distance;
       
       std::auto_ptr<placement_element> current_placement(new placement_element);
+      std::cerr << std::endl << "   Trying new placement at: " << index << ", distance: " << distance << std::endl;
 
       double string_height = p.info.get_dimensions().second;
       double old_x = path_positions[index-1].x;
@@ -561,7 +562,7 @@
       double dy = new_y - old_y;
       
       double segment_length = path_distances[index];
-      
+
       current_placement->starting_x = old_x + dx*distance/segment_length;
       current_placement->starting_y = old_y + dy*distance/segment_length;
       double angle = atan2(-dy, dx);
@@ -584,13 +585,15 @@
          c = ci.character;
 
          //Coordinates this character will start at
+         std::cerr << "length:" << segment_length << std::endl;
+         assert(segment_length != 0);
          double start_x = old_x + dx*distance/segment_length;
          double start_y = old_y + dy*distance/segment_length;
          //Coordinates this character ends at, calculated below
          double end_x = 0;
          double end_y = 0;
-         
-         if (segment_length - distance  >= ci.width) 
+
+         if (segment_length - distance  >= ci.width)
          {
             //if the distance remaining in this segment is enough, we just go further along the segment
             distance += ci.width;
@@ -626,6 +629,8 @@
                start_x, start_y, ci.width, 
                old_x, old_y, new_x, new_y, 
                end_x, end_y); //results are stored in end_x, end_y
+            assert(!isnan(end_y));
+            assert(!isnan(end_x));
 
             //Need to calculate distance on the new segment
             distance = sqrt(pow(old_x - end_x, 2) + pow(old_y - end_y, 2));
@@ -669,6 +674,7 @@
          current_placement->add_node(c,render_x - current_placement->starting_x, 
                                        -render_y + current_placement->starting_y, 
                                        render_angle);
+         std::cerr << "   add_node: " << render_x << "," << current_placement->starting_x << "," <<  render_y << "," << current_placement->starting_y << "," << render_angle << std::endl;
          
          //Normalise to 0 <= angle < 2PI
          while (render_angle >= 2*M_PI)
@@ -779,6 +785,7 @@
       double A = dx * dx + dy * dy;
       double B = 2 * (dx * (x1 - cx) + dy * (y1 - cy));
       double C = (x1 - cx) * (x1 - cx) + (y1 - cy) * (y1 - cy) - radius * radius;
+      assert(!isnan(B));
    
       double det = B * B - 4 * A * C;
       if (A <= 0.0000001 || det < 0)
