|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #72912 GD and rtl languages
Submitted: 2016-08-21 11:08 UTC Modified: 2016-09-14 14:05 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: hirad dot daneshvar at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: GD related
PHP Version: 5.6.25 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: hirad dot daneshvar at gmail dot com
New email:
PHP Version: OS:


 [2016-08-21 11:08 UTC] hirad dot daneshvar at gmail dot com
From manual page:

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:
// 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);


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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-21 12:15 UTC]
-Status: Open +Status: Verified
 [2016-08-21 12:15 UTC]
Indeed, neither RTL languages nor GPOS kerning is currently
supported in GD. PRs against <> are
 [2016-08-22 15:21 UTC]
-Assigned To: +Assigned To: cmb
 [2016-08-22 15:21 UTC]
> Indeed, neither RTL languages nor GPOS kerning is currently
> supported in GD.

I've been not up-to-date. Actually, there is CTL support in master
since <> has been merged.
 [2016-09-14 14:05 UTC]
-Status: Verified +Status: Duplicate
 [2016-09-14 14:05 UTC]
I've just found bug #43899 which is about the same issue, so I'm
closing this ticket as duplicate.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Feb 24 02:01:28 2024 UTC