php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34670 imageTTFText for Indian scripts (Devanagari)
Submitted: 2005-09-28 11:50 UTC Modified: 2015-08-08 11:38 UTC
Votes:11
Avg. Score:4.2 ± 1.3
Reproduced:9 of 9 (100.0%)
Same Version:6 (66.7%)
Same OS:4 (44.4%)
From: klaus at glashoff dot net Assigned: pajoye
Status: Assigned Package: GD related
PHP Version: 5.*, 6 OS: Windows XP
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC