本文整理汇总了PHP中Font::getWidth方法的典型用法代码示例。如果您正苦于以下问题:PHP Font::getWidth方法的具体用法?PHP Font::getWidth怎么用?PHP Font::getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Font
的用法示例。
在下文中一共展示了Font::getWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gettimeofday
function __construct()
{
parent::__construct();
$this->startTime = gettimeofday(true);
$message = " --- POWERED BY LIBCACA --- OLDSCHOOL TEXT EFFECTS ARE 100% PURE WIN";
$this->scroll = new Canvas(strlen($message), 1);
$this->scroll->setColorAnsi(AnsiColor::WHITE, AnsiColor::TRANSPARENT);
$this->scroll->putStr(0, 0, $message);
$fontList = Font::getList();
$f = new Font($fontList[1]);
$w = $f->getWidth() * strlen($message);
$h = $f->getHeight();
$this->image = imagecreatetruecolor($w, $h);
imagealphablending($this->image, false);
imagesavealpha($this->image, true);
$this->d = new Dither($this->image);
$f->Render($this->scroll, $this->image);
}
示例2: __construct
/**
* @param Font $font
* @param string $text
* @param int $color
* @param int $spacing
* @throws FontException
*/
public function __construct(Font $font, $text, $color, $spacing = 1)
{
$cw = $font->getWidth();
$ch = $font->getHeight();
// no support for UTF-8 or newlines!
$num_chars = strlen($text);
$full_width = $cw * $num_chars + ($num_chars - 1) * $spacing;
$full_height = $ch;
$pixels = array_fill(0, $full_width * $full_height, 0);
for ($i = 0; $i < $num_chars; ++$i) {
$char = ord($text[$i]);
$cox = ($cw + $spacing) * $i;
$char_pixels = $font->getPixelsForCharacter($char);
for ($y = 0; $y < $ch; ++$y) {
for ($x = 0; $x < $cw; ++$x) {
if ($char_pixels[$y * $cw + $x]) {
$pixels[$full_width * $y + $cox + $x] = $color;
}
}
}
}
parent::__construct($full_width, $full_height, $pixels);
}