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