Создание определенных слов или набора слов, выделенных жирным шрифтом в phppresentation
Как сделать отдельные слова или строки, выделенные жирным шрифтом в абзаце, используя phppresentation.
$textRun = $shape->createTextRun('Your content is centered around promotion of events. While we encourage continuing this practice based on the strong results.');
$textRun->getFont()->setSize(13);
$textRun->getFont()->setColor($colorBlack);
$textRun->getFont()->setName('Montserrat');
В вышеприведенном тексте я хочу сделать "продвижение событий" жирным шрифтом, а другой текст как есть. Как я могу сделать это в библиотеке phppresentation.
Заранее спасибо.
1 ответ
Решение
Вы должны разделить свой текст на несколько частей.
Вы можете использовать этот код:
$oFont = new Font();
$oFont->setSize(13);
$oFont->setColor($colorBlack);
$oFont->setName('Montserrat');
$oFontBold = clone $oFont;
$oFontBold->setBold(true);
$textRun = $shape->createTextRun('Your content is centered around ');
$textRun->setFont($oFont);
$textRun = $shape->createTextRun('promotion of events');
$textRun->setFont($oFontBold);
$textRun = $shape->createTextRun('. While we encourage continuing this practice based on the strong results.');
$textRun->setFont($oFont);