2015-12-16
@param string|null $k [optional]
@param null|string|int|S|Store $s [optional]
@return Font
340321
final protected function _font($k = null, $s = null) {return dfc($this, function($k, $s) {return
		new Font($this->json($k, $s))
	;}, [$k ?: df_caller_f(), df_scope_code($this->scope($s))]);}
1251335
public function setCurrentStyle(string $s)
    {
        $this->currentStyle = $s;
        $style              = $this->wt_report->getStyle($s);
        $this->SetFont($style['font'], $style['style'], $style['size']);
    }
164307
public static Font getFont (String name, int style) {
		return new Font(name, style, getDefaultFont().getSize());
	}
1361770
public void registerFont (String name, java.awt.Font font) {
    if (font == null) throw new NullPointerException();
    fonts.put(name, font);
  }
1005864
public static Typeface getFont(Context context, String fontName) {
        synchronized (cache) {
            if (!cache.containsKey(fontName)) {
                try {
                    Typeface t = Typeface.createFromAsset(context.getAssets(), fontName);
                    cache.put(fontName, t);
                } catch (Exception e) {
                    return null;
                }
            }
            return cache.get(fontName);
        }
    }
521782
function loadFont (fontFace, callback) {
  var defaultNode;
  var testNode;
  var checkFont;

  // See if we've previously loaded it.
  if (_loadedFonts[fontFace.id]) {
    return callback(null);
  }

  // See if we've previously failed to load it.
  if (_failedFonts[fontFace.id]) {
    return callback(_failedFonts[fontFace.id]);
  }

  // System font: assume already loaded.
  if (!fontFace.url) {
    return callback(null);
  }

  // Font load is already in progress:
  if (_pendingFonts[fontFace.id]) {
    _pendingFonts[fontFace.id].callbacks.push(callback);
    return;
  }

  // Create the test <span>'s for measuring.
  defaultNode = createTestNode('Helvetica', fontFace.attributes);
  testNode = createTestNode(fontFace.family, fontFace.attributes);
  document.body.appendChild(testNode);
  document.body.appendChild(defaultNode);

  _pendingFonts[fontFace.id] = {
    startTime: Date.now(),
    defaultNode: defaultNode,
    testNode: testNode,
    callbacks: [callback]
  };

  // Font watcher
  checkFont = function () {
    var currWidth = testNode.getBoundingClientRect().width;
    var defaultWidth = defaultNode.getBoundingClientRect().width;
    var loaded = currWidth !== defaultWidth;

    if (loaded) {
      handleFontLoad(fontFace, null);
    } else {
      // Timeout?
      if (Date.now() - _pendingFonts[fontFace.id].startTime >= kFontLoadTimeout) {
        handleFontLoad(fontFace, true);
      } else {
        requestAnimationFrame(checkFont);
      }
    }
  };

  // Start watching
  checkFont();
}
921216
function getFonts( $languages = null ) {
		if ( ! $languages ) {
			$languages = $this->_getRequiredLanguages();
		}
		$basepath = WP_CONTENT_DIR . '/uploads/assets/fonts/';
		if ( ! is_dir( $basepath ) ) {
			mkdir( $basepath, 0755, true );
		}

		// List fonts
		$fontpacks = [
			'bn' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansBengali-Bold.ttf',
					'NotoSansBengali-Regular.ttf',
					'NotoSerifBengali-Bold.ttf',
					'NotoSerifBengali-Regular.ttf',
				],
			],
			'cans' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansCanadianAboriginal-Regular.ttf',
				],
			],
			'hi' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansDevanagari-Regular.ttf',
					'NotoSansDevanagari-Bold.ttf',
					'NotoSerifDevanagari-Bold.ttf',
					'NotoSerifDevanagari-Regular.ttf',
				],
			],
			'ja' => [
				'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/',
				'files' => [
					'NotoSansCJKjp-Light.otf',
					'NotoSansCJKjp-Regular.otf',
					'NotoSansCJKjp-Bold.otf',
				],
			],
			'kn' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansKannada-Bold.ttf',
					'NotoSansKannada-Regular.ttf',
					'NotoSerifKannada-Bold.ttf',
					'NotoSerifKannada-Regular.ttf',
				],
			],
			'ko' => [
				'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/',
				'files' => [
					'NotoSansCJKkr-Regular.otf',
					'NotoSansCJKkr-Bold.otf',
				],
			],
			'ml' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansMalayalam-Bold.ttf',
					'NotoSansMalayalam-Regular.ttf',
					'NotoSerifMalayalam-Bold.ttf',
					'NotoSerifMalayalam-Regular.ttf',
				],
			],
			'or' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/hinted/',
				'files' => [
					'NotoSansOriya-Bold.ttf',
					'NotoSansOriya-Regular.ttf',
				],
			],
			'te' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansTelugu-Bold.ttf',
					'NotoSansTelugu-Regular.ttf',
					'NotoSerifTelugu-Bold.ttf',
					'NotoSerifTelugu-Regular.ttf',
				],
			],
			'zh_HANS' => [
				'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/',
				'files' => [
					'NotoSansCJKsc-Regular.otf',
					'NotoSansCJKsc-Bold.otf',
				],
			],
			'zh_HANT' => [
				'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/',
				'files' => [
					'NotoSansCJKtc-Light.otf',
					'NotoSansCJKtc-Regular.otf',
					'NotoSansCJKtc-Bold.otf',
				],
			],
		];

		$language_names = $this->getSupportedLanguages();

		foreach ( $fontpacks as $language => $val ) {
			if ( in_array( $language, $languages, true ) ) {
				foreach ( $val['files'] as $font ) {
					if ( ! file_exists( $basepath . $font ) ) {
						if ( ! function_exists( 'download_url' ) ) {
							require_once( ABSPATH . 'wp-admin/includes/file.php' );
						}
						$result = download_url( $val['baseurl'] . $font );
						if ( is_wp_error( $result ) ) {
							$_SESSION['pb_errors'][] = sprintf( __( 'Your %1$s font could not be downloaded from %2$s.', 'pressbooks' ), $language_names[ $language ], '<code>' . $val['baseurl'] . $font . '</code>' ) . '<br /><pre>' . $result->get_error_message() . '</pre>';
							return false;
						} else {
							copy( $result, $basepath . $font );
							unlink( $result );
						}
					}
				}
			}
		}

		return true;
	}
