Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 private function exportRow($row, $x, $w)
 {
     $color = Color::NIL();
     $ret = '';
     $sz = count($this->buf[$row]);
     for ($i = $x; $i < $x + $w and $i < $sz; $i++) {
         if (!isset($this->buf[$row][$i])) {
             echo sprintf("Dump: row = %s, i = %s, x = %s, w = %s\n", $row, $i, $x, $w);
             //echo var_export($this->buf[$row]) . "\n";
             exit(1);
         }
         list($char, $clr) = $this->buf[$row][$i];
         if ($color != $clr) {
             $ret .= $clr->export();
             $color = $clr;
         }
         $ret .= $char;
         if (WString::isWide($char)) {
             $i++;
         }
     }
     if ($x + $w > $sz) {
         if ($color != Color::NIL()) {
             $ret .= Color::NIL()->export();
         }
         $ret .= str_repeat(' ', $x + $w - $sz);
     }
     return $ret;
 }