drawChar($im, $this->text, true); $this->drawText($im); } function getLabel() { $label = $this->label; if($this->label === $this->AUTO_LABEL) { $label = ''; } return $label; } /** * Returns the maximal size of a barcode * * @return int[] */ function getMaxSize() { $p = BCGBarcode1D::getMaxSize(); $array = str_split($this->text, 1); $textlength = (array_sum($array) + count($array)) * $this->scale; return array($p[0] + $textlength, $p[1]); } /** * Overloaded method for drawing special label * * @param resource $im */ function drawText(&$im) { if($this->label !== $this->AUTO_LABEL && $this->label !== '') { $pA = $this->getMaxSize(); $pB = BCGBarcode1D::getMaxSize(); $w = $pA[0] - $pB[0]; if(is_a($this->textfont, 'BCGFont')) { $textfont = $this->textfont; // clone $textfont->setText($this->label); $xPosition = ($w / 2) - $textfont->getWidth() / 2 + $this->offsetX * $this->scale; $yPosition = $this->thickness * $this->scale + $textfont->getHeight() - $textfont->getUnderBaseline() + $this->SIZE_SPACING_FONT + $this->offsetY * $this->scale; $text_color = $this->colorFg->allocate($im); $textfont->draw($im, $text_color, $xPosition, $yPosition); } elseif($this->textfont !== 0) { $xPosition = ($w / 2) - (strlen($this->label) * imagefontwidth($this->textfont)) / 2 + $this->offsetX * $this->scale; $yPosition = $this->thickness * $this->scale + $this->offsetY * $this->scale + $this->SIZE_SPACING_FONT; $text_color = $this->colorFg->allocate($im); imagestring($im, $this->textfont, $xPosition, $yPosition, $this->label, $text_color); } } } }; ?>