Req #72912 [Opn->Ver]: GD and rtl languages

From: Date: Sun, 21 Aug 2016 12:15:59 +0000
Subject: Req #72912 [Opn->Ver]: GD and rtl languages
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203450@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72912&edit=1 ID: 72912 Updated by: cmb@php.net Reported by: hirad dot daneshvar at gmail dot com Summary: GD and rtl languages -Status: Open +Status: Verified Type: Feature/Change Request Package: GD related PHP Version: 5.6.25 Block user comment: N Private report: N New Comment: Indeed, neither RTL languages nor GPOS kerning is currently supported in GD. PRs against <https://github.com/libgd/libgd> are welcome! Previous Comments: ------------------------------------------------------------------------ [2016-08-21 11:08:21] hirad dot daneshvar at gmail dot com Description: ------------ --- From manual page: http://www.php.net/function.imagettftext --- I can add text watermarks to my image, however the text must be a Left To Right language. How can I use RTL languages such as Persian to add a watermark? For example a text like سلام will be added like م ا ل س. I have searched A LOT, and all I found was custom functions to do so. However persian letters unlike Latin letters should be connected. For example in the word 'Hello' there is a space in between 'H' and 'e', in the same word in persian, which is 'سلام', the first letter 'س' is connected to 'ل'. To do this we have to replace the letters with the correct connected symbol to do the trick. Using this approach when applying different fonts to our word, the letters that we replaced with their connected symbol are written in an ugly font. I was wondering if there was an extension or library to install and handle this using GD. Test script: --------------- <?php // Set the content-type header('Content-Type: image/png'); // Create the image $im = imagecreatetruecolor(400, 30); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29, $white); // The text to draw $text = 'سلام'; $font = 'yekan.ttf'; // Add some shadow to the text imagettftext($im, 20, 0, 11, 21, $grey, $font, $text); // Add the text imagettftext($im, 20, 0, 10, 20, $black, $font, $text); imagepng($im); imagedestroy($im); ?> Expected result: ---------------- When I run the code I expect to see سلام in an image Actual result: -------------- When I run the code I get م ا ل س in an image ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72912&edit=1

« previous php.bugs (#203450) next »