File: gmagickdraw_038_setFontStretch_basic.phpt

package info (click to toggle)
php-gmagick 2.0.6~rc1%2B%2B-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,660 kB
  • sloc: ansic: 6,890; php: 330; xml: 267; pascal: 5; makefile: 2
file content (61 lines) | stat: -rw-r--r-- 1,635 bytes parent folder | download | duplicates (5)
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
58
59
60
61
--TEST--
Test GmagickDraw, setFontStretch
--SKIPIF--
<?php
$imageMagickRequiredVersion=0x675;
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php

$backgroundColor = 'rgb(225, 225, 225)';
$strokeColor = 'rgb(0, 0, 0)';
$fillColor = 'DodgerBlue2';

function setFontStretch($fillColor, $strokeColor, $backgroundColor) {

    $draw = new \GmagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(2);
    $draw->setFontSize(36);

    $fontStretchTypes = array(
        \Gmagick::STRETCH_ULTRACONDENSED,
        \Gmagick::STRETCH_CONDENSED,
        \Gmagick::STRETCH_SEMICONDENSED,
        \Gmagick::STRETCH_SEMIEXPANDED,
        \Gmagick::STRETCH_EXPANDED,
        \Gmagick::STRETCH_EXTRAEXPANDED,
        \Gmagick::STRETCH_ULTRAEXPANDED,
        \Gmagick::STRETCH_ANY
    );

    $offset = 0;
    foreach ($fontStretchTypes as $fontStretch) {
        $draw->setFontStretch($fontStretch);
        $draw->annotate(50, 75 + $offset, "Lorem Ipsum!");
        $offset += 50;
        
        $currentFontStretch = $draw->getFontStretch($fontStretch);

        if ($currentFontStretch !== $fontStretch) {
            echo "Failed to get correct fontStretch $currentFontStretch != $fontStretch \n";
        }
    }

    $gmagick = new \Gmagick();
    $gmagick->newImage(500, 500, $backgroundColor);
    $gmagick->setImageFormat("png");
    $gmagick->drawImage($draw);

    $bytes = $gmagick->getImageBlob();
    if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 
}

setFontStretch($fillColor, $strokeColor, $backgroundColor) ;
echo "Ok";
?>
--EXPECTF--
Ok