php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #43899 Problem in displaying right to left connected languages (like persian, arabic)
Submitted: 2008-01-20 12:28 UTC Modified: 2017-08-16 16:28 UTC
Votes:13
Avg. Score:4.5 ± 0.7
Reproduced:10 of 10 (100.0%)
Same Version:7 (70.0%)
Same OS:6 (60.0%)
From: mohamnag at gmail dot com Assigned:
Status: Suspended Package: GD related
PHP Version: 6 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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mohamnag at gmail dot com
New email:
PHP Version: OS:

 

 [2008-01-20 12:28 UTC] mohamnag at gmail dot com
Description:
------------
There is an issue displaying Persian characters in GD generated images.
In persian, characters are arranged right to left (I mean first char is the most right hand arranged one). In addition characters are connected. For example while ی and ک are being written when separated, they should be written یک when connected. So not only they should be arranged right to left but also the shape of characters change during connections.
However displaying text using GD don't arrange persian characters right to left nor connects them correctly.
Some persian developers have made a php function which corrects the problem here: http://persiangd.berlios.de/doku.php
but I think it should be solved globally in the original lib.


Reproduce code:
---------------
header("Content-type: image/png");
//uncomment to correct issue:
//include("fagd.php");

$text="یک";

$im = imagecreate(800, 40);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);

//uncomment to correct issue:
//$text = fagd($string,'fa');

$font = dirname(__FILE__).'/tahoma.ttf';

// Add the text
imagettftext($im, 20, 0, 20, 25, $black, $font,$text);

imagepng($im);
imagedestroy($im);


Expected result:
----------------
this is an image displaying the correct output resulting from passing the text to imagettftext(), after being parsed using the fagd() function (provided by persian developers to correct the issue):
http://khone.ir/test/t2.png

Actual result:
--------------
this is an image displaying the problematic view resulting from direct input of persian text to imagettftext():
http://khone.ir/test/t1.png

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-27 12:58 UTC] jani@php.net
Assigned to the GD maintainer.
 [2016-09-14 14:08 UTC] cmb@php.net
-Status: Assigned +Status: Suspended -Type: Bug +Type: Feature/Change Request -Assigned To: pajoye +Assigned To: cmb
 [2016-09-14 14:08 UTC] cmb@php.net
Indeed, libgd does not yet support complex text layout except in
master, but this is not a bug, but rather a missing feature.
Anyhow, I'm suspending this ticket until libgd actually releases
CTL support.
 [2017-08-16 16:28 UTC] cmb@php.net
-Assigned To: cmb +Assigned To:
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Tue Sep 25 05:01:25 2018 UTC