getFont() публичный Метод

Get font
public getFont ( ) : Font
Результат PhpOffice\PhpPresentation\Style\Font
Пример #1
0
 public function testTypeScatterSuperScript()
 {
     $oSlide = $this->oPresentation->getActiveSlide();
     $oShape = $oSlide->createChartShape();
     $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
     $oScatter = new Scatter();
     $oSeries = new Series('Downloads', $this->seriesData);
     $oSeries->getFont()->setSuperScript(true);
     $oScatter->addSeries($oSeries);
     $oShape->getPlotArea()->setType($oScatter);
     $oXMLDoc = TestHelperDOCX::getDocument($this->oPresentation, 'PowerPoint2007');
     $element = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $this->assertEquals('30000', $oXMLDoc->getElementAttribute($element, 'baseline', 'ppt/charts/' . $oShape->getIndexedFilename()));
 }
Пример #2
0
 public function testHashCode()
 {
     $object = new Series();
     $this->assertEquals(md5($object->getFill()->getHashCode() . $object->getFont()->getHashCode() . var_export($object->getValues(), true) . var_export($object, true) . get_class($object)), $object->getHashCode());
 }
Пример #3
0
function fnSlide_Bar3D(PhpPresentation $objPHPPresentation)
{
    global $oFill;
    global $oShadow;
    // Create templated slide
    echo EOL . date('H:i:s') . ' Create templated slide' . EOL;
    $currentSlide = createTemplatedSlide($objPHPPresentation);
    // Generate sample data for first chart
    echo date('H:i:s') . ' Generate sample data for chart' . EOL;
    $series1Data = array('Jan' => 133, 'Feb' => 99, 'Mar' => 191, 'Apr' => 205, 'May' => 167, 'Jun' => 201, 'Jul' => 240, 'Aug' => 226, 'Sep' => 255, 'Oct' => 264, 'Nov' => 283, 'Dec' => 293);
    $series2Data = array('Jan' => 266, 'Feb' => 198, 'Mar' => 271, 'Apr' => 305, 'May' => 267, 'Jun' => 301, 'Jul' => 340, 'Aug' => 326, 'Sep' => 344, 'Oct' => 364, 'Nov' => 383, 'Dec' => 379);
    // Create a bar chart (that should be inserted in a shape)
    echo date('H:i:s') . ' Create a bar chart (that should be inserted in a chart shape)' . EOL;
    $bar3DChart = new Bar3D();
    $series1 = new Series('2009', $series1Data);
    $series1->setShowSeriesName(true);
    $series1->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4F81BD'));
    $series1->getFont()->getColor()->setRGB('00FF00');
    $series1->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFE06B20'));
    $series2 = new Series('2010', $series2Data);
    $series2->setShowSeriesName(true);
    $series2->getFont()->getColor()->setRGB('FF0000');
    $series2->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFC0504D'));
    $bar3DChart->addSeries($series1);
    $bar3DChart->addSeries($series2);
    // Create a shape (chart)
    echo date('H:i:s') . ' Create a shape (chart)' . EOL;
    $shape = $currentSlide->createChartShape();
    $shape->setName('PHPPresentation Monthly Downloads')->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
    $shape->setShadow($oShadow);
    $shape->setFill($oFill);
    $shape->getBorder()->setLineStyle(Border::LINE_SINGLE);
    $shape->getTitle()->setText('PHPPresentation Monthly Downloads');
    $shape->getTitle()->getFont()->setItalic(true);
    $shape->getTitle()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT);
    $shape->getPlotArea()->getAxisX()->setTitle('Month');
    $shape->getPlotArea()->getAxisY()->setTitle('Downloads');
    $shape->getPlotArea()->setType($bar3DChart);
    $shape->getView3D()->setRightAngleAxes(true);
    $shape->getView3D()->setRotationX(20);
    $shape->getView3D()->setRotationY(20);
    $shape->getLegend()->getBorder()->setLineStyle(Border::LINE_SINGLE);
    $shape->getLegend()->getFont()->setItalic(true);
}
Пример #4
0
 /**
  * @param Chart $chart
  * @param Chart\Series $series
  */
 private function writeSeriesStyle(Chart $chart, Chart\Series $series)
 {
     $chartType = $chart->getPlotArea()->getType();
     // style:style
     $this->xmlContent->startElement('style:style');
     $this->xmlContent->writeAttribute('style:name', 'styleSeries' . $this->numSeries);
     $this->xmlContent->writeAttribute('style:family', 'chart');
     // style:chart-properties
     $this->xmlContent->startElement('style:chart-properties');
     $this->xmlContent->writeAttribute('chart:data-label-number', 'value');
     $this->xmlContent->writeAttribute('chart:label-position', 'center');
     if ($chartType instanceof AbstractTypePie) {
         $this->xmlContent->writeAttribute('chart:pie-offset', $chartType->getExplosion());
     }
     if ($chartType instanceof Line) {
         //@todo : Permit edit the symbol of a line
         $this->xmlContent->writeAttribute('chart:symbol-type', 'automatic');
     }
     // > style:chart-properties
     $this->xmlContent->endElement();
     // style:graphic-properties
     $this->xmlContent->startElement('style:graphic-properties');
     if ($chartType instanceof Line || $chartType instanceof Scatter) {
         //@todo : Permit edit the color and width of a line
         $this->xmlContent->writeAttribute('svg:stroke-width', '0.079cm');
         $this->xmlContent->writeAttribute('svg:stroke-color', '#4a7ebb');
     } else {
         $this->xmlContent->writeAttribute('draw:stroke', 'none');
         if (!$chartType instanceof Area) {
             $this->xmlContent->writeAttribute('draw:fill', $series->getFill()->getFillType());
         }
     }
     $this->xmlContent->writeAttribute('draw:fill-color', '#' . $series->getFill()->getStartColor()->getRGB());
     // > style:graphic-properties
     $this->xmlContent->endElement();
     // style:text-properties
     $this->xmlContent->startElement('style:text-properties');
     $this->xmlContent->writeAttribute('fo:color', '#' . $series->getFont()->getColor()->getRGB());
     $this->xmlContent->writeAttribute('fo:font-family', $series->getFont()->getName());
     $this->xmlContent->writeAttribute('fo:font-size', $series->getFont()->getSize() . 'pt');
     // > style:text-properties
     $this->xmlContent->endElement();
     // > style:style
     $this->xmlContent->endElement();
     foreach ($series->getDataPointFills() as $idx => $oFill) {
         // style:style
         $this->xmlContent->startElement('style:style');
         $this->xmlContent->writeAttribute('style:name', 'styleSeries' . $this->numSeries . '_' . $idx);
         $this->xmlContent->writeAttribute('style:family', 'chart');
         // style:graphic-properties
         $this->xmlContent->startElement('style:graphic-properties');
         $this->xmlContent->writeAttribute('draw:fill', $oFill->getFillType());
         $this->xmlContent->writeAttribute('draw:fill-color', '#' . $oFill->getStartColor()->getRGB());
         // > style:graphic-properties
         $this->xmlContent->endElement();
         // > style:style
         $this->xmlContent->endElement();
     }
 }
