/** * Draw a block of text, word wrap, right justified, support newline character (\n) */ public function drawTextBlockRight($x1, $y1, $x2, $y2, $text) { if ($x1 > $x2) { list($x1, $x2) = array($x2, $x1); } if ($y1 > $y2) { list($y1, $y2) = array($y2, $y1); } $width = $x2 - $x1; $block = WString::wordWrap($text, $width); foreach ($block as $line) { if ($y1 > $y2) { break; } $left = $width - WString::stringWidth($line); $pre = str_repeat(' ', $left); $this->drawString($x1, $y1, $pre . $line); $y1++; } return $this; }