Skip to content

Commit 7a31dbb

Browse files
devX2712Progi1984
authored andcommitted
ADD Get more font attributs
Need some mor informations to be same as original when reading, like charset, etc
1 parent a49854f commit 7a31dbb

File tree

3 files changed

+115
-5
lines changed

3 files changed

+115
-5
lines changed

src/PhpPresentation/Reader/PowerPoint2007.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,10 +1358,17 @@ protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oSh
13581358
}
13591359
// Font definition
13601360
$oElementFont = $document->getElement('a:latin', $oElementrPr);
1361-
if (is_object($oElementFont)) {
1362-
if ($oElementFont->hasAttribute('typeface')) {
1363-
$oText->getFont()->setName($oElementFont->getAttribute('typeface'));
1364-
}
1361+
if (is_object($oElementFont) && $oElementFont->hasAttribute('typeface')) {
1362+
$oText->getFont()->setName($oElementFont->getAttribute('typeface'));
1363+
}
1364+
if (($oElementFont instanceof \DOMElement) && $oElementFont->hasAttribute('panose')) {
1365+
$oText->getFont()->setPanose($oElementFont->getAttribute('panose'));
1366+
}
1367+
if (($oElementFont instanceof \DOMElement) && $oElementFont->hasAttribute('pitchFamily')) {
1368+
$oText->getFont()->setPitchFamily($oElementFont->getAttribute('pitchFamily'));
1369+
}
1370+
if (($oElementFont instanceof \DOMElement) && $oElementFont->hasAttribute('charset')) {
1371+
$oText->getFont()->setCharset($oElementFont->getAttribute('charset'));
13651372
}
13661373
// Load shape effects
13671374
$oEffect = $document->getElement('a:effectLst', $oElementrPr);

src/PhpPresentation/Style/Font.php

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,26 @@ class Font implements ComparableInterface
7272
private $name = 'Calibri';
7373

7474
/**
75-
* Font Size.
75+
* panose
76+
*
77+
* @var string
78+
*/
79+
private $panose;
80+
/**
81+
* pitchFamily
82+
*
83+
* @var string
84+
*/
85+
private $pitchFamily;
86+
/**
87+
* charset
88+
*
89+
* @var string
90+
*/
91+
private $charset;
92+
93+
/**
94+
* Font Size
7695
*
7796
* @var int
7897
*/
@@ -180,6 +199,81 @@ public function setName(string $pValue = 'Calibri'): self
180199
$pValue = 'Calibri';
181200
}
182201
$this->name = $pValue;
202+
return $this;
203+
}
204+
205+
/**
206+
* Get panose
207+
*
208+
* @return string
209+
*/
210+
public function getPanose()
211+
{
212+
return $this->panose;
213+
}
214+
215+
/**
216+
* Set panose
217+
*
218+
* @param string $pValue
219+
* @return \PhpOffice\PhpPresentation\Style\Font
220+
*/
221+
public function setPanose($pValue)
222+
{
223+
if ($pValue == '') {
224+
$pValue = '';
225+
}
226+
$this->panose = $pValue;
227+
228+
return $this;
229+
}
230+
/**
231+
* Get pitchFamily
232+
*
233+
* @return string
234+
*/
235+
public function getPitchFamily()
236+
{
237+
return $this->pitchFamily;
238+
}
239+
240+
/**
241+
* Set pitchFamily
242+
*
243+
* @param string $pValue
244+
* @return \PhpOffice\PhpPresentation\Style\Font
245+
*/
246+
public function setPitchFamily($pValue)
247+
{
248+
if ($pValue == '') {
249+
$pValue = '';
250+
}
251+
$this->pitchFamily = $pValue;
252+
253+
return $this;
254+
}
255+
/**
256+
* Get charset
257+
*
258+
* @return string
259+
*/
260+
public function getCharset()
261+
{
262+
return $this->charset;
263+
}
264+
265+
/**
266+
* Set charset
267+
*
268+
* @param string $pValue
269+
* @return \PhpOffice\PhpPresentation\Style\Font
270+
*/
271+
public function setCharset($pValue)
272+
{
273+
if ($pValue == '') {
274+
$pValue = '';
275+
}
276+
$this->charset = $pValue;
183277

184278
return $this;
185279
}

src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,12 +678,21 @@ protected function writeRunStyles(XMLWriter $objWriter, RichText\Run $element):
678678
$this->writeColor($objWriter, $element->getFont()->getColor());
679679
$objWriter->endElement();
680680

681+
// Write Effects
682+
$this->writeEffect($objWriter, $element->getEffectCollection(), 'srgbClr');
683+
681684
// Font
682685
// - a:latin
683686
// - a:ea
684687
// - a:cs
685688
$objWriter->startElement('a:' . $element->getFont()->getFormat());
686689
$objWriter->writeAttribute('typeface', $element->getFont()->getName());
690+
if ($element->getFont()->getPanose()!="")
691+
$objWriter->writeAttribute('panose', $element->getFont()->getPanose());
692+
if ($element->getFont()->getPitchFamily()!="")
693+
$objWriter->writeAttribute('pitchFamily', $element->getFont()->getPitchFamily());
694+
if ($element->getFont()->getCharset()!="")
695+
$objWriter->writeAttribute('charset', $element->getFont()->getCharset());
687696
$objWriter->endElement();
688697

689698
// a:hlinkClick

0 commit comments

Comments
 (0)