Пример #5
0
 /**
  * @param Chart $chart
  * @param Chart\Series $series
  */
 private function writeSeriesStyle(Chart $chart, Chart\Series $series)
 {
     $chartType = $chart->getPlotArea()->getType();
     // style:style
     $this->xmlContent->startElement('style:style');
     $this->xmlContent->writeAttribute('style:name', 'styleSeries' . $this->numSeries);
     $this->xmlContent->writeAttribute('style:family', 'chart');
     // style:chart-properties
     $this->xmlContent->startElement('style:chart-properties');
     $this->xmlContent->writeAttribute('chart:data-label-number', 'value');
     $this->xmlContent->writeAttribute('chart:label-position', 'center');
     if ($chartType instanceof AbstractTypePie) {
         $this->xmlContent->writeAttribute('chart:pie-offset', $chartType->getExplosion());
     }
     if ($chartType instanceof Line || $chartType instanceof Scatter) {
         $oMarker = $series->getMarker();
         /**
          * @link : http://www.datypic.com/sc/odf/a-chart_symbol-type.html
          */
         $this->xmlContent->writeAttributeIf($oMarker->getSymbol() == Chart\Marker::SYMBOL_NONE, 'chart:symbol-type', 'none');
         /**
          * @link : http://www.datypic.com/sc/odf/a-chart_symbol-name.html
          */
         $this->xmlContent->writeAttributeIf($oMarker->getSymbol() != Chart\Marker::SYMBOL_NONE, 'chart:symbol-type', 'named-symbol');
         if ($oMarker->getSymbol() != Chart\Marker::SYMBOL_NONE) {
             switch ($oMarker->getSymbol()) {
                 case Chart\Marker::SYMBOL_DASH:
                     $symbolName = 'horizontal-bar';
                     break;
                 case Chart\Marker::SYMBOL_DOT:
                     $symbolName = 'circle';
                     break;
                 case Chart\Marker::SYMBOL_TRIANGLE:
                     $symbolName = 'arrow-up';
                     break;
                 default:
                     $symbolName = $oMarker->getSymbol();
                     break;
             }
             $this->xmlContent->writeAttribute('chart:symbol-name', $symbolName);
             $symbolSize = number_format(CommonDrawing::pointsToCentimeters($oMarker->getSize()), 2, '.', '');
             $this->xmlContent->writeAttribute('chart:symbol-width', $symbolSize . 'cm');
             $this->xmlContent->writeAttribute('chart:symbol-height', $symbolSize . 'cm');
         }
     }
     // > style:chart-properties
     $this->xmlContent->endElement();
     // style:graphic-properties
     $this->xmlContent->startElement('style:graphic-properties');
     if ($chartType instanceof Line || $chartType instanceof Scatter) {
         $outlineWidth = '';
         $outlineColor = '';
         $oOutline = $series->getOutline();
         if ($oOutline instanceof Outline) {
             $outlineWidth = $oOutline->getWidth();
             if (!empty($outlineWidth)) {
                 $outlineWidth = number_format(CommonDrawing::pointsToCentimeters($outlineWidth), 3, '.', '');
             }
             $outlineColor = $oOutline->getFill()->getStartColor()->getRGB();
         }
         if (empty($outlineWidth)) {
             $outlineWidth = '0.079';
         }
         if (empty($outlineColor)) {
             $outlineColor = '4a7ebb';
         }
         $this->xmlContent->writeAttribute('svg:stroke-width', $outlineWidth . 'cm');
         $this->xmlContent->writeAttribute('svg:stroke-color', '#' . $outlineColor);
     } else {
         $this->xmlContent->writeAttribute('draw:stroke', 'none');
         if (!$chartType instanceof Area) {
             $this->xmlContent->writeAttribute('draw:fill', $series->getFill()->getFillType());
         }
     }
     $this->xmlContent->writeAttribute('draw:fill-color', '#' . $series->getFill()->getStartColor()->getRGB());
     // > style:graphic-properties
     $this->xmlContent->endElement();
     // style:text-properties
     $this->xmlContent->startElement('style:text-properties');
     $this->xmlContent->writeAttribute('fo:color', '#' . $series->getFont()->getColor()->getRGB());
     $this->xmlContent->writeAttribute('fo:font-family', $series->getFont()->getName());
     $this->xmlContent->writeAttribute('fo:font-size', $series->getFont()->getSize() . 'pt');
     // > style:text-properties
     $this->xmlContent->endElement();
     // > style:style
     $this->xmlContent->endElement();
     foreach ($series->getDataPointFills() as $idx => $oFill) {
         // style:style
         $this->xmlContent->startElement('style:style');
         $this->xmlContent->writeAttribute('style:name', 'styleSeries' . $this->numSeries . '_' . $idx);
         $this->xmlContent->writeAttribute('style:family', 'chart');
         // style:graphic-properties
         $this->xmlContent->startElement('style:graphic-properties');
         $this->xmlContent->writeAttribute('draw:fill', $oFill->getFillType());
         $this->xmlContent->writeAttribute('draw:fill-color', '#' . $oFill->getStartColor()->getRGB());
         // > style:graphic-properties
         $this->xmlContent->endElement();
         // > style:style
         $this->xmlContent->endElement();
     }
 }