831495
public static function getTrueTypeFontFileFromFont($font) {
		if (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath)) {
			throw new PHPExcel_Exception('Valid directory to TrueType Font files not specified');
		}

		$name		= $font->getName();
		$bold		= $font->getBold();
		$italic		= $font->getItalic();

		// Check if we can map font to true type font file
		switch ($name) {
			case 'Arial':
				$fontFile = (
					$bold ? ($italic ? self::ARIAL_BOLD_ITALIC : self::ARIAL_BOLD)
						  : ($italic ? self::ARIAL_ITALIC : self::ARIAL)
				);
				break;

			case 'Calibri':
				$fontFile = (
					$bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD)
						  : ($italic ? self::CALIBRI_ITALIC : self::CALIBRI)
				);
				break;

			case 'Courier New':
				$fontFile = (
					$bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD)
						  : ($italic ? self::COURIER_NEW_ITALIC : self::COURIER_NEW)
				);
				break;

			case 'Comic Sans MS':
				$fontFile = (
					$bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS
				);
				break;

			case 'Georgia':
				$fontFile = (
					$bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD)
						  : ($italic ? self::GEORGIA_ITALIC : self::GEORGIA)
				);
				break;

			case 'Impact':
				$fontFile = self::IMPACT;
				break;

			case 'Liberation Sans':
				$fontFile = (
					$bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD)
						  : ($italic ? self::LIBERATION_SANS_ITALIC : self::LIBERATION_SANS)
				);
				break;

			case 'Lucida Console':
				$fontFile = self::LUCIDA_CONSOLE;
				break;

			case 'Lucida Sans Unicode':
				$fontFile = self::LUCIDA_SANS_UNICODE;
				break;

			case 'Microsoft Sans Serif':
				$fontFile = self::MICROSOFT_SANS_SERIF;
				break;

			case 'Palatino Linotype':
				$fontFile = (
					$bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD)
						  : ($italic ? self::PALATINO_LINOTYPE_ITALIC : self::PALATINO_LINOTYPE)
				);
				break;

			case 'Symbol':
				$fontFile = self::SYMBOL;
				break;

			case 'Tahoma':
				$fontFile = (
					$bold ? self::TAHOMA_BOLD : self::TAHOMA
				);
				break;

			case 'Times New Roman':
				$fontFile = (
					$bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD)
						  : ($italic ? self::TIMES_NEW_ROMAN_ITALIC : self::TIMES_NEW_ROMAN)
				);
				break;

			case 'Trebuchet MS':
				$fontFile = (
					$bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD)
						  : ($italic ? self::TREBUCHET_MS_ITALIC : self::TREBUCHET_MS)
				);
				break;

			case 'Verdana':
				$fontFile = (
					$bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD)
						  : ($italic ? self::VERDANA_ITALIC : self::VERDANA)
				);
				break;

			default:
				throw new PHPExcel_Exception('Unknown font name "'. $name .'". Cannot map to TrueType font file');
				break;
		}

		$fontFile = self::$trueTypeFontPath . $fontFile;

		// Check if file actually exists
		if (!file_exists($fontFile)) {
			throw New PHPExcel_Exception('TrueType Font file not found');
		}

		return $fontFile;
	}
472244
public function setDefaultFont($default = null)
    {
        $old = $this->defaultFont;
        $this->defaultFont = $default;
        if ($default) {
            $this->value['font-family'] = $default;
        }
        return $old;
    }
988206
public function ascii($file = null)
    {
        $file = $file ? $file : $this->cacheFileName;

        $asciiArt = new CAsciiArt();
        $asciiArt->setOptions($this->asciiOptions);
        return $asciiArt->createFromFile($file);
    }
