Search code examples
phpimagettftext

Euro (€) in imagettftext


How can i create an € sign with imagettftext()? I'm using the font 'Lucida Grande' which contains the euro sign. € does not work, too.


Solution

  • See the documentation (emphasis mine):

    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.

    Named entities, such as ©, are not supported. Consider using html_entity_decode() to decode these named entities into UTF-8 strings (html_entity_decode() supports this as of PHP 5.0.0).

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

    You can try using the actual € character, or decoding it, or using the decimal character reference. See here for the entry in FileFormat.Info Unicode Lookup, which has all the code formats: http://www.fileformat.info/info/unicode/char/20ac/index.htm. In this case it would be €.