Esempio n. 1
0
 public function testGetTextBoxes()
 {
     $text = 'Test not exceeding';
     $font = $this->getFont();
     $fitter = new Fitter($text, $font);
     $box = new Box(500, 150);
     $fitter->makeTextFitInBox($box);
     $result = $fitter->getTextBoxes();
     $this->assertCount(1, $result);
     $this->assertInstanceOf('\\Imagine\\Image\\Box', $result[0]);
 }
Esempio n. 2
0
 public function drawText(Image $image, $string, $offsetY)
 {
     $box = new Box($image->getSize()->getWidth(), $image->getSize()->getHeight() / 4);
     $fitter = new Fitter($string, $this->getFont());
     $fitter->makeTextFitInBox($box);
     $boxes = $fitter->getTextBoxes();
     $start = $fitter->getStartingPointForCenteredBox($image->getSize(), $boxes[0]);
     foreach ($fitter->getLines() as $k => $line) {
         $start = $fitter->getStartingPointForCenteredBox($image->getSize(), $boxes[$k], $offsetY);
         $image->draw()->text($line, $fitter->getFont(), $start);
         if (version_compare(phpversion("imagick"), "3.0.2", ">=")) {
             $offsetY += $fitter->getFont()->getSize() * 96 / 72;
         } else {
             $offsetY += $fitter->getFont()->getSize();
         }
     }
 }