mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 08:27:03 +03:00
Added: Incorrect image orientation
This commit is contained in:
parent
217207883f
commit
e3b62d24d8
87 changed files with 10461 additions and 21 deletions
68
rainloop/v/0.0.0/app/libraries/Imagine/Imagick/Font.php
Normal file
68
rainloop/v/0.0.0/app/libraries/Imagine/Imagick/Font.php
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Imagine package.
|
||||
*
|
||||
* (c) Bulat Shakirzyanov <mallluhuct@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Imagine\Imagick;
|
||||
|
||||
use Imagine\Image\AbstractFont;
|
||||
use Imagine\Image\Box;
|
||||
use Imagine\Image\Palette\Color\ColorInterface;
|
||||
|
||||
/**
|
||||
* Font implementation using the Imagick PHP extension
|
||||
*/
|
||||
final class Font extends AbstractFont
|
||||
{
|
||||
/**
|
||||
* @var \Imagick
|
||||
*/
|
||||
private $imagick;
|
||||
|
||||
/**
|
||||
* @param \Imagick $imagick
|
||||
* @param string $file
|
||||
* @param integer $size
|
||||
* @param ColorInterface $color
|
||||
*/
|
||||
public function __construct(\Imagick $imagick, $file, $size, ColorInterface $color)
|
||||
{
|
||||
$this->imagick = $imagick;
|
||||
|
||||
parent::__construct($file, $size, $color);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function box($string, $angle = 0)
|
||||
{
|
||||
$text = new \ImagickDraw();
|
||||
|
||||
$text->setFont($this->file);
|
||||
|
||||
/**
|
||||
* @see http://www.php.net/manual/en/imagick.queryfontmetrics.php#101027
|
||||
*
|
||||
* ensure font resolution is the same as GD's hard-coded 96
|
||||
*/
|
||||
if (version_compare(phpversion("imagick"), "3.0.2", ">=")) {
|
||||
$text->setResolution(96, 96);
|
||||
$text->setFontSize($this->size);
|
||||
} else {
|
||||
$text->setFontSize((int) ($this->size * (96 / 72)));
|
||||
}
|
||||
|
||||
$info = $this->imagick->queryFontMetrics($text, $string);
|
||||
|
||||
$box = new Box($info['textWidth'], $info['textHeight']);
|
||||
|
||||
return $box;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue