Skip to content

Commit 1758590

Browse files
committed
MAGETWO-62464: Travis CI: GD2 imagettfbbox creates image with invalid size
1 parent b06604f commit 1758590

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,6 @@ public function cropDataProvider()
545545
*/
546546
public function testCreatePngFromString($pixel1, $expectedColor1, $pixel2, $expectedColor2, $adapterType)
547547
{
548-
if (!function_exists('imagettfbbox')) {
549-
$this->markTestSkipped('Workaround for problem with imagettfbbox() function on Travis');
550-
}
551548
$adapter = $this->_getAdapter($adapterType);
552549

553550
/** @var \Magento\Framework\Filesystem\Directory\ReadFactory readFactory */
@@ -560,9 +557,11 @@ public function testCreatePngFromString($pixel1, $expectedColor1, $pixel2, $expe
560557
$adapter->refreshImageDimensions();
561558

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

565563
$color2 = $adapter->getColorAt($pixel2['x'], $pixel2['y']);
564+
unset($color2['alpha']);
566565
$this->assertEquals($expectedColor2, $color2);
567566
}
568567

@@ -576,30 +575,30 @@ public function createPngFromStringDataProvider()
576575
return [
577576
[
578577
['x' => 5, 'y' => 8],
579-
'expectedColor1' => ['red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0],
580-
['x' => 0, 'y' => 15],
581-
'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],
582581
\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_GD2,
583582
],
584583
[
585-
['x' => 4, 'y' => 7],
586-
'expectedColor1' => ['red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0],
587-
['x' => 0, 'y' => 15],
588-
'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],
589588
\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_IM
590589
],
591590
[
592591
['x' => 1, 'y' => 14],
593-
'expectedColor1' => ['red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127],
592+
'expectedColor1' => ['red' => 255, 'green' => 255, 'blue' => 255],
594593
['x' => 5, 'y' => 12],
595-
'expectedColor2' => ['red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0],
594+
'expectedColor2' => ['red' => 0, 'green' => 0, 'blue' => 0],
596595
\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_GD2
597596
],
598597
[
599-
['x' => 1, 'y' => 14],
600-
'expectedColor1' => ['red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127],
601-
['x' => 4, 'y' => 10],
602-
'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],
603602
\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_IM
604603
]
605604
];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ protected function _createImageFromTtfText($text, $font)
748748
$this->_fontSize,
749749
0,
750750
0,
751-
$height,
751+
$height - $boundingBox[1],
752752
$black,
753753
$font,
754754
$text

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

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

437-
$draw->setFontSize($this->_fontSize);
437+
$draw->setFontSize($this->_fontSize * 4 / 3);
438438
$draw->setFillColor($color);
439439
$draw->setStrokeAntialias(true);
440440
$draw->setTextAntialias(true);

0 commit comments

Comments
 (0)