当前位置: 首页>>代码示例>>PHP>>正文


PHP Settings::getDefaultFontName方法代码示例

本文整理汇总了PHP中PhpOffice\PhpWord\Settings::getDefaultFontName方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::getDefaultFontName方法的具体用法?PHP Settings::getDefaultFontName怎么用?PHP Settings::getDefaultFontName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhpOffice\PhpWord\Settings的用法示例。


在下文中一共展示了Settings::getDefaultFontName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:samogot,项目名称:rura-convertors,代码行数:36,代码来源:Head.php

示例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
 }
开发者ID:hcvcastro,项目名称:pxp,代码行数:41,代码来源:Styles.php

示例3: registerFontItems

 /**
  * Register fonts and colors
  *
  * @param \PhpOffice\PhpWord\Style\AbstractStyle $style
  */
 private function registerFontItems($style)
 {
     $defaultFont = Settings::getDefaultFontName();
     $defaultColor = Settings::DEFAULT_FONT_COLOR;
     if ($style instanceof Font) {
         $this->registerFontItem($this->fontTable, $style->getName(), $defaultFont);
         $this->registerFontItem($this->colorTable, $style->getColor(), $defaultColor);
         $this->registerFontItem($this->colorTable, $style->getFgColor(), $defaultColor);
     }
 }
开发者ID:hcvcastro,项目名称:pxp,代码行数:15,代码来源:Header.php

示例4: getDefaultFontName

 /**
  * Get default font name
  *
  * @return string
  */
 public function getDefaultFontName()
 {
     return Settings::getDefaultFontName();
 }
开发者ID:matiasvillanueva,项目名称:laravel5-CRUD-LOGIN,代码行数:9,代码来源:PhpWord.php

示例5: writeFontFaces

 /**
  * Write font faces declaration
  */
 protected function writeFontFaces(XMLWriter $xmlWriter)
 {
     $xmlWriter->startElement('office:font-face-decls');
     $fontTable = array();
     $styles = Style::getStyles();
     $numFonts = 0;
     if (count($styles) > 0) {
         foreach ($styles as $style) {
             // Font
             if ($style instanceof Font) {
                 $numFonts++;
                 $name = $style->getName();
                 if (!in_array($name, $fontTable)) {
                     $fontTable[] = $name;
                     // style:font-face
                     $xmlWriter->startElement('style:font-face');
                     $xmlWriter->writeAttribute('style:name', $name);
                     $xmlWriter->writeAttribute('svg:font-family', $name);
                     $xmlWriter->endElement();
                 }
             }
         }
     }
     if (!in_array(Settings::getDefaultFontName(), $fontTable)) {
         $xmlWriter->startElement('style:font-face');
         $xmlWriter->writeAttribute('style:name', Settings::getDefaultFontName());
         $xmlWriter->writeAttribute('svg:font-family', Settings::getDefaultFontName());
         $xmlWriter->endElement();
     }
     $xmlWriter->endElement();
 }
开发者ID:hcvcastro,项目名称:pxp,代码行数:34,代码来源:AbstractPart.php

示例6: 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
     }
 }
开发者ID:FabianoFaria,项目名称:ULA_front,代码行数:72,代码来源:Styles.php

示例7: testSetGetDefaultFontName

 /**
  * Test set/get default font name
  */
 public function testSetGetDefaultFontName()
 {
     $this->assertEquals(Settings::DEFAULT_FONT_NAME, Settings::getDefaultFontName());
     $this->assertTrue(Settings::setDefaultFontName('Times New Roman'));
     $this->assertFalse(Settings::setDefaultFontName(' '));
 }
开发者ID:brunodebarros,项目名称:phpword,代码行数:9,代码来源:SettingsTest.php


注:本文中的PhpOffice\PhpWord\Settings::getDefaultFontName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。