本文整理汇总了PHP中PhpOffice\PhpWord\Settings::getDefaultFontSize方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::getDefaultFontSize方法的具体用法?PHP Settings::getDefaultFontSize怎么用?PHP Settings::getDefaultFontSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpOffice\PhpWord\Settings
的用法示例。
在下文中一共展示了Settings::getDefaultFontSize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeStyles
/**
* Get styles
*
* @return string
*/
private function writeStyles()
{
$css = '<style>' . PHP_EOL;
// Default styles
$defaultStyles = array('*' => array('font-family' => Settings::getDefaultFontName(), 'font-size' => Settings::getDefaultFontSize() . 'pt'), 'a.NoteRef' => array('text-decoration' => 'none'), 'hr' => array('height' => '1px', 'padding' => '0', 'margin' => '1em 0', 'border' => '0', 'border-top' => '1px solid #CCC'));
foreach ($defaultStyles as $selector => $style) {
$styleWriter = new GenericStyleWriter($style);
$css .= $selector . ' {' . $styleWriter->write() . '}' . PHP_EOL;
}
// Custom styles
$customStyles = Style::getStyles();
if (is_array($customStyles)) {
foreach ($customStyles as $name => $style) {
if ($style instanceof Font) {
$styleWriter = new FontStyleWriter($style);
if ($style->getStyleType() == 'title') {
$name = str_replace('Heading_', 'h', $name);
} else {
$name = '.' . $name;
}
$css .= "{$name} {" . $styleWriter->write() . '}' . PHP_EOL;
} elseif ($style instanceof Paragraph) {
$styleWriter = new ParagraphStyleWriter($style);
$name = '.' . $name;
$css .= "{$name} {" . $styleWriter->write() . '}' . PHP_EOL;
}
}
}
$css .= '</style>' . PHP_EOL;
return $css;
}
示例2: writeDefault
/**
* Write default styles
*/
private function writeDefault(XMLWriter $xmlWriter)
{
$xmlWriter->startElement('style:default-style');
$xmlWriter->writeAttribute('style:family', 'paragraph');
// Paragraph
$xmlWriter->startElement('style:paragraph-properties');
$xmlWriter->writeAttribute('fo:hyphenation-ladder-count', 'no-limit');
$xmlWriter->writeAttribute('style:text-autospace', 'ideograph-alpha');
$xmlWriter->writeAttribute('style:punctuation-wrap', 'hanging');
$xmlWriter->writeAttribute('style:line-break', 'strict');
$xmlWriter->writeAttribute('style:tab-stop-distance', '1.249cm');
$xmlWriter->writeAttribute('style:writing-mode', 'page');
$xmlWriter->endElement();
// style:paragraph-properties
// Font
$xmlWriter->startElement('style:text-properties');
$xmlWriter->writeAttribute('style:use-window-font-color', 'true');
$xmlWriter->writeAttribute('style:font-name', Settings::getDefaultFontName());
$xmlWriter->writeAttribute('fo:font-size', Settings::getDefaultFontSize() . 'pt');
$xmlWriter->writeAttribute('fo:language', 'fr');
$xmlWriter->writeAttribute('fo:country', 'FR');
$xmlWriter->writeAttribute('style:letter-kerning', 'true');
$xmlWriter->writeAttribute('style:font-name-asian', Settings::getDefaultFontName() . '2');
$xmlWriter->writeAttribute('style:font-size-asian', Settings::getDefaultFontSize() . 'pt');
$xmlWriter->writeAttribute('style:language-asian', 'zh');
$xmlWriter->writeAttribute('style:country-asian', 'CN');
$xmlWriter->writeAttribute('style:font-name-complex', Settings::getDefaultFontName() . '2');
$xmlWriter->writeAttribute('style:font-size-complex', Settings::getDefaultFontSize() . 'pt');
$xmlWriter->writeAttribute('style:language-complex', 'hi');
$xmlWriter->writeAttribute('style:country-complex', 'IN');
$xmlWriter->writeAttribute('fo:hyphenate', 'false');
$xmlWriter->writeAttribute('fo:hyphenation-remain-char-count', '2');
$xmlWriter->writeAttribute('fo:hyphenation-push-char-count', '2');
$xmlWriter->endElement();
// style:text-properties
$xmlWriter->endElement();
// style:default-style
}
示例3: getDefaultFontSize
/**
* Get default font size
*
* @return integer
*/
public function getDefaultFontSize()
{
return Settings::getDefaultFontSize();
}
示例4: writeFormatting
/**
* Write document formatting properties
*
* @return string
*/
private function writeFormatting()
{
$content = '';
$content .= '\\deftab720';
// Set the default tab size (720 twips)
$content .= '\\viewkind1';
// Set the view mode of the document
$content .= '\\uc1';
// Set the numberof bytes that follows a unicode character
$content .= '\\pard';
// Resets to default paragraph properties.
$content .= '\\nowidctlpar';
// No widow/orphan control
$content .= '\\lang1036';
// Applies a language to a text run (1036 : French (France))
$content .= '\\kerning1';
// Point size (in half-points) above which to kern character pairs
$content .= '\\fs' . Settings::getDefaultFontSize() * 2;
// Set the font size in half-points
$content .= PHP_EOL;
return $content;
}
示例5: writeDefaultStyles
/**
* Write default font and other default styles
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\AbstractStyle[] $styles
*/
private function writeDefaultStyles(XMLWriter $xmlWriter, $styles)
{
$fontName = PhpWordSettings::getDefaultFontName();
$fontSize = PhpWordSettings::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
}
}
示例6: testSetGetDefaultFontSize
/**
* Test set/get default font size
*/
public function testSetGetDefaultFontSize()
{
$this->assertEquals(Settings::DEFAULT_FONT_SIZE, Settings::getDefaultFontSize());
$this->assertTrue(Settings::setDefaultFontSize(12));
$this->assertFalse(Settings::setDefaultFontSize(null));
}