public function __construct($bsw, $size = 1, $height = 1919, $spacing = 10, $offset = 50) { //set variables// $this->bsw = $bsw; $this->size = $size; $this->height = $height / $size; $this->spacing = $spacing; $this->offset = $offset; $this->units = bsw2unit($bsw); //init variables $curH = $this->padding; $prev = ''; $col = ''; $posX = array(); $posY = array(); //punc vs sign, spacing and lanes $prev = ''; $cnt = count($this->units); for ($i = 0; $i < $cnt; $i++) { $unitbsw = $this->units[$i]; $chars = str_split($unitbsw, 3); $first = $chars[0]; //unit type for spacing test later if (isPunc($first)) { $cur = "P"; //punctuation $lane = 0; } else { $cur = "S"; //sign $lane = char2lane($first); } //adjust padding based on punc/sign order switch ($prev . $cur) { case 'SS': //sign sign $padding = $this->spacing * 2; break; case 'SP': //sign punctuation //sign punctuation case 'PP': //punctuation punctuation $padding = $this->spacing; break; case 'PS': //punctuation sign $padding = $this->spacing * 3; break; default: $padding = 0; } $prev = $cur; if ($cur == "P") { $unit = new Symbol($unitbsw); } else { $unit = new Sign($first . bsw2cluster($unitbsw)); $unitbsw = $unit->getBSW(); } if ($curH + $padding + $unit->getHeight() < $this->height) { //go ahead and add $col .= $unitbsw; //this is the value to center $posX[] = $unit->getCenterX() - $this->offset * $lane; $posY[] = $curH + $padding; $curH += $padding + $unit->getHeight(); } else { //finalize column list $this->cols[] = $col; $this->posX[] = $posX; $this->posY[] = $posY; $col = ''; $posX = array(); $posY = array(); $curH = $this->padding; $prev = ''; $i--; } } if ($col) { $this->cols[] = $col; $this->posX[] = $posX; $this->posY[] = $posY; } }