Fix issue #43
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index b6a11a3..bb0ea7b 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -1245,22 +1245,37 @@
 		// offset flips itself automatically
 
 		if ($this->wm_vrt_alignment === 'B')
+		{
 			$this->wm_vrt_offset = $this->wm_vrt_offset * -1;
+		}
 
 		if ($this->wm_hor_alignment === 'R')
+		{
 			$this->wm_hor_offset = $this->wm_hor_offset * -1;
+		}
 
 		// Set font width and height
 		// These are calculated differently depending on
 		// whether we are using the true type font or not
 		if ($this->wm_use_truetype === TRUE)
 		{
-			if ($this->wm_font_size === '')
+			if (empty($this->wm_font_size))
 			{
 				$this->wm_font_size = 17;
 			}
 
-			$fontwidth  = $this->wm_font_size-($this->wm_font_size/4);
+			if (function_exists('imagettfbbox'))
+			{
+				$temp = imagettfbbox($this->wm_font_size, 0, $this->wm_font_path, $this->wm_text);
+				$temp = $temp[2] - $temp[0];
+
+				$fontwidth = $temp / strlen($this->wm_text);
+			}
+			else
+			{
+				$fontwidth = $this->wm_font_size - ($this->wm_font_size / 4);
+			}
+
 			$fontheight = $this->wm_font_size;
 			$this->wm_vrt_offset += $this->wm_font_size;
 		}
@@ -1368,45 +1383,45 @@
 	public function image_create_gd($path = '', $image_type = '')
 	{
 		if ($path === '')
+		{
 			$path = $this->full_src_path;
+		}
 
 		if ($image_type === '')
+		{
 			$image_type = $this->image_type;
+		}
 
 		switch ($image_type)
 		{
-			case	 1 :
-						if ( ! function_exists('imagecreatefromgif'))
-						{
-							$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
-							return FALSE;
-						}
+			case 1 :
+				if ( ! function_exists('imagecreatefromgif'))
+				{
+					$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
+					return FALSE;
+				}
 
-						return imagecreatefromgif($path);
-				break;
+				return imagecreatefromgif($path);
 			case 2 :
-						if ( ! function_exists('imagecreatefromjpeg'))
-						{
-							$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
-							return FALSE;
-						}
+				if ( ! function_exists('imagecreatefromjpeg'))
+				{
+					$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
+					return FALSE;
+				}
 
-						return imagecreatefromjpeg($path);
-				break;
+				return imagecreatefromjpeg($path);
 			case 3 :
-						if ( ! function_exists('imagecreatefrompng'))
-						{
-							$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
-							return FALSE;
-						}
+				if ( ! function_exists('imagecreatefrompng'))
+				{
+					$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
+					return FALSE;
+				}
 
-						return imagecreatefrompng($path);
-				break;
-
+				return imagecreatefrompng($path);
+			default:
+				$this->set_error(array('imglib_unsupported_imagecreate'));
+				return FALSE;
 		}
-
-		$this->set_error(array('imglib_unsupported_imagecreate'));
-		return FALSE;
 	}
 
 	// --------------------------------------------------------------------