/** * Render text depending of font type and available font extensions * * @param string $id * @param string $text * @param string $chars * @param int $type * @param string $path * @param ezcGraphColor $color * @param ezcGraphCoordinate $position * @param float $size * @param float $rotation * @return void */ protected function renderText($id, $text, $chars, $type, $path, ezcGraphColor $color, ezcGraphCoordinate $position, $size, $rotation = null) { $movie = $this->getDocument(); $tb = new SWFTextField(SWFTEXTFIELD_NOEDIT); $tb->setFont(new SWFFont($path)); $tb->setHeight($size); $tb->setColor($color->red, $color->green, $color->blue, 255 - $color->alpha); $tb->addString($text); $tb->addChars($chars); $object = $movie->add($tb); $object->rotate($rotation !== null ? -$rotation->getRotation() : 0); $object->moveTo($position->x + ($rotation === null ? 0 : $this->modifyCoordinate($rotation->get(0, 2))), $position->y - $size * (1 + $this->options->lineSpacing) + ($rotation === null ? 0 : $this->modifyCoordinate($rotation->get(1, 2)))); $object->setName($id); }
/** * Render text depending of font type and available font extensions * * @param string $id * @param string $text * @param string $font * @param ezcGraphColor $color * @param ezcGraphCoordinate $position * @param float $size * @param float $rotation * @return void */ protected function renderText($text, $font, ezcGraphColor $color, ezcGraphCoordinate $position, $size, $rotation = null) { $this->context->selectFontFace($font, CairoFontSlant::NORMAL, CairoFontWeight::NORMAL); $this->context->setFontSize($size); // Store current state of context $this->context->save(); $this->context->moveTo(0, 0); if ($rotation !== null) { // Move to the center $this->context->translate($rotation->getCenter()->x, $rotation->getCenter()->y); // Rotate around text center $this->context->rotate(deg2rad($rotation->getRotation())); // Center the text $this->context->translate($position->x - $rotation->getCenter()->x, $position->y - $rotation->getCenter()->y - $size * 0.15); } else { $this->context->translate($position->x, $position->y - $size * 0.15); } $this->context->newPath(); $this->getStyle($color, true); $this->context->showText($text); $this->context->stroke(); // Restore state of context $this->context->restore(); }
/** * Render text depending of font type and available font extensions * * @param string $id * @param string $text * @param string $font * @param ezcGraphColor $color * @param ezcGraphCoordinate $position * @param float $size * @param float $rotation * @return void */ protected function renderText($text, $font, ezcGraphColor $color, ezcGraphCoordinate $position, $size, $rotation = null) { cairo_select_font_face($this->context, $font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size($this->context, $size); // Store current state of context cairo_save($this->context); cairo_move_to($this->context, 0, 0); if ($rotation !== null) { // Move to the center cairo_translate($this->context, $rotation->getCenter()->x, $rotation->getCenter()->y); // Rotate around text center cairo_rotate($this->context, deg2rad($rotation->getRotation())); // Center the text cairo_translate($this->context, $position->x - $rotation->getCenter()->x, $position->y - $rotation->getCenter()->y - $size * 0.15); } else { cairo_translate($this->context, $position->x, $position->y - $size * 0.15); } cairo_new_path($this->context); $this->getStyle($color, true); cairo_show_text($this->context, $text); cairo_stroke($this->context); // Restore state of context cairo_restore($this->context); }