Frage

I've looked everywhere, but I can't figure out why I am facing this problem.

I am using phpThumb to do add some text (watermark) on some photos. The problem is that I need to use the special characters from Norway (æøå). These don't play so nice with ImageTTFtext.

enter image description here

The picture above contains the code for æ and should (according to the documentation) be correct. I've also tried some functions I found here on stack, but everything returns the same. Why does it print the code and not the actual character I am trying to display?

Is this due to old version of some software or something?

Versions:

PHP 5.3.2
ImageMagick 6.5.7
GD: 2.0

EDIT: Just to make it clear, I am passing the text the "correct" way according to the docs. Passing utf_encode('€') as the argument SHOULD WORK.

War es hilfreich?

Lösung 2

Answering this so anyone facing the same problem as me can find a solution.

It turns out the "built in" font from GD did not support my special characters. Upload your own fonts and use them in the function, it should work.

Andere Tipps

You are concerned about the text parameter of imagettftext. Let's review it's documentation:

The text string in UTF-8 encoding.

May include decimal numeric character references (of the form: € [€]) to access characters in a font beyond position 127. The hexadecimal format (like © [©]) is supported. Strings in UTF-8 encoding can be passed directly.

In your question you have neither posted the code you are using nor did you specifiy the literal string used. For example if you pass a string "î" you will see î. So the display itself you added to your question might demonstrate what you experience as an issue, but the display itself might be totally unrelated to it's cause. The cause would be the string then.

Next to that the function is part of the gd extension, not ImageMagick.

The PHP version 5.3.2 is also out of date, however I have not scanned the changelog of it (nor the GD library version you use) if there is an error that matches what you have described. But it seems possible.

In any case should imagettftext display the text correctly. Even if a character is not found, you would see something different.

If a character is used in the string which is not supported by the font, a hollow rectangle will replace the character. From the parameters description:

Provide a hex-dump of the string you pass to that function and add it to your question.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top