PHP GD not rendering unicode fonts properly
I开发者_Go百科 am having problems in rendering unicode glyphs ( language : Malayalam, Tamil and Hindi) with PHP GD library. Is this something related to the rendering engine of GD library? Any workarounds available ?
First make sure your fonts contain the desired glyphs (system fonts such as Arial should). Then make sure you convert your parameters to unicode using utf8_decode()
if neccessary.
i have found one try this
<?php
//error_reporting(0);
$text = ("Unreadable text");
$font = "mangal.ttf";
$fontSize = "10";
$width = '600';
$s = new CairoImageSurface(CairoFormat::ARGB32, $width, 21);
$c = new CairoContext($s);
/* Set the background*/
$c->setSourceRGB(.1,149,.58);
$c->paint();
$c->setSourceRGB(.1,.1,.1);
/* Make a Pango layout, set the font, then set the layout size */
$l = new PangoLayout($c);
$desc = new PangoFontDescription("mangal normal $fontSize");
$l->setFontDescription($desc);
/* Here, we use Pango markup to make part of the text bold */
$l->setText($text);
/* Draw the layout on the surface */
$l->showLayout($c);
$s->writeToPng("unicode.png");
echo $img = "<img src=\"unicode.png\">";
?>
精彩评论