/** * Set an option value * * @param string $propertyName * @param mixed $propertyValue * @throws ezcBasePropertyNotFoundException * If a property is not defined in this class * @return void */ public function __set($propertyName, $propertyValue) { switch ($propertyName) { case 'minFontSize': if (!is_numeric($propertyValue) || $propertyValue < 1) { throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 1'); } // Ensure min font size is smaller or equal max font size. if ($propertyValue > $this->properties['maxFontSize']) { throw new ezcBaseValueException($propertyName, $propertyValue, 'float <= ' . $this->properties['maxFontSize']); } $this->properties[$propertyName] = (double) $propertyValue; break; case 'maxFontSize': if (!is_numeric($propertyValue) || $propertyValue < 1) { throw new ezcBaseValueException($propertyName, $propertyValue, 'float > 1'); } // Ensure max font size is greater or equal min font size. if ($propertyValue < $this->properties['minFontSize']) { throw new ezcBaseValueException($propertyName, $propertyValue, 'float >= ' . $this->properties['minFontSize']); } $this->properties[$propertyName] = (double) $propertyValue; break; case 'minimalUsedFont': $propertyValue = (double) $propertyValue; if ($propertyValue < $this->minimalUsedFont) { $this->properties['minimalUsedFont'] = $propertyValue; } break; case 'color': case 'background': case 'border': case 'textShadowColor': $this->properties[$propertyName] = ezcGraphColor::create($propertyValue); break; case 'borderWidth': case 'padding': case 'textShadowOffset': if (!is_numeric($propertyValue) || $propertyValue < 0) { throw new ezcBaseValueException($propertyName, $propertyValue, 'int >= 0'); } $this->properties[$propertyName] = (int) $propertyValue; break; case 'minimizeBorder': case 'textShadow': if (!is_bool($propertyValue)) { throw new ezcBaseValueException($propertyName, $propertyValue, 'bool'); } $this->properties[$propertyName] = (bool) $propertyValue; break; case 'name': if (is_string($propertyValue)) { $this->properties['name'] = $propertyValue; } else { throw new ezcBaseValueException($propertyName, $propertyValue, 'string'); } break; case 'path': if (is_file($propertyValue) && is_readable($propertyValue)) { $this->properties['path'] = $propertyValue; $parts = pathinfo($this->properties['path']); switch (strtolower($parts['extension'])) { case 'fdb': $this->properties['type'] = ezcGraph::PALM_FONT; break; case 'pfb': $this->properties['type'] = ezcGraph::PS_FONT; break; case 'ttf': $this->properties['type'] = ezcGraph::TTF_FONT; break; case 'svg': $this->properties['type'] = ezcGraph::SVG_FONT; $this->properties['name'] = ezcGraphSvgFont::getFontName($propertyValue); break; default: throw new ezcGraphUnknownFontTypeException($propertyValue, $parts['extension']); } $this->pathChecked = true; } else { throw new ezcBaseFileNotFoundException($propertyValue, 'font'); } break; case 'type': if (is_int($propertyValue)) { $this->properties['type'] = $propertyValue; } else { throw new ezcBaseValueException($propertyName, $propertyValue, 'int'); } break; default: throw new ezcBasePropertyNotFoundException($propertyName); break; } }
/** * Finally save image * * @param string $file Destination filename * @return void */ public function render($file) { $this->createDocument(); $this->drawAllTexts(); // Embed used glyphs $this->font->addFontToDocument($this->dom); $this->dom->save($file); }