Req #72912 [NEW]: GD and rtl languages
| From: | hirad dot daneshvar at gmail dot com | Date: | Sun, 21 Aug 2016 11:08:24 +0000 |
| Subject: | Req #72912 [NEW]: GD and rtl languages | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-203448@lists.php.net to get a copy of this message | ||
From: hirad dot daneshvar at gmail dot com
Operating system:
PHP version: 5.6.25
Package: GD related
Bug Type: Feature/Change Request
Bug description:GD and rtl languages
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 bug report at https://bugs.php.net/bug.php?id=72912&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72912&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72912&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72912&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72912&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72912&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72912&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72912&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72912&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72912&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72912&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72912&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72912&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72912&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72912&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72912&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72912&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72912&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72912&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72912&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72912&r=mysqlcfg