diff --git a/docs/changes/1.1.0.md b/docs/changes/1.1.0.md index eb19d3b37..45c2e2671 100644 --- a/docs/changes/1.1.0.md +++ b/docs/changes/1.1.0.md @@ -10,6 +10,7 @@ - PowerPoint2007 Reader - PowerPoint2007 Writer - Added support for PHP 8.2 & 8.3 - [@Progi1984](https://github.com/Progi1984) in [#769](https://github.com/PHPOffice/PHPPresentation/pull/769) +- PowerPoint 2007 Writer : Added support to Font for Axis tick label & chinese font support - [@zhengwhizz](https://github.com/zhengwhizz) in [#774](https://github.com/PHPOffice/PHPPresentation/pull/774) ## Bugfixes diff --git a/src/PhpPresentation/Shape/Chart/Axis.php b/src/PhpPresentation/Shape/Chart/Axis.php index 671b67ba3..116f64d6e 100644 --- a/src/PhpPresentation/Shape/Chart/Axis.php +++ b/src/PhpPresentation/Shape/Chart/Axis.php @@ -70,7 +70,14 @@ class Axis implements ComparableInterface private $font; /** - * @var null|Gridlines + * Tick lable font. + * + * @var Font + */ + protected $tickLabelFont; + + /** + * @var Gridlines|null */ protected $majorGridlines; @@ -144,6 +151,7 @@ public function __construct(string $title = 'Axis Title') $this->title = $title; $this->outline = new Outline(); $this->font = new Font(); + $this->tickLabelFont = new Font(); } /** @@ -172,6 +180,24 @@ public function getFont(): ?Font return $this->font; } + /** + * Set tick label font. + */ + public function setTickLabelFont(?Font $font = null): self + { + $this->tickLabelFont = $font; + + return $this; + } + + /** + * Get tick label font. + */ + public function getTickLabelFont(): ?Font + { + return $this->tickLabelFont; + } + /** * Set font. */ diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index c65081ed7..7bca3887a 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -902,6 +902,10 @@ protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, bool $includ $objWriter->writeAttribute('typeface', $series->getFont()->getName()); // >a:latin $objWriter->endElement(); + // a:ea + $objWriter->startElement('a:ea'); + $objWriter->writeAttribute('typeface', $series->getFont()->getName()); + $objWriter->endElement(); // >a:defRPr $objWriter->endElement(); @@ -1106,6 +1110,10 @@ protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $in $objWriter->startElement('a:latin'); $objWriter->writeAttribute('typeface', $series->getFont()->getName()); $objWriter->endElement(); + // a:ea + $objWriter->startElement('a:ea'); + $objWriter->writeAttribute('typeface', $series->getFont()->getName()); + $objWriter->endElement(); $objWriter->endElement(); @@ -1309,6 +1317,10 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo $objWriter->startElement('a:latin'); $objWriter->writeAttribute('typeface', $series->getFont()->getName()); $objWriter->endElement(); + // a:ea + $objWriter->startElement('a:ea'); + $objWriter->writeAttribute('typeface', $series->getFont()->getName()); + $objWriter->endElement(); // c:dLbls\c:txPr\a:p\a:pPr\a:defRPr\ $objWriter->endElement(); @@ -1450,6 +1462,10 @@ protected function writeTypePie(XMLWriter $objWriter, Pie $subject, bool $includ $objWriter->startElement('a:latin'); $objWriter->writeAttribute('typeface', $series->getFont()->getName()); $objWriter->endElement(); + // a:ea + $objWriter->startElement('a:ea'); + $objWriter->writeAttribute('typeface', $series->getFont()->getName()); + $objWriter->endElement(); $objWriter->endElement(); @@ -1610,6 +1626,10 @@ protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, bool $in $objWriter->startElement('a:latin'); $objWriter->writeAttribute('typeface', $series->getFont()->getName()); $objWriter->endElement(); + // a:ea + $objWriter->startElement('a:ea'); + $objWriter->writeAttribute('typeface', $series->getFont()->getName()); + $objWriter->endElement(); $objWriter->endElement(); @@ -1759,6 +1779,10 @@ protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $incl $objWriter->startElement('a:latin'); $objWriter->writeAttribute('typeface', $series->getFont()->getName()); $objWriter->endElement(); + // a:ea + $objWriter->startElement('a:ea'); + $objWriter->writeAttribute('typeface', $series->getFont()->getName()); + $objWriter->endElement(); $objWriter->endElement(); @@ -1931,6 +1955,10 @@ protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $in $objWriter->startElement('a:latin'); $objWriter->writeAttribute('typeface', $series->getFont()->getName()); $objWriter->endElement(); + // a:ea + $objWriter->startElement('a:ea'); + $objWriter->writeAttribute('typeface', $series->getFont()->getName()); + $objWriter->endElement(); $objWriter->endElement(); @@ -2093,6 +2121,10 @@ protected function writeTypeScatter(XMLWriter $objWriter, Scatter $subject, bool $objWriter->startElement('a:latin'); $objWriter->writeAttribute('typeface', $series->getFont()->getName()); $objWriter->endElement(); + // a:ea + $objWriter->startElement('a:ea'); + $objWriter->writeAttribute('typeface', $series->getFont()->getName()); + $objWriter->endElement(); $objWriter->endElement(); @@ -2366,6 +2398,10 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty $objWriter->startElement('a:latin'); $objWriter->writeAttribute('typeface', $oAxis->getFont()->getName()); $objWriter->endElement(); + // a:ea + $objWriter->startElement('a:ea'); + $objWriter->writeAttribute('typeface', $oAxis->getFont()->getName()); + $objWriter->endElement(); $objWriter->endElement(); @@ -2434,6 +2470,64 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty // ##c:spPr $objWriter->endElement(); + // c:txPr + $objWriter->startElement('c:txPr'); + + // a:bodyPr + $objWriter->writeElement('a:bodyPr', null); + + // a:lstStyle + $objWriter->writeElement('a:lstStyle', null); + + // a:p + $objWriter->startElement('a:p'); + + // a:pPr + $objWriter->startElement('a:pPr'); + + // a:defRPr + $objWriter->startElement('a:defRPr'); + $objWriter->writeAttribute('b', ($oAxis->getTickLabelFont()->isBold() ? 'true' : 'false')); + $objWriter->writeAttribute('i', ($oAxis->getTickLabelFont()->isItalic() ? 'true' : 'false')); + $objWriter->writeAttribute('strike', ($oAxis->getTickLabelFont()->isStrikethrough() ? 'sngStrike' : 'noStrike')); + $objWriter->writeAttribute('sz', ($oAxis->getTickLabelFont()->getSize() * 100)); + $objWriter->writeAttribute('u', $oAxis->getTickLabelFont()->getUnderline()); + $objWriter->writeAttributeIf($oAxis->getTickLabelFont()->isSuperScript(), 'baseline', '300000'); + $objWriter->writeAttributeIf($oAxis->getTickLabelFont()->isSubScript(), 'baseline', '-250000'); + + // Font - a:solidFill + $objWriter->startElement('a:solidFill'); + $this->writeColor($objWriter, $oAxis->getTickLabelFont()->getColor()); + $objWriter->endElement(); + + // Font - a:latin + $objWriter->startElement('a:latin'); + $objWriter->writeAttribute('typeface', $oAxis->getTickLabelFont()->getName()); + $objWriter->endElement(); + + // Font - a:ea + $objWriter->startElement('a:ea'); + $objWriter->writeAttribute('typeface', $oAxis->getTickLabelFont()->getName()); + $objWriter->endElement(); + + ## a:defRPr + $objWriter->endElement(); + + ## a:pPr + $objWriter->endElement(); + + // a:endParaRPr + $objWriter->startElement('a:endParaRPr'); + $objWriter->writeAttribute('lang', 'en-US'); + $objWriter->writeAttribute('dirty', '0'); + $objWriter->endElement(); + + ## a:p + $objWriter->endElement(); + + ## c:txPr + $objWriter->endElement(); + // c:crossAx $objWriter->startElement('c:crossAx'); $objWriter->writeAttribute('val', $crossAxVal);