File: 015-imagickdrawsetresolution.phpt

package info (click to toggle)
php-imagick 3.4.4%2Bphp8.0%2B3.4.4-2%2Bdeb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,776 kB
  • sloc: ansic: 34,120; xml: 842; php: 188; pascal: 85; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 1,571 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
--TEST--
Test ImagickDraw->setResolution
--SKIPIF--
<?php 
	require_once(dirname(__FILE__) . '/skipif.inc');
	checkFormatPresent('png');
?>
--FILE--
<?php

$im = new Imagick();
$im->newImage(1000,1000, "white","png");

$draw = new ImagickDraw();
$draw->setFont (dirname (__FILE__) . '/anonymous_pro_minus.ttf');
$draw->setFontSize(72);

$draw->setResolution(10, 10);
$small = $im->queryFontMetrics($draw, "Hello World");

$draw->setResolution(300, 300);
$large = $im->queryFontMetrics($draw, "Hello World");

if ($small['textWidth'] < $large['textWidth']) {
	echo "Small font _is_ smaller than big font.".PHP_EOL;
}

//These will both be one line.
$oneLine = $im->queryFontMetrics($draw, "Hello Hello");
$forceOneLine = $im->queryFontMetrics($draw, "Hello \nHello", false);

//These will both be multiline
$forceMultiLine = $im->queryFontMetrics($draw, "Hello \nHello", true);
$guessLine = $im->queryFontMetrics($draw, "Hello\nHello");

if (abs($oneLine["textHeight"] - $forceOneLine["textHeight"]) > 0.1) {
	//Reaching this is bad
	echo "One line and forced one line are not the same height.".PHP_EOL;
	echo $oneLine["textHeight"]." ".$forceOneLine["textHeight"].PHP_EOL;
}

if ($forceMultiLine["textHeight"] - (2 * $forceOneLine["textHeight"]) + 2 > 0) {
	echo "Two lines are 2 times one line.".PHP_EOL;
}

if ($guessLine["textHeight"] - (2 * $forceOneLine["textHeight"]) + 2 > 0) {
	echo "Two lines are 2 times one line.".PHP_EOL;
}

echo "OK\n";

?>
--EXPECT--
Small font _is_ smaller than big font.
Two lines are 2 times one line.
Two lines are 2 times one line.
OK