本文整理汇总了PHP中ImagickDraw::setFontStretch方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickDraw::setFontStretch方法的具体用法?PHP ImagickDraw::setFontStretch怎么用?PHP ImagickDraw::setFontStretch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImagickDraw
的用法示例。
在下文中一共展示了ImagickDraw::setFontStretch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ImagickDraw
<?php
$draw = new ImagickDraw();
$font_path = __DIR__ . '/php_imagick_tests/anonymous_pro_minus.ttf';
$draw->setFont($font_path);
var_dump($draw->getFont() === $font_path);
try {
$draw->setFont(">_<");
} catch (Exception $ex) {
var_dump("setFont");
}
$draw->setFontSize(12);
var_dump($draw->getFontSize());
$draw->setFontStretch(Imagick::STRETCH_SEMIEXPANDED);
var_dump($draw->getFontStretch() === Imagick::STRETCH_SEMIEXPANDED);
$draw->setFontStyle(Imagick::STYLE_ITALIC);
var_dump($draw->getFontStyle() === Imagick::STYLE_ITALIC);
$draw->setFontWeight(500);
var_dump($draw->getFontWeight());
try {
$draw->setFontWeight(1000);
} catch (ImagickDrawException $ex) {
var_dump($ex->getMessage());
}
示例2: setFontStretch
function setFontStretch($fillColor, $strokeColor, $backgroundColor)
{
$draw = new \ImagickDraw();
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(2);
$draw->setFontSize(36);
$fontStretchTypes = [\Imagick::STRETCH_ULTRACONDENSED, \Imagick::STRETCH_CONDENSED, \Imagick::STRETCH_SEMICONDENSED, \Imagick::STRETCH_SEMIEXPANDED, \Imagick::STRETCH_EXPANDED, \Imagick::STRETCH_EXTRAEXPANDED, \Imagick::STRETCH_ULTRAEXPANDED, \Imagick::STRETCH_ANY];
$offset = 0;
foreach ($fontStretchTypes as $fontStretch) {
$draw->setFontStretch($fontStretch);
$draw->annotation(50, 75 + $offset, "Lorem Ipsum!");
$offset += 50;
}
$imagick = new \Imagick();
$imagick->newImage(500, 500, $backgroundColor);
$imagick->setImageFormat("png");
$imagick->drawImage($draw);
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}