本文整理匯總了PHP中Imagine\Gd\Imagine::font方法的典型用法代碼示例。如果您正苦於以下問題:PHP Imagine::font方法的具體用法?PHP Imagine::font怎麽用?PHP Imagine::font使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Imagine\Gd\Imagine
的用法示例。
在下文中一共展示了Imagine::font方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* Constructs a new ImageNotFoundResponse
* @param int $maxWidth
* @param int $maxHeight
* @param int $code
* @param string $message
*/
public function __construct($maxWidth, $maxHeight, $code, $message)
{
if ($maxWidth == 0) {
$maxWidth = 300;
}
if ($maxHeight == 0) {
$maxHeight = 300;
}
$imagine = new Imagine();
$size = new Box(300, 300);
$image = $imagine->create($size);
$black = $image->palette()->color("000");
$path = realpath(__DIR__ . "/../Resources/public/fonts/OpenSans-Regular.ttf");
$font = $imagine->font($path, 24, $black);
$image->draw()->text($message, $font, new Point(0, 0));
$box = $image->getSize();
$box = $box->widen($maxWidth);
if ($box->getHeight() > $maxHeight) {
$box = $box->heighten($maxHeight);
}
$image->resize($box);
return parent::__construct($image->get("png"), $code, array("Content-Type" => "image/png"));
}
示例2: font
/**
* @param int $fontSize
* @param string $textColor
* @param string $fontName
* @return \Imagine\Gd\Font|\Imagine\Image\FontInterface
*/
protected function font($fontSize = null, $textColor = null, $fontName = null)
{
return $this->imagine->font($fontName ? $fontName : $this->fontName, $fontSize ? $fontSize : $this->fontSize, $textColor ? is_object($textColor) ? $textColor : $this->color($textColor) : $this->color($this->textColor));
}