private static function buildWordsNoGreaterThanGivenWidth($wordCandidate, $maxPossibleWordWidth, Font $font, $fontSize, $encoding, array &$words, array &$wordSizes)
 {
     $wordLength = mb_strlen($wordCandidate, $encoding);
     $buildingWord = '';
     $buildingWordWidth = 0;
     for ($i = 0; $i < $wordLength; $i++) {
         $char = mb_substr($wordCandidate, $i, 1, $encoding);
         $charSize = $font->getWidthOfText($char, $fontSize);
         $nextBuildingWordWidth = $buildingWordWidth + $charSize;
         if ($nextBuildingWordWidth > $maxPossibleWordWidth) {
             $words[] = $buildingWord;
             $wordSizes[] = $buildingWordWidth;
             $buildingWord = $char;
             $buildingWordWidth = $charSize;
         } else {
             $buildingWord .= $char;
             $buildingWordWidth += $charSize;
         }
     }
     //remaning word
     $words[] = $buildingWord;
     $wordSizes[] = $buildingWordWidth;
 }
Esempio n. 2
0
 public function setFont(BaseFont $font, $size)
 {
     $this->addToQueue('doSetFont', array($font, $size, $font->getCurrentStyle()));
 }
Esempio n. 3
0
 public function setFont(BaseFont $font, $size)
 {
     $this->addToQueue('doSetFont', array($font->getCurrentWrappedFont(), $size));
 }