Search code examples
phpunicodeimagettftext

PHP imagettftext() cannot display Unicode Plane 1 characters


I'm trying to render Egyptian Hyeroglyphs from Unicode Plane 1 (U+13000..U+1342F) as images with PHP imagettftext()

Here is my code:

$img = imagecreatetruecolor(240, 240);
imagettftext($img, 60, 0, 48, 192, 0, '/path/to/fonts/NotoSansEgyptianHieroglyphs-Regular.ttf', '𓄿');`

NB: This Noto font correctly handles Hieroglyphs such as ð“„¿ 𓄿 see here

This question struggles with UTF-8 characters, but I've tested this code successfully on many fonts with many codepoints. Characters are already html entities encoded with &#...; as stated in the documentation and UTF-8 characters (accents, etc.) work fine, at least, according to my tests, up to 65533 (plane 0), but Hieroglyphs are in plane 1 and it seems to be impossible to render anything but a single blank square.


Solution

  • It is not currently possible. libgd does not support Unicode plane 1 characters. It's a known issue since, at least 2015, see https://github.com/libgd/libgd/issues/185