code: public function writeRichTextForCharts(XMLWriter $objWriter, $pRichText = null, $prefix = null)
      {
          if (!$pRichText instanceof RichText) {
              $textRun = $pRichText;
              $pRichText = new RichText();
              $pRichText->createTextRun($textRun);
          }
  
          if ($prefix !== null) {
              $prefix .= ':';
          }
  
          // Loop through rich text elements
          $elements = $pRichText->getRichTextElements();
          foreach ($elements as $element) {
              // r
              $objWriter->startElement($prefix . 'r');
  
              // rPr
              $objWriter->startElement($prefix . 'rPr');
  
              // Bold
              $objWriter->writeAttribute('b', ($element->getFont()->getBold() ? 1 : 0));
              // Italic
              $objWriter->writeAttribute('i', ($element->getFont()->getItalic() ? 1 : 0));
              // Underline
              $underlineType = $element->getFont()->getUnderline();
              switch ($underlineType) {
                  case 'single':
                      $underlineType = 'sng';
  
                      break;
                  case 'double':
                      $underlineType = 'dbl';
  
                      break;
              }
              $objWriter->writeAttribute('u', $underlineType);
              // Strikethrough
              $objWriter->writeAttribute('strike', ($element->getFont()->getStrikethrough() ? 'sngStrike' : 'noStrike'));
  
              // rFont
              $objWriter->startElement($prefix . 'latin');
              $objWriter->writeAttribute('typeface', $element->getFont()->getName());
              $objWriter->endElement();
  
              $objWriter->endElement();
  
              // t
              $objWriter->startElement($prefix . 't');
              $objWriter->writeRawData(StringHelper::controlCharacterPHP2OOXML($element->getText()));
              $objWriter->endElement();
  
              $objWriter->endElement();
          }
      }
docs: Write Rich Text.
  
  @param XMLWriter $objWriter XML Writer
  @param RichText|string $pRichText text string or Rich text
  @param string $prefix Optional Namespace prefix