/** * Overloaded method for drawing special label * * @param resource $im */ function drawText(&$im) { if ($this->label !== $this->AUTO_LABEL) { BCGBarcode1D::drawText($im); } elseif ($this->label !== '') { $temp_text = $this->text . $this->keys[$this->checksumValue]; if (is_a($this->textfont, 'BCGFont')) { $code1 = 0; $code2 = 0; $this->textfont->setText($temp_text); $this->drawExtendedBars($im, $this->textfont->getHeight(), $code1, $code2); // We need to separate the text, one on the left and one on the right, one starting and one ending $text0 = substr($temp_text, 1, 1); $text1 = substr($temp_text, 2, 5); $text2 = substr($temp_text, 7, 5); $text3 = substr($temp_text, 12, 1); $font0 = $this->textfont; // clone $font1 = $this->textfont; // clone $font2 = $this->textfont; // clone $font3 = $this->textfont; // clone $font0->setText($text0); $font1->setText($text1); $font2->setText($text2); $font3->setText($text3); $xPosition0 = $this->offsetX * $this->scale - $font0->getWidth() - 4; // -4 is just for beauty; $xPosition3 = $this->offsetX * $this->scale + $this->positionX * $this->scale + 2; $yPosition0 = $this->thickness * $this->scale + $font0->getHeight() / 2 + $this->offsetY * $this->scale; $xPosition1 = ($this->scale * 36 - $font1->getWidth()) / 2 + $code1 * $this->scale + $this->offsetX * $this->scale; $xPosition2 = ($this->scale * 37 - $font2->getWidth()) / 2 + $code2 * $this->scale + $this->offsetX * $this->scale; $yPosition = $this->thickness * $this->scale + $this->textfont->getHeight() + $this->SIZE_SPACING_FONT + $this->offsetY * $this->scale; $text_color = $this->colorFg->allocate($im); $font0->draw($im, $text_color, $xPosition0, $yPosition0); $font1->draw($im, $text_color, $xPosition1, $yPosition); $font2->draw($im, $text_color, $xPosition2, $yPosition); $font3->draw($im, $text_color, $xPosition3, $yPosition0); } elseif ($this->textfont !== 0) { $code1 = 0; $code2 = 0; $this->drawExtendedBars($im, 9, $code1, $code2); $xPosition0 = $this->offsetX * $this->scale - imagefontwidth($this->textfont); $xPosition3 = $this->offsetX * $this->scale + $this->positionX * $this->scale + 2; $yPosition0 = $this->thickness * $this->scale - imagefontheight($this->textfont) / 2 + $this->offsetY * $this->scale; $xPosition1 = ($this->scale * 36 - imagefontwidth($this->textfont) * 5) / 2 + $code1 * $this->scale + $this->offsetX * $this->scale; $xPosition2 = ($this->scale * 37 - imagefontwidth($this->textfont) * 5) / 2 + $code2 * $this->scale + $this->offsetX * $this->scale; $yPosition = $this->thickness * $this->scale + $this->offsetY * $this->scale; $text_color = $this->colorFg->allocate($im); imagechar($im, $this->textfont, $xPosition0, $yPosition0, $temp_text[1], $text_color); imagestring($im, $this->textfont, $xPosition1, $yPosition, substr($temp_text, 2, 5), $text_color); imagestring($im, $this->textfont, $xPosition2, $yPosition, substr($temp_text, 7, 5), $text_color); imagechar($im, $this->textfont, $xPosition3, $yPosition0, $temp_text[12], $text_color); } } }
/** * Overloaded method for drawing special label * * @param resource $im */ protected function drawText($im) { if ($this->label !== BCGBarcode1D::AUTO_LABEL) { parent::drawText($im); } elseif ($this->label !== '') { $temp_text = $this->text . $this->keys[$this->checksumValue]; if ($this->textfont instanceof BCGFont) { $code1 = 0; $code2 = 0; $this->textfont->setText($temp_text); $this->drawExtendedBars($im, $this->textfont->getHeight(), $code1, $code2); // We need to separate the text, one on the left and one on the right and one starting $text0 = substr($temp_text, 0, 1); $text1 = substr($temp_text, 1, 6); $text2 = substr($temp_text, 7, 6); $font0 = clone $this->textfont; $font1 = clone $this->textfont; $font2 = clone $this->textfont; $font0->setText($text0); $font1->setText($text1); $font2->setText($text2); $xPosition0 = $this->offsetX * $this->scale - $font0->getWidth() - 4; // -4 is just for beauty $yPosition0 = $this->thickness * $this->scale + $font0->getHeight() / 2 + $this->offsetY * $this->scale; $xPosition1 = ($this->scale * 44 - $font1->getWidth()) / 2 + $code1 * $this->scale + $this->offsetX * $this->scale; $xPosition2 = ($this->scale * 44 - $font1->getWidth()) / 2 + $code2 * $this->scale + $this->offsetX * $this->scale; $yPosition = $this->thickness * $this->scale + $this->textfont->getHeight() + self::SIZE_SPACING_FONT + $this->offsetY * $this->scale; $text_color = $this->colorFg->allocate($im); $font0->draw($im, $text_color, $xPosition0, $yPosition0); $font1->draw($im, $text_color, $xPosition1, $yPosition); $font2->draw($im, $text_color, $xPosition2, $yPosition); } elseif ($this->textfont !== 0) { $code1 = 0; $code2 = 0; $this->drawExtendedBars($im, 9, $code1, $code2); $startPosition = 10; $xPosition0 = $this->offsetX * $this->scale - imagefontwidth($this->textfont); $yPosition0 = $this->thickness * $this->scale - imagefontheight($this->textfont) / 2 + $this->offsetY * $this->scale; $xPosition1 = ($this->scale * 44 - imagefontwidth($this->textfont) * 6) / 2 + $code1 * $this->scale + $this->offsetX * $this->scale; $xPosition2 = ($this->scale * 44 - imagefontwidth($this->textfont) * 6) / 2 + $code2 * $this->scale + $this->offsetX * $this->scale; $yPosition = $this->thickness * $this->scale + 1 * $this->scale + $this->offsetY * $this->scale; $text_color = $this->colorFg->allocate($im); imagechar($im, $this->textfont, $xPosition0, $yPosition0, $temp_text[0], $text_color); imagestring($im, $this->textfont, $xPosition1, $yPosition, substr($temp_text, 1, 6), $text_color); imagestring($im, $this->textfont, $xPosition2, $yPosition, substr($temp_text, 7, 6), $text_color); } } }
/** * Overloaded method for drawing special label. * * @param resource $im */ protected function drawText($im) { if ($this->label !== BCGBarcode1D::AUTO_LABEL) { parent::drawText($im); } elseif ($this->label !== '') { $temp_text = $this->text . $this->keys[$this->checksumValue]; if ($this->textfont instanceof BCGFont) { $code1 = 0; $code2 = 0; $this->textfont->setText($temp_text); $this->drawExtendedBars($im, $this->textfont->getHeight(), $code1, $code2); // We need to separate the text, one on the left and one on the right $text1 = substr($temp_text, 0, 4); $text2 = substr($temp_text, 4, 4); $font1 = clone $this->textfont; $font2 = clone $this->textfont; $font1->setText($text1); $font2->setText($text2); // The $this->res offset is to center without thinking of the white space in the guard $xPosition1 = ($this->scale * 30 - $font1->getWidth()) / 2 + $code1 * $this->scale + $this->offsetX * $this->scale; $xPosition2 = ($this->scale * 30 - $font2->getWidth()) / 2 + $code2 * $this->scale + $this->offsetX * $this->scale; $yPosition = $this->thickness * $this->scale + $this->textfont->getHeight() + BCGBarcode1D::SIZE_SPACING_FONT + $this->offsetY * $this->scale; $text_color = $this->colorFg->allocate($im); $font1->draw($im, $text_color, $xPosition1, $yPosition); $font2->draw($im, $text_color, $xPosition2, $yPosition); } elseif ($this->textfont !== 0) { $code1 = 0; $code2 = 0; $this->drawExtendedBars($im, 9, $code1, $code2); $xPosition1 = ($this->scale * 30 - imagefontwidth($this->textfont) * 4) / 2 + $code1 * $this->scale + $this->offsetX * $this->scale; $xPosition2 = ($this->scale * 30 - imagefontwidth($this->textfont) * 4) / 2 + $code2 * $this->scale + $this->offsetX * $this->scale; $yPosition = $this->thickness * $this->scale + 1 * $this->scale + $this->offsetY * $this->scale; $text_color = $this->colorFg->allocate($im); imagestring($im, $this->textfont, $xPosition1, $yPosition, substr($temp_text, 0, 4), $text_color); imagestring($im, $this->textfont, $xPosition2, $yPosition, substr($temp_text, 4, 4), $text_color); } } }