本文整理汇总了PHP中PhpOffice\PhpWord\PhpWord::getDefaultFontSize方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpWord::getDefaultFontSize方法的具体用法?PHP PhpWord::getDefaultFontSize怎么用?PHP PhpWord::getDefaultFontSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpOffice\PhpWord\PhpWord
的用法示例。
在下文中一共展示了PhpWord::getDefaultFontSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetGetDefaultFontSize
/**
* Test set/get default font size
*/
public function testSetGetDefaultFontSize()
{
$phpWord = new PhpWord();
$fontSize = 16;
$this->assertEquals(PhpWord::DEFAULT_FONT_SIZE, $phpWord->getDefaultFontSize());
$phpWord->setDefaultFontSize($fontSize);
$this->assertEquals($fontSize, $phpWord->getDefaultFontSize());
}
示例2: writeDefaultStyles
/**
* Write default font and other default styles
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param array $styles
*/
private function writeDefaultStyles(XMLWriter $xmlWriter, PhpWord $phpWord, $styles)
{
$fontName = $phpWord->getDefaultFontName();
$fontSize = $phpWord->getDefaultFontSize();
// Default font
$xmlWriter->startElement('w:docDefaults');
$xmlWriter->startElement('w:rPrDefault');
$xmlWriter->startElement('w:rPr');
$xmlWriter->startElement('w:rFonts');
$xmlWriter->writeAttribute('w:ascii', $fontName);
$xmlWriter->writeAttribute('w:hAnsi', $fontName);
$xmlWriter->writeAttribute('w:eastAsia', $fontName);
$xmlWriter->writeAttribute('w:cs', $fontName);
$xmlWriter->endElement();
// w:rFonts
$xmlWriter->startElement('w:sz');
$xmlWriter->writeAttribute('w:val', $fontSize * 2);
$xmlWriter->endElement();
// w:sz
$xmlWriter->startElement('w:szCs');
$xmlWriter->writeAttribute('w:val', $fontSize * 2);
$xmlWriter->endElement();
// w:szCs
$xmlWriter->endElement();
// w:rPr
$xmlWriter->endElement();
// w:rPrDefault
$xmlWriter->endElement();
// w:docDefaults
// Normal style
$xmlWriter->startElement('w:style');
$xmlWriter->writeAttribute('w:type', 'paragraph');
$xmlWriter->writeAttribute('w:default', '1');
$xmlWriter->writeAttribute('w:styleId', 'Normal');
$xmlWriter->startElement('w:name');
$xmlWriter->writeAttribute('w:val', 'Normal');
$xmlWriter->endElement();
// w:name
if (array_key_exists('Normal', $styles)) {
$styleWriter = new ParagraphStyleWriter($xmlWriter, $styles['Normal']);
$styleWriter->write();
}
$xmlWriter->endElement();
// w:style
// FootnoteReference style
if (!array_key_exists('FootnoteReference', $styles)) {
$xmlWriter->startElement('w:style');
$xmlWriter->writeAttribute('w:type', 'character');
$xmlWriter->writeAttribute('w:styleId', 'FootnoteReference');
$xmlWriter->startElement('w:name');
$xmlWriter->writeAttribute('w:val', 'Footnote Reference');
$xmlWriter->endElement();
// w:name
$xmlWriter->writeElement('w:semiHidden');
$xmlWriter->writeElement('w:unhideWhenUsed');
$xmlWriter->startElement('w:rPr');
$xmlWriter->startElement('w:vertAlign');
$xmlWriter->writeAttribute('w:val', 'superscript');
$xmlWriter->endElement();
// w:vertAlign
$xmlWriter->endElement();
// w:rPr
$xmlWriter->endElement();
// w:style
}
}