/** * Get a text from the labele * * @param mixed $key Key in the array text * @return Text */ public function getText($key) { if (is_array($this->texts) and array_key_exists($key, $this->texts)) { $value = $this->texts[$key]; if (is_string($this->function)) { $value = call_user_func($this->function, $value); } $text = new awText($value); $text->setFont($this->font); $text->setAngle($this->angle); $text->setColor($this->color); if ($this->background instanceof awColor) { $text->setBackgroundColor($this->background); } else { if ($this->background instanceof awGradient) { $text->setBackgroundGradient($this->background); } } $text->border = $this->border; if ($this->padding !== NULL) { call_user_func_array(array($text, 'setPadding'), $this->padding); } return $text; } else { return NULL; } }
/** * Return the height of a text for a GDDriver * * @param awText $text * @return int $fontHeight */ private function getGDTextHeight(awText $text) { $font = $text->getFont(); if ($text->getAngle() === 90) { $text->setAngle(45); return $this->getGDTextWidth($text); } else { if ($text->getAngle() === 45) { $text->setAngle(90); } } $fontHeight = imagefontheight($font->font); if ($fontHeight === FALSE) { awImage::drawError("Class PHPFontDriver: Unable to get font size."); } return (int) $fontHeight; }
/** * Get the height of a string * * @param awText $text A string */ public function getTextHeight(awText $text) { if ($text->getAngle() === 90) { $text->setAngle(45); return $this->getTextWidth($text); } else { if ($text->getAngle() === 45) { $text->setAngle(90); } } $font = $text->getFont(); $fontHeight = imagefontheight($font->font); if ($fontHeight === FALSE) { trigger_error("Unable to get font size", E_USER_ERROR); } return (int) $fontHeight; }