? .buildpath
? .bzr
? .cvsignore
? .project
? .settings
? captcha-HEAD.kpf
? image_captcha/.DS_Store
? image_captcha/fonts/.DS_Store
? image_captcha/fonts/.gitignore
? image_captcha/fonts/1456Gutenberg.TTF
? image_captcha/fonts/Army.ttf
? image_captcha/fonts/BABYK___.TTF
? image_captcha/fonts/actionj.ttf
? image_captcha/fonts/dropacha.ttf
? image_captcha/fonts/skinck.ttf
? image_captcha/fonts/subeve.ttf
? image_captcha/fonts/tiza.ttf
? image_captcha/fonts/Tesox/.DS_Store
? translations/.DS_Store
Index: image_captcha/image_captcha.user.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/captcha/image_captcha/image_captcha.user.inc,v
retrieving revision 1.20
diff -u -u -p -r1.20 image_captcha.user.inc
--- image_captcha/image_captcha.user.inc	17 Sep 2009 23:16:32 -0000	1.20
+++ image_captcha/image_captcha.user.inc	22 Sep 2009 21:04:24 -0000
@@ -261,9 +261,18 @@ function _image_captcha_image_generator_
     $center_x = ($c + 0.5) * $ccage_width;
     $center_y = 0.5 * $height;
 
-    // get character dimensions for ttf fonts
+    // Get character dimensions for TrueType fonts.
     if ($font != 'BUILTIN') {
       $bbox = imagettfbbox($font_size, 0, realpath($font), $character);
+      // In very rare cases with some versions of the GD library, the x-value
+      // of the left side of the bounding box as returned by the first call of
+      // imagettfbbox is corrupt (value -2147483648 = 0x80000000).
+      // The weird thing is that calling the function a second or third time
+      // can be used as workaround.
+      // This issue is discussed at http://drupal.org/node/349218.
+      for ($count=0; $bbox[2] < 0 && $count < 5; $count++) {
+        $bbox = imagettfbbox($font_size, 0, realpath($font), $character);
+      }
     }
 
     // determine print position: at what coordinate should the character be
