1--TEST-- 2Font charmap order is deterministic based on order in the font, use the selected encoding 3--SKIPIF-- 4<?php 5 if(!extension_loaded('gd')){ die('skip gd extension not available'); } 6 if(!function_exists('imagettftext')) die('skip imagettftext() not available'); 7 if(gd_info()['JIS-mapped Japanese Font Support']) die('skip JIS-mapped Japanese Font Support not supported'); 8?> 9--FILE-- 10<?php 11// this is an Apache Licensed font, see separate LICENSE file 12$font = __DIR__.'/Rochester-Regular.otf'; 13 14// thank you Helgi 15$sample_string = "\xC3\x9E\xC3\xB6"; 16 17$im = imagecreatetruecolor( 18 100, 19 80 20); 21 22$white = imagecolorallocate($im, 255, 255, 255); 23$black = imagecolorallocate($im, 0, 0, 0); 24 25imagefilledrectangle( 26 $im, 27 0, 28 0, 29 100, 30 80, 31 $white 32); 33 34imagettftext( 35 $im, 36 45, 37 0, 38 15, 39 60, 40 $black, 41 $font, 42 $sample_string 43); 44 45$w = imagesx($im); 46$h = imagesy($im); 47$black_pixels = 0; 48 49for ($y = 0; $y < $h; $y++) { 50 for ($x = 0; $x < $w; $x++) { 51 $rgb = imagecolorat($im, $x, $y); 52 if ($rgb === 0) { 53 ++$black_pixels; 54 } 55 } 56} 57 58if ($black_pixels >= 10) { 59 printf("SUCCESS %d black pixels\n", $black_pixels); 60} else { 61 printf("FAIL %d black pixels\n", $black_pixels); 62} 63imagedestroy($im); 64?> 65--EXPECTF-- 66SUCCESS %d black pixels 67