diff --git a/src/Drivers/AbstractFontProcessor.php b/src/Drivers/AbstractFontProcessor.php index 37fea91c..b19f39dc 100644 --- a/src/Drivers/AbstractFontProcessor.php +++ b/src/Drivers/AbstractFontProcessor.php @@ -45,6 +45,16 @@ abstract class AbstractFontProcessor implements FontProcessorInterface return $lines; } + /** + * {@inheritdoc} + * + * @see FontProcessorInterface::nativeFontSize() + */ + public function nativeFontSize(FontInterface $font): float + { + return $font->size(); + } + /** * {@inheritdoc} * diff --git a/src/Drivers/Gd/FontProcessor.php b/src/Drivers/Gd/FontProcessor.php index b90b4666..e7254081 100644 --- a/src/Drivers/Gd/FontProcessor.php +++ b/src/Drivers/Gd/FontProcessor.php @@ -57,7 +57,17 @@ class FontProcessor extends AbstractFontProcessor */ public function nativeFontSize(FontInterface $font): float { - return floatval(ceil($font->size() * .75)); + return floatval(round($font->size() * .76, 6)); + } + + /** + * {@inheritdoc} + * + * @see FontProcessorInterface::leading() + */ + public function leading(FontInterface $font): int + { + return (int) round(parent::leading($font) * .8); } /** diff --git a/src/Drivers/Imagick/FontProcessor.php b/src/Drivers/Imagick/FontProcessor.php index fb76622c..831b5110 100644 --- a/src/Drivers/Imagick/FontProcessor.php +++ b/src/Drivers/Imagick/FontProcessor.php @@ -40,16 +40,6 @@ class FontProcessor extends AbstractFontProcessor ); } - /** - * {@inheritdoc} - * - * @see FontProcessorInterface::nativeFontSize() - */ - public function nativeFontSize(FontInterface $font): float - { - return $font->size(); - } - /** * Imagick::annotateImage() needs an ImagickDraw object - this method takes * the font object as the base and adds an optional passed color to the new diff --git a/tests/Drivers/Gd/FontProcessorTest.php b/tests/Drivers/Gd/FontProcessorTest.php index 3159fbc3..73c0091a 100644 --- a/tests/Drivers/Gd/FontProcessorTest.php +++ b/tests/Drivers/Gd/FontProcessorTest.php @@ -62,7 +62,7 @@ class FontProcessorTest extends TestCase { $processor = new FontProcessor(); $size = $processor->nativeFontSize(new Font('5')); - $this->assertEquals(9.0, $size); + $this->assertEquals(9.12, $size); } public function testTextBlock(): void @@ -90,6 +90,6 @@ class FontProcessorTest extends TestCase { $processor = new FontProcessor(); $result = $processor->leading(new Font()); - $this->assertEquals(10, $result); + $this->assertEquals(8, $result); } }