mirror of
https://github.com/Intervention/image.git
synced 2025-09-01 01:51:43 +02:00
Merge pull request #624 from lupka/kerning
Add support for text kerning (ImageMagick only)
This commit is contained in:
@@ -46,6 +46,13 @@ abstract class AbstractFont
|
||||
*/
|
||||
public $valign;
|
||||
|
||||
/**
|
||||
* Space between text characters
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
public $kerning = 0;
|
||||
|
||||
/**
|
||||
* Path to TTF or GD library internal font file of the text
|
||||
*
|
||||
@@ -218,6 +225,27 @@ abstract class AbstractFont
|
||||
return $this->valign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text kerning
|
||||
*
|
||||
* @param string $kerning
|
||||
* @return void
|
||||
*/
|
||||
public function kerning($kerning)
|
||||
{
|
||||
$this->kerning = $kerning;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get kerning
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getKerning()
|
||||
{
|
||||
return $this->kerning;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set path to font file
|
||||
*
|
||||
|
@@ -260,4 +260,18 @@ class Font extends \Intervention\Image\AbstractFont
|
||||
imagestring($image->getCore(), $this->getInternalFont(), $posx, $posy, $this->text, $color->getInt());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text kerning
|
||||
*
|
||||
* @param string $kerning
|
||||
* @return void
|
||||
*/
|
||||
public function kerning($kerning)
|
||||
{
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
"Kerning is not supported by GD driver."
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -37,6 +37,7 @@ class Font extends AbstractFont
|
||||
|
||||
$draw->setFontSize($this->size);
|
||||
$draw->setFillColor($color->getPixel());
|
||||
$draw->setTextKerning($this->kerning);
|
||||
|
||||
// align horizontal
|
||||
switch (strtolower($this->align)) {
|
||||
|
@@ -57,6 +57,13 @@ class AbstractFontTest extends TestCase
|
||||
$this->assertEquals('top', $font->valign);
|
||||
}
|
||||
|
||||
public function testKerning()
|
||||
{
|
||||
$font = $this->getMockForAbstractClass('\Intervention\Image\AbstractFont');
|
||||
$font->kerning(10.5);
|
||||
$this->assertEquals(10.5, $font->kerning);
|
||||
}
|
||||
|
||||
public function testFile()
|
||||
{
|
||||
$font = $this->getMockForAbstractClass('\Intervention\Image\AbstractFont');
|
||||
|
Reference in New Issue
Block a user