Skip to content

Commit 9832b9d

Browse files
Merge pull request #1463 from magento-borg/MAGETWO-62464
[Borg] Travis fix
2 parents 097f8af + 874b53f commit 9832b9d

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
namespace Magento\Framework\Image\Adapter;
77

8-
use Magento\Framework\App\Filesystem\DirectoryList;
9-
108
/**
119
* @magentoAppIsolation enabled
1210
*/
@@ -547,11 +545,6 @@ public function cropDataProvider()
547545
*/
548546
public function testCreatePngFromString($pixel1, $expectedColor1, $pixel2, $expectedColor2, $adapterType)
549547
{
550-
if (!function_exists('imagettfbbox')
551-
|| (getenv('TRAVIS') && getenv('TRAVIS_PHP_VERSION') == '7.1')
552-
) {
553-
$this->markTestSkipped('Workaround for problem with imagettfbbox() function on Travis');
554-
}
555548
$adapter = $this->_getAdapter($adapterType);
556549

557550
/** @var \Magento\Framework\Filesystem\Directory\ReadFactory readFactory */
@@ -564,9 +557,11 @@ public function testCreatePngFromString($pixel1, $expectedColor1, $pixel2, $expe
564557
$adapter->refreshImageDimensions();
565558

566559
$color1 = $adapter->getColorAt($pixel1['x'], $pixel1['y']);
560+
unset($color1['alpha']);
567561
$this->assertEquals($expectedColor1, $color1);
568562

569563
$color2 = $adapter->getColorAt($pixel2['x'], $pixel2['y']);
564+
unset($color2['alpha']);
570565
$this->assertEquals($expectedColor2, $color2);
571566
}
572567

@@ -580,30 +575,30 @@ public function createPngFromStringDataProvider()
580575
return [
581576
[
582577
['x' => 5, 'y' => 8],
583-
'expectedColor1' => ['red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0],
584-
['x' => 0, 'y' => 15],
585-
'expectedColor2' => ['red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127],
578+
'expectedColor1' => ['red' => 0, 'green' => 0, 'blue' => 0],
579+
['x' => 0, 'y' => 14],
580+
'expectedColor2' => ['red' => 255, 'green' => 255, 'blue' => 255],
586581
\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_GD2,
587582
],
588583
[
589-
['x' => 4, 'y' => 7],
590-
'expectedColor1' => ['red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0],
591-
['x' => 0, 'y' => 15],
592-
'expectedColor2' => ['red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127],
584+
['x' => 5, 'y' => 12],
585+
'expectedColor1' => ['red' => 0, 'green' => 0, 'blue' => 0],
586+
['x' => 0, 'y' => 20],
587+
'expectedColor2' => ['red' => 255, 'green' => 255, 'blue' => 255],
593588
\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_IM
594589
],
595590
[
596591
['x' => 1, 'y' => 14],
597-
'expectedColor1' => ['red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127],
592+
'expectedColor1' => ['red' => 255, 'green' => 255, 'blue' => 255],
598593
['x' => 5, 'y' => 12],
599-
'expectedColor2' => ['red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0],
594+
'expectedColor2' => ['red' => 0, 'green' => 0, 'blue' => 0],
600595
\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_GD2
601596
],
602597
[
603-
['x' => 1, 'y' => 14],
604-
'expectedColor1' => ['red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127],
605-
['x' => 4, 'y' => 10],
606-
'expectedColor2' => ['red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0],
598+
['x' => 1, 'y' => 20],
599+
'expectedColor1' => ['red' => 255, 'green' => 255, 'blue' => 255],
600+
['x' => 5, 'y' => 16],
601+
'expectedColor2' => ['red' => 0, 'green' => 0, 'blue' => 0],
607602
\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_IM
608603
]
609604
];

lib/internal/Magento/Framework/Image/Adapter/Gd2.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,8 @@ protected function _createImageFromText($text)
737737
protected function _createImageFromTtfText($text, $font)
738738
{
739739
$boundingBox = imagettfbbox($this->_fontSize, 0, $font, $text);
740-
$width = abs($boundingBox[4]) + abs($boundingBox[0]);
741-
$height = abs($boundingBox[5]) + abs($boundingBox[1]);
740+
$width = abs($boundingBox[4] - $boundingBox[0]);
741+
$height = abs($boundingBox[5] - $boundingBox[1]);
742742

743743
$this->_createEmptyImage($width, $height);
744744

@@ -748,7 +748,7 @@ protected function _createImageFromTtfText($text, $font)
748748
$this->_fontSize,
749749
0,
750750
0,
751-
$height - abs($boundingBox[1]),
751+
$height - $boundingBox[1],
752752
$black,
753753
$font,
754754
$text

lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ public function createPngFromString($text, $font = '')
434434
}
435435
}
436436

437-
$draw->setFontSize($this->_fontSize);
437+
// Font size for ImageMagick is set in pixels, while the for GD2 it is in points. 3/4 is ratio between them
438+
$draw->setFontSize($this->_fontSize * 4 / 3);
438439
$draw->setFillColor($color);
439440
$draw->setStrokeAntialias(true);
440441
$draw->setTextAntialias(true);

0 commit comments

Comments
 (0)