diff --git a/src/ftcommon.c b/src/ftcommon.c
index a028b73..8dc982c 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -870,6 +870,10 @@
     if ( error )
       return error;
 
+    /* bail out if the bitmap is too wide */
+    if ( *pen_x + left + bit3.width >= display->bitmap->width )
+      return FT_Err_Raster_Overflow;
+
     /* now render the bitmap into the display surface */
     grBlitGlyphToBitmap( display->bitmap, &bit3, *pen_x + left,
                          *pen_y - top, display->fore_color );
@@ -905,6 +909,10 @@
       return error;
     }
 
+    /* bail out if the bitmap is too wide */
+    if ( *pen_x + left + bit3.width >= display->bitmap->width )
+      return FT_Err_Raster_Overflow;
+
     /* now render the bitmap into the display surface */
     grBlitGlyphToBitmap( display->bitmap, &bit3, *pen_x + left,
                          *pen_y - top, color );
diff --git a/src/ftview.c b/src/ftview.c
index 2401202..6e57a08 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -45,9 +45,6 @@
             y = start_y;                                                \
           } while ( 0 )
 
-#define X_TOO_LONG( x, size, display )                   \
-          ( (x) + ( (size)->metrics.max_advance >> 6 ) > \
-            (display)->bitmap->width )
 #define Y_TOO_LONG( y, size, display )       \
           ( (y) >= (display)->bitmap->rows )
 
@@ -182,18 +179,27 @@
           goto Next;
         }
 
+      Draw:
         error = FTDemo_Draw_Glyph( handle, display, glyph, &x, &y );
-        FT_Done_Glyph( glyph );
 
-        if ( error )
-          status.Fail++;
-        else if ( X_TOO_LONG( x, size, display ) )
+        if ( error == FT_Err_Raster_Overflow )
         {
           x  = start_x;
           y += step_y;
 
           if ( Y_TOO_LONG( y, size, display ) )
+          {
+            FT_Done_Glyph( glyph );
             break;
+          }
+          else
+            goto Draw; /* try again */
+        }
+        else
+        {
+          FT_Done_Glyph( glyph );
+          if ( error )
+            goto Next;
         }
       }
       else
@@ -275,21 +281,27 @@
 
         FT_Outline_Transform( outline, &shear );
 
+      Draw:
         error = FTDemo_Draw_Slot( handle, display, face->glyph, &x, &y );
 
-        if ( error )
-          status.Fail++;
-        else if ( X_TOO_LONG( x, size, display ) )
+        if ( error == FT_Err_Raster_Overflow )
         {
           x  = start_x;
           y += step_y;
 
           if ( Y_TOO_LONG( y, size, display ) )
             break;
+          else
+            goto Draw;
         }
+        else if ( error )
+          goto Next;
       }
       else
+      {
+    Next:
         status.Fail++;
+      }
 
       i++;
     }
@@ -384,22 +396,27 @@
         if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
           slot->bitmap_top += ystr >> 6;
 
+      Draw:
         error = FTDemo_Draw_Slot( handle, display, slot, &x, &y );
 
-        if ( error )
-          goto Next;
-        else if ( X_TOO_LONG( x, size, display ) )
+        if ( error == FT_Err_Raster_Overflow )
         {
           x  = start_x;
           y += step_y;
 
           if ( Y_TOO_LONG( y, size, display ) )
             break;
+          else
+            goto Draw; /* try again */
         }
+        else if ( error )
+          goto Next;
       }
       else
+      {
     Next:
         status.Fail++;
+      }
 
       i++;
     }
@@ -439,17 +456,21 @@
       else
         gindex = FTDemo_Get_Index( handle, i );
 
+    Draw:
       error = FTDemo_Draw_Index( handle, display, gindex, &x, &y );
-      if ( error )
-        status.Fail++;
-      else if ( X_TOO_LONG( x, size, display ) )
+
+      if ( error == FT_Err_Raster_Overflow )
       {
-        x = start_x;
+        x  = start_x;
         y += step_y;
 
         if ( Y_TOO_LONG( y, size, display ) )
           break;
+        else
+          goto Draw; /* try again */
       }
+      else if ( error )
+        status.Fail++;
 
       i++;
     }
@@ -504,23 +525,23 @@
 
       gindex = FTDemo_Get_Index( handle, ch );
 
+    Draw:
       error = FTDemo_Draw_Index( handle, display, gindex, &x, &y );
-      if ( error )
-        status.Fail++;
-      else
-      {
-        /* Draw_Index adds one pixel space */
-        x--;
+      x--; /* remove the added extra point */
 
-        if ( X_TOO_LONG( x, size, display ) )
-        {
-          x  = start_x;
-          y += step_y;
+      if ( error == FT_Err_Raster_Overflow )
+      {
+        x  = start_x;
+        y += step_y;
 
-          if ( Y_TOO_LONG( y, size, display ) )
-            break;
-        }
+        if ( Y_TOO_LONG( y, size, display ) )
+          break;
+        else
+          goto Draw; /* try again */
       }
+      else if ( error )
+        status.Fail++;
+
 
       if ( num_indices > 0 )
         num_indices -= 1;
@@ -601,10 +622,11 @@
         gindex = FTDemo_Get_Index( handle, *p );
 
         error = FTDemo_Draw_Index( handle, display, gindex, &x, &y );
-        if ( error )
-          status.Fail++;
-        else if ( X_TOO_LONG( x, size, display ) )
+
+        if ( error == FT_Err_Raster_Overflow )
           break;
+        else if ( error )
+          status.Fail++;
 
         p++;
       }
