1--TEST-- 2Test ImagickDraw:: setTextInterlineSpacing 3--SKIPIF-- 4<?php 5$minimumVersions = ['6.9.8-6', '7.0.5-7']; 6require_once(dirname(__FILE__) . '/skipif.inc'); 7 8?> 9--FILE-- 10<?php 11 12require_once(dirname(__FILE__) . '/functions.inc'); 13 14$backgroundColor = 'rgb(225, 225, 225)'; 15$strokeColor = 'rgb(0, 0, 0)'; 16$fillColor = 'DodgerBlue2'; 17 18$interlineSpacings = [0, 16, 24, 36]; 19 20$imageHeights = []; 21 22foreach ($interlineSpacings as $interlineSpacing) { 23 24 $draw = new \ImagickDraw(); 25 26 setFontForImagickDraw($draw); 27 28 $draw->setStrokeColor($strokeColor); 29 $draw->setFillColor($fillColor); 30 31 $draw->setStrokeWidth(2); 32 $draw->setFontSize(56); 33 34 $draw->setFontSize(16); 35 $draw->setStrokeAntialias(true); 36 $draw->setTextAntialias(true); 37 $draw->setFillColor('#ff0000'); 38 $draw->setTextInterlineSpacing($interlineSpacing); 39 40 $imagick = new \Imagick(); 41 $imagick->newImage(600, 600, "rgb(230, 230, 230)"); 42 $imagick->setImageFormat('png'); 43 $imagick->annotateImage($draw, 30, 40, 0, "Line 1\nLine 2\nLine 3"); 44 $imagick->trimImage(0); 45 $imagick->setImagePage($imagick->getimageWidth(), $imagick->getimageheight(), 0, 0); 46 47 $bytes = $imagick->getImageBlob(); 48 if (strlen($bytes) <= 0) { 49 die("Failed to generate image."); 50 } 51 52 $imageHeights[$interlineSpacing] = $imagick->getImageHeight(); 53 54 $imagick->writeImage(__DIR__ . "/interline_spacing_test_$interlineSpacing.png"); 55} 56 57 58$previousHeight = null; 59 60foreach ($imageHeights as $interlineSpacing => $imageHeight) { 61 if ($previousHeight !== null) { 62 $differenceFromPrevious = $imageHeight - $previousHeight; 63 if ($differenceFromPrevious < 15) { 64 echo "textInterlineSpacing of $interlineSpacing only resulted in extra height of $differenceFromPrevious\n"; 65 } 66 } 67 68 $previousHeight = $imageHeight; 69} 70 71echo "Ok"; 72?> 73--CLEAN-- 74<?php 75$interlineSpacings = [0, 16, 24, 36]; 76foreach ($interlineSpacings as $interlineSpacing) { 77 @unlink(__DIR__ . "/interline_spacing_test_$interlineSpacing.png"); 78} 79 80?> 81--EXPECTF-- 82Ok 83