php.net |  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
Votes:20
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: klaus at glashoff dot net
New email:
PHP Version: OS:

 

 [2005-09-28 11:50 UTC] klaus at glashoff dot net
Description:
------------
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:
---------------
<?php
Header ("Content-type: image/png");
$string ="&#2325;&#2381;&#2340;";
$string=rawurldecode($string);
$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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-28 12:49 UTC] pajoye@php.net
Please provide links to:
- the font you use (Sanskrit2003.ttf)
  or are you using the font from www.omkarananda-ashram.org?
 
- 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 
http://www.omkarananda-ashram.org/Sanskrit/itranslator2003.htm#dls

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
http://leuchtraum.de/translation/test/devatest.php?text=kt
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 http://www.unicode.org/versions/Unicode4.0.0/ch09.pdf
Table 9.2 on p. 229 is of relevance; also the pages before.
 [2005-09-28 14:18 UTC] pajoye@php.net
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] pajoye@php.net
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] cmb@php.net
-Status: Assigned +Status: Feedback
 [2015-07-17 00:08 UTC] cmb@php.net
This issue appears to have been fixed as of PHP 5.3.0, see
<http://imgur.com/JT577Q7,yKzJI0I>, or do I misunderstand the
problem?
 [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 http://unicode.org/faq/indic.html#17

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:

http://utils.net/caption/fidd-utf8:hi_in/fid-r/cn-1/fidd-utf8:hi_in/t-AnyHindiUnicodeStringHere

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] cmb@php.net
-Status: No Feedback +Status: Open
 [2015-08-08 11:38 UTC] cmb@php.net
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.

Refer: http://fontforge.github.io/gposgsub.html
 [2017-10-24 07:37 UTC] kalle@php.net
-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] cmb@php.net
-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] cmb@php.net
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] <https://gist.github.com/cmb69/0355b94c13631b7b1a64df21388039d5>
[2] <https://github.com/libgd/libgd/issues>
 [2021-09-09 11:56 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2021-09-09 11:56 UTC] cmb@php.net
I have forwarded this issue to libgd[1], and suspend this ticket
for the time being.

[1] <https://github.com/libgd/libgd/issues/758>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 08:01:29 2024 UTC