Imagemagick unicode text not working


#1

Hello I am on dreamhost VPS and i am trying to use pre-installed Imagemagick to print unicode text on images …something like this :

$im->newPseudoImage(200, 200, “pango:हिन्दी”);

PHP script works great on my localhost. But doesnt’ on dreamhost. it only produces some box with question-marks.

I am new to this, but I hear I need Imagemagick with pango support for this, I tried installing newer Imagemagick ushing SSH but somehow i can’t overwrite preinstalled imagemagick?? Is there a way around? Please help.


#2

Possibly the problem is due to a missing font? You can check what fonts are available on your VPS with fc-list or fc-list :lang=hi (for just Hindi).

You could probably install the fonts you need in your user’s dot-font directory (i.e. /home/user/.font).


#4

After you install the font, the command fc-list :lang=hi should list the font as available for Hindi. You might try some of the fonts that come with Ubuntu 10.4 (the OS DreamHost uses). For example, I tried the Nakula font:

https://packages.debian.org/wheezy/fonts-nakula

And now fc-list reports it as available for Hindi:

$ fc-list :lang=hi
/home/user/.fonts/nakula.ttf: Nakula:style=Regular

#5

Strange!! I have installed all the fonts (including nakula.ttf) and ArialUnicodeMS.ttf known for its multi language support. I even rebuilt the font cache fc-cache -f -v. And fc-list is showing all fonts I have just installed.

setFont() should work regardless and it working on localhost… but why is this ignored on server??

    $im = new Imagick();
    $im->setFont("/home/user/test/ArialUnicodeMS.ttf"); //this is not working
    $im->setPointSize(25);
    $im->newPseudoImage(200, 200, 'pango:‎हिन्दी');
    $im->setImageFormat("png");
    header("Content-Type: image/png");
    echo $im->getImageBlob();

#6

Yes, I see that problem too. However, when I run your sample code from the command line, it produces a correct PNG:

$ php test.php > output.png

But the same code fails when PHP is run from the web server. I wonder if a difference in environment configuration is the problem?


#7

exactly! not sure why this is happening… i have created a support ticket hopefully they will come up with a solution.


#8

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.