267520
public function setFontColor($r, $g = null, $b = null) {
		
		if(true === is_string($r) && preg_match('/^#?([A-Fa-f0-9]{6})$/', $r, $color)) {
			list($r, $g, $b) = sscanf($color[1], '%02x%02x%02x');
		}

		if(false === ('-' . intval($r) == '-' . $r)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer or a valid hex color with 6 characters (# not included)', __METHOD__), E_USER_ERROR);
		}

		if(false === ('-' . intval($g) == '-' . $g)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($g)), E_USER_ERROR);
		}

		if(false === ('-' . intval($b) == '-' . $b)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($b)), E_USER_ERROR);
		}

		$this -> color = ['r' => $r, 'g' => $g, 'b' => $b];
	}
519728
function toFontString(font) {
	if (!font || helpers.isNullOrUndef(font.size) || helpers.isNullOrUndef(font.family)) {
		return null;
	}

	return (font.style ? font.style + ' ' : '')
		+ (font.weight ? font.weight + ' ' : '')
		+ font.size + 'px '
		+ font.family;
}
751809
public function cdf($k)
    {
        $accumulator = 0.0;

        for ($i=0; $i<=$k; $i++) {
            $accumulator += $this->pdf($i);
        }
        return $accumulator;
    }
404193
public function build(): SetFontFamiliesRequest
	{
		$instance = new SetFontFamiliesRequest();
		if ($this->fontFamilies === null) {
			throw new BuilderException('Property [fontFamilies] is required.');
		}
		$instance->fontFamilies = $this->fontFamilies;
		return $instance;
	}
1178652
protected function _load_font($font, $encoding = null, $options = "")
    {
        // Fix for PDFLibs case-sensitive font names
        $baseFont = basename($font);
        $isNativeFont = false;
        if (isset(self::$nativeFontsTpPDFLib[$baseFont])) {
            $font = self::$nativeFontsTpPDFLib[$baseFont];
            $isNativeFont = true;
        }

        // Check if the font is a native PDF font
        // Embed non-native fonts
        $test = strtolower($baseFont);
        if (in_array($test, DOMPDF::$nativeFonts)) {
            $font = basename($font);
        } else {
            // Embed non-native fonts
            $options .= " embedding=true";
        }

        if (is_null($encoding)) {
            // Unicode encoding is only available for the commerical
            // version of PDFlib and not PDFlib-Lite
            if (strlen($this->_dompdf->getOptions()->getPdflibLicense()) > 0) {
                $encoding = "unicode";
            } else {
                $encoding = "auto";
            }
        }

        $key = "$font:$encoding:$options";
        if (isset($this->_fonts[$key])) {
            return $this->_fonts[$key];
        }

        // Native fonts are build in, just load it
        if ($isNativeFont) {
            $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options);

            return $this->_fonts[$key];
        }

        $fontOutline = $this->getPDFLibParameter("FontOutline", 1);
        if ($fontOutline === "" || $fontOutline <= 0) {
            $families = $this->_dompdf->getFontMetrics()->getFontFamilies();
            foreach ($families as $files) {
                foreach ($files as $file) {
                    $face = basename($file);
                    $afm = null;

                    if (isset($this->_fontsFiles[$face])) {
                        continue;
                    }

                    // Prefer ttfs to afms
                    if (file_exists("$file.ttf")) {
                        $outline = "$file.ttf";
                    } elseif (file_exists("$file.TTF")) {
                        $outline = "$file.TTF";
                    } elseif (file_exists("$file.pfb")) {
                        $outline = "$file.pfb";
                        if (file_exists("$file.afm")) {
                            $afm = "$file.afm";
                        }
                    } elseif (file_exists("$file.PFB")) {
                        $outline = "$file.PFB";
                        if (file_exists("$file.AFM")) {
                            $afm = "$file.AFM";
                        }
                    } else {
                        continue;
                    }

                    $this->_fontsFiles[$face] = true;

                    if ($this->getPDFLibMajorVersion() >= 9) {
                        $this->setPDFLibParameter("FontOutline", '{' . "$face=$outline" . '}');
                    } else {
                        $this->setPDFLibParameter("FontOutline", "\{$face\}=\{$outline\}");
                    }

                    if (is_null($afm)) {
                        continue;
                    }
                    if ($this->getPDFLibMajorVersion() >= 9) {
                        $this->setPDFLibParameter("FontAFM", '{' . "$face=$afm" . '}');
                    } else {
                        $this->setPDFLibParameter("FontAFM", "\{$face\}=\{$afm\}");
                    }
                }
            }
        }

        $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options);

        return $this->_fonts[$key];
    }
1127987
final protected function v($d = null, $k = null) {
		$k = $k ?: df_caller_f();
		return $this->cfg(df_const($this, $k, $k), $d);
	}
1319742
private static FontStyle intToFontStyle(int style) {
        switch (style) {
        case java.awt.Font.PLAIN:
            return FontStyle.PLAIN;
        case java.awt.Font.BOLD:
            return FontStyle.BOLD;
        case java.awt.Font.ITALIC:
            return FontStyle.ITALIC;
        case java.awt.Font.BOLD + java.awt.Font.ITALIC:
            return FontStyle.BOLD_ITALIC;
        default:
            return FontStyle.PLAIN;
        }
    }