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; }
public function setFont(BaseFont $font, $size) { $this->addToQueue('doSetFont', array($font, $size, $font->getCurrentStyle())); }
public function setFont(BaseFont $font, $size) { $this->addToQueue('doSetFont', array($font->getCurrentWrappedFont(), $size)); }