コード例 #1
0
ファイル: tcpdf.php プロジェクト: jackalope/jr_cr_demo
 /**
  * Try to set font
  *
  * Stays with the old font, if the newly specified font is not available.
  *
  * If the font does not support the given style, it falls back to the style
  * used beforehand, and if this is also not support the plain style will be
  * used.
  * 
  * @param string $name 
  * @param int $style 
  * @return void
  */
 public function trySetFont($name, $style)
 {
     // Just du no use new font, if it is unknown
     // @TODO: Add some kind of weak error reporting here?
     if (!isset($this->fonts[$name])) {
         $name = $this->currentFont['name'];
     }
     // Style fallback
     if (!isset($this->fonts[$name][$style])) {
         $style = isset($this->fonts[$name][$this->currentFont['style']]) ? $this->currentFont['style'] : self::FONT_PLAIN;
     }
     // Create and use font on current page
     $this->document->setFont($this->fonts[$name][self::FONT_PLAIN], ($style & self::FONT_BOLD ? 'B' : '') . ($style & self::FONT_OBLIQUE ? 'I' : '') . ($style & self::FONT_UNDERLINE ? 'U' : ''));
     $this->currentFont = array('name' => $name, 'style' => $style, 'size' => $this->currentFont['size']);
 }
コード例 #2
0
ファイル: tcpdf.php プロジェクト: bmdevel/ezc
 /**
  * Try to set font
  *
  * Stays with the old font, if the newly specified font is not available.
  *
  * If the font does not support the given style, it falls back to the style
  * used beforehand, and if this is also not support the plain style will be
  * used.
  *
  * @param string $name
  * @param int $style
  * @return void
  */
 public function trySetFont($name, $style)
 {
     if ($this->document === null) {
         $this->initialize();
     }
     // Just du no use new font, if it is unknown
     if (!isset($this->fonts[$name])) {
         throw new ezcDocumentInvalidFontException($name);
     }
     // Style fallback
     if (!isset($this->fonts[$name][$style])) {
         $style = isset($this->fonts[$name][$this->currentFont['style']]) ? $this->currentFont['style'] : self::FONT_PLAIN;
     }
     // Create and use font on current page
     $this->document->setFont($this->fonts[$name][self::FONT_PLAIN], ($style & self::FONT_BOLD ? 'B' : '') . ($style & self::FONT_OBLIQUE ? 'I' : ''));
     $this->currentFont = array('name' => $name, 'style' => $style, 'size' => $this->currentFont['size']);
 }