Skip to content

Commit 050d393

Browse files
authored
Update AbstractElement.php - fgColor and bgColor
In combination with next edit... Sets the fgColor and bgColor according to the colorTable.
1 parent 0ab0b49 commit 050d393

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/PhpWord/Writer/RTF/Element/AbstractElement.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,18 @@ protected function writeFontStyle()
200200
$styleWriter->setColorIndex($colorIndex + 1);
201201
}
202202
}
203+
if ($this->fontStyle->getFgColor() != null) {
204+
$colorIndex = array_search($this->fontStyle->getFgColor(), $parentWriter->getColorTable());
205+
if ($colorIndex !== false) {
206+
$styleWriter->setFgColorIndex($colorIndex + 1);
207+
}
208+
}
209+
if ($this->fontStyle->getBgColor() != null) {
210+
$colorIndex = array_search($this->fontStyle->getBgColor(), $parentWriter->getColorTable());
211+
if ($colorIndex !== false) {
212+
$styleWriter->setBgColorIndex($colorIndex + 1);
213+
}
214+
}
203215
if ($this->fontStyle->getName() != null) {
204216
$fontIndex = array_search($this->fontStyle->getName(), $parentWriter->getFontTable());
205217
if ($fontIndex !== false) {

0 commit comments

Comments
 (0)