PHP将阿拉伯语文本转换为图像

I got problem from my text to image(jpg) function for arabic text. I tried below code, it only working for normal text. But when I tried to input the text with Arabic text, the display will show enter image description here

mb_language('uni');
mb_internal_encoding('UTF-8');

$text = "ديفيد";

$font_file      = 'coolvetica.ttf';
$font_size      = 8 ; // font size in pts
$font_color     = '#000' ;
$image_file     = 'assets/img/Soccer.Field_Transparant.png';

$x_finalpos     = 127;
$y_finalpos     = 103;

$mime_type          = 'image/png' ;
$extension          = '.png' ;
$s_end_buffer_size  = 4096 ;

I already tried to check the code but no find the solution.

Thank you.

As far as i can tell, the coolvetica.ttf font doesn't normally support arabic letters, so if you're enforcing that font, that's most likely the cause. You'll probably need to switch to one of these fonts instead:

http://www.wazu.jp/gallery/Fonts_Arabic.html