1--TEST-- 2Test ImagickDraw->setResolution 3--SKIPIF-- 4<?php 5 require_once(dirname(__FILE__) . '/skipif.inc'); 6 checkFormatPresent('png'); 7?> 8--FILE-- 9<?php 10 11$im = new Imagick(); 12$im->newImage(1000,1000, "white","png"); 13 14$draw = new ImagickDraw(); 15$draw->setFont (dirname (__FILE__) . '/anonymous_pro_minus.ttf'); 16$draw->setFontSize(72); 17 18$draw->setResolution(10, 10); 19$small = $im->queryFontMetrics($draw, "Hello World"); 20 21$draw->setResolution(300, 300); 22$large = $im->queryFontMetrics($draw, "Hello World"); 23 24if ($small['textWidth'] < $large['textWidth']) { 25 echo "Small font _is_ smaller than big font.".PHP_EOL; 26} 27 28//These will both be one line. 29$oneLine = $im->queryFontMetrics($draw, "Hello Hello"); 30$forceOneLine = $im->queryFontMetrics($draw, "Hello \nHello", false); 31 32//These will both be multiline 33$forceMultiLine = $im->queryFontMetrics($draw, "Hello \nHello", true); 34$guessLine = $im->queryFontMetrics($draw, "Hello\nHello"); 35 36if (abs($oneLine["textHeight"] - $forceOneLine["textHeight"]) > 0.1) { 37 //Reaching this is bad 38 echo "One line and forced one line are not the same height.".PHP_EOL; 39 echo $oneLine["textHeight"]." ".$forceOneLine["textHeight"].PHP_EOL; 40} 41 42if ($forceMultiLine["textHeight"] - (2 * $forceOneLine["textHeight"]) + 2 > 0) { 43 echo "Two lines are 2 times one line.".PHP_EOL; 44} 45 46if ($guessLine["textHeight"] - (2 * $forceOneLine["textHeight"]) + 2 > 0) { 47 echo "Two lines are 2 times one line.".PHP_EOL; 48} 49 50echo "OK\n"; 51 52?> 53--EXPECT-- 54Small font _is_ smaller than big font. 55Two lines are 2 times one line. 56Two lines are 2 times one line. 57OK 58