Index: textimage.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/textimage/textimage.module,v
retrieving revision 1.23.4.17
diff -u -p -r1.23.4.17 textimage.module
--- textimage.module	2 Jun 2009 22:27:46 -0000	1.23.4.17
+++ textimage.module	2 Nov 2009 16:54:15 -0000
@@ -388,7 +388,7 @@ function textimage_image_from_preset($pr
   }
 
   // Generate the textimage
-  $img = textimage_text_to_image($text, $font_size, $font_file, $font_color, $text_angle, $text_maximum_width, $text_fixed_width, $text_align);
+  $img = textimage_text_to_image($text, $font_size, $font_file, $font_color, $text_angle, $text_maximum_width, $text_fixed_width, $text_align, $font_language);
 
   // Add a border
   if ($text_stroke['width'] && $text_stroke['color']) {
@@ -687,7 +687,7 @@ if (!function_exists('drupal_preg_match'
  * @return $image
  *   A GD image resource.
  */
-function textimage_text_to_image($text, $fontsize, $font, $color = array('hex' => '#000000', 'opacity' => '100'), $angle = 0, $maximum_width = 0, $fixed_width = 0, $align = ALIGN_LEFT) {
+function textimage_text_to_image($text, $fontsize, $font, $color = array('hex' => '#000000', 'opacity' => '100'), $angle = 0, $maximum_width = 0, $fixed_width = 0, $align = ALIGN_LEFT, $is_arabic = 0) {
   // Set rotation angle.
   $q_angle = -$angle;
   while ($q_angle > 0 || $q_angle <= -90) {
@@ -776,7 +776,20 @@ function textimage_text_to_image($text, 
   // Create the textimage.
   list($r, $g, $b) = _textimage_hex2rgb($color['hex']);
   $alpha = -($color['opacity'] - 100) / 100 * 127;
-  $fore = imagecolorallocatealpha($image, $r, $g, $b, $alpha);
+  $fore = imagecolorallocatealpha($image, $r, $g, $b, $alpha);
+  
+  //This will fix the display of arabic/persian characters 
+  if ($is_arabic) {
+    $persian_log = drupal_get_path('module', 'textimage') . '/persian_log';
+    if (file_check_directory($persian_log)) {
+      require_once('persian_log/persian_log2vis.php');
+      persian_log2vis($text);
+      $y = $y - 10;
+    }
+    else {
+      drupal_set_message('<code>persian_log</code> ' . t('folder was not found in <code>textimage</code>. Please make sure you download the library, extract it to <code>textimage</code> folder and rename the folder to <code>persian_log</code>.'), 'error');
+    }
+  }
 
   imagettftext($image, $fontsize, $q_angle, $x, $y, $fore, $font, $text);
   if ($rotation != 0) {
Index: textimage_admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/textimage/textimage_admin.inc,v
retrieving revision 1.5.4.10
diff -u -p -r1.5.4.10 textimage_admin.inc
--- textimage_admin.inc	14 May 2009 12:34:24 -0000	1.5.4.10
+++ textimage_admin.inc	2 Nov 2009 16:54:17 -0000
@@ -172,6 +172,15 @@ function textimage_preset_edit(&$form_st
     '#description' => t('Select the font to be used in this image. If no fonts are listed, check the <a href="!path">settings for Fonts Path</a>.', array('!path' => url('admin/build/textimage/settings'))),
     '#required' => TRUE,
   );
+  $form['settings']['font']['language'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Are you using this preset for Arabic text?'),
+    '#weight' => 10,
+    '#description' => t('If you use Arabic font to generate Arabic characters, check this option to perform the required processing of Arabic characters.<br/>To use this, you should download <a href="@link">this library</a> and extract it to the modules directory, such as <b>textimage/persian_log/</b>'),
+    '#default_value' => isset($preset['settings']['font']['language'])
+      ? $preset['settings']['font']['language']
+      : 0,
+  );
   $form['settings']['font']['size'] = array(
     '#type' => 'textfield',
     '#title' => t('Size'),
