|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34670 imagettftext() doesn't combine combining chars
Submitted: 2005-09-28 11:50 UTC Modified: 2021-09-09 11:56 UTC
Avg. Score:4.2 ± 1.1
Reproduced:17 of 17 (100.0%)
Same Version:9 (52.9%)
Same OS:5 (29.4%)
From: klaus at glashoff dot net Assigned:
Status: Suspended Package: GD related
PHP Version: 7.4 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: klaus at glashoff dot net
New email:
PHP Version: OS:


 [2005-09-28 11:50 UTC] klaus at glashoff dot net
The results of imagettftext() are - at least for Indian languages - not totally satisfying:  Consonant conjuncts appear as two consonants with virama.  In order to display "kta" in Devanagari, imagettftext, for example,  when given the argument " k + virama + t" (क्त) should return the conjunct for "kt", but it does not.

(Instead of the font Sanskrit2003.ttf, use any Unicode font containing U+0900 - U+097F; for example mangal.ttf).

Reproduce code:
Header ("Content-type: image/png");
$string ="&#2325;&#2381;&#2340;";
$im =  imagecreate (200, 25);
$white = ImageColorAllocate ($im,224,224,224);
$black = ImageColorAllocate ($im,50,100,100);

ImageTTFText ($im, 12, 0, 5, 15, $black, "Sanskrit2003.ttf", $string);
ImagePng ($im);
ImageDestroy ($im);

Expected result:
The Devanagari conjunct glyph for "kt" should appear, not a separate "k" with virama sign &#2381.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-28 12:49 UTC]
Please provide links to:
- the font you use (Sanskrit2003.ttf)
  or are you using the font from
- expected results (using another program if required)
  as images

- actual result as images

 [2005-09-28 14:14 UTC] klaus at glashoff dot net
1. The font can be downloaded from

2. The expected result may be generated by any browser which can deal with the Unicode sequence I gave: &#2325;&#2381;&2340;  What you will see (if an appropriate font has been installed) is a single glyph which is a conjunct of the glyph for "k" (&#2325) and "t" (&#2340).

3. The different results (text from the browser or image) may be seen on my testpage
Please see also the source of the page. 
Try also input of "krtsna" or other conjuncts. (This test page is not perfect but hopefully sufficient to show the problem).

4. The Unicode directives for Devanagari are given in
Table 9.2 on p. 229 is of relevance; also the pages before.
 [2005-09-28 14:18 UTC]
Thanks for the links, they are mostly what I'm using to port the Freetype backend to the newly added Unicode support in HEAD (php6).

Did that ever work? 

For what I see, it seems like I will be able to really fixed that only in php6 using unicode (unicode strings passed to FT with correct glyphs set).

 [2005-09-29 11:40 UTC]
Did that ever work? take #2
 [2005-09-29 12:51 UTC] klaus at glashoff dot net
It's a new project, so I do not know whether that ever worked.
 [2008-09-19 23:48 UTC] sbikas at yahoo dot com
Is this problem solved? I tried using several Bengali unicode fonts. The problem exists.
 [2015-07-17 00:08 UTC]
-Status: Assigned +Status: Feedback
 [2015-07-17 00:08 UTC]
This issue appears to have been fixed as of PHP 5.3.0, see
<,yKzJI0I>, or do I misunderstand the
 [2015-07-26 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2015-08-08 04:30 UTC] jay dot scv at gmail dot com
Problem still remains. Image shown on imagur is incorrect.
 [2015-08-08 04:37 UTC] jay dot scv at gmail dot com
Please refer

This will provide you enough information on how 'virama' combinations should be rendered. 

I could provide any supporting information you may need.
 [2015-08-08 05:01 UTC] jay dot scv at gmail dot com
A direct browser based text to image:

On every reload, it will use a random hindi unicode capable code.

For any other language change utf8:hi_in to utf8:<2letter_language_code>_<2_letter_country_code>
 [2015-08-08 11:38 UTC]
-Status: No Feedback +Status: Open
 [2015-08-08 11:38 UTC]
Thanks, now I got it. The problem isn't particularly related to
Bengali, but rather to combining characters in general, which are
not supported by imagettftext().
 [2015-08-08 20:53 UTC] jay dot scv at gmail dot com
I think, you got it. Problem is with most Indic and Arabic languages.

Please note that most of these fonts carry GPOS and GSUB tables. Font tables also have information related to substitution of glyph combinations with a different glyph.

 [2017-10-24 07:37 UTC]
-Status: Assigned +Status: Open -Assigned To: pajoye +Assigned To:
 [2019-09-19 04:02 UTC] kalpit dot jain at wagmob dot com
we are running into this bug when writing
क्षत्रिय on an image using imagettftext
imagettftext can not write क्ष
 [2021-05-03 11:28 UTC]
-Summary: imageTTFText for Indian scripts (Devanagari) +Summary: imagettftext() doesn't combine combining chars -PHP Version: 5.*, 6 +PHP Version: 7.4
 [2021-05-03 11:28 UTC]
I created a gist which clearly shows the misbehavior[1].  I'm
pretty sure this is actually an upstream issue, so should be
reported there[2].

[1] <>
[2] <>
 [2021-09-09 11:56 UTC]
-Status: Open +Status: Suspended
 [2021-09-09 11:56 UTC]
I have forwarded this issue to libgd[1], and suspend this ticket
for the time being.

[1] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 13 08:01:30 2024 UTC