-----------------------------------------
getFontFilePath
-----------------------------------------

Get Font File Full Path

@param  string $font         font file
@return String               Font Full Path
973526
protected function getFontFilePath($font = null, $custom_key = null) {

		// Get Calling Class Name
		$cls = $custom_key ? $custom_key : strtolower(str_replace(__NAMESPACE__.'\\', '', get_called_class()));

		$font_path = Config::get(self::PACKAGE_NAME . '.font_dir') . DIRECTORY_SEPARATOR;

		// Check if has Sub Directory
		$font_path .= Config::get(self::PACKAGE_NAME . '.'.$cls.'.font_dir') ?  Config::get(self::PACKAGE_NAME . '.'.$cls.'.font_dir') . DIRECTORY_SEPARATOR : '';

		// $font OR Default
		$font_path .= ($font) ? $font : Config::get(self::PACKAGE_NAME . '.'.$cls.'.font');

		return $font_path;
	}
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;
	}
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);
        }
    }
1303098
public function findFonts($path = null)
    {
        foreach (glob($path . DIRECTORY_SEPARATOR . '*') as $path) {
            if (is_dir($path)) {
                $path = $this->findFonts($path);
            } elseif (preg_match('~(.+\..tf)$~i', $path, $m)) {
                $meta = new FontMeta($path);
                if (strlen($meta->getFontName())) {
                    $this->fonts[$meta->getFontName()] = $path;
                }
            }
        }

        return $path;
    }
1264774
function get_font_height($font, $size) {
		if (!$font) {
			$fontFamily = $this->_pdf->getFontFamily();
			$fontStyle = $this->_pdf->getFontStyle();
		}
		else {
			$fontdata = $this->_get_font($font);
			$fontFamily = $fontdata['family'];
			$fontStyle = $fontdata['style'];
			$this->_pdf->SetFont($fontFamily, $fontStyle, $size, $font);
		}
		if (strpos($fontStyle, 'B') !== false) {
			$scale = self::FONT_HEIGHT_SCALE_BOLD;
		}
		else {
			$scale = self::FONT_HEIGHT_SCALE_NORMAL;
		}
		$result = $scale * $size;
		//Helpers::dompdf_debug("trace", "(". basename($font) .", $size): returns $result");
		return $result;
	}
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;
	}
204524
protected function getAssetPath(string $asset): string
    {
        $assetConfig = $this->applicationConfig->getSnapshotConfig()->getAssets();
        $location = $assetConfig[$asset]['location'] ?? 'code';
        $path = $this->applicationConfig->getPath($location);
        return "$path/$asset";
    }
1038081
function getFontDecender( $size = false )
    {
        // note that this will most likely return a negative value
        if ( !$this->numFonts )
        {
            $this->selectFont( './fonts/Helvetica' );
        }
        $h = $this->fonts[$this->currentFont]['FontBBox'][1];
        if ( $size === false )
        {
            $size = $this->fontSize();
        }
        return $size*$h/1000;
    }
1291090
private function _parse_font_face($str)
    {
        $descriptors = $this->_parse_properties($str);

        preg_match_all("/(url|local)\s*\([\"\']?([^\"\'\)]+)[\"\']?\)\s*(format\s*\([\"\']?([^\"\'\)]+)[\"\']?\))?/i", $descriptors->src, $src);

        $sources = array();
        $valid_sources = array();

        foreach ($src[0] as $i => $value) {
            $source = array(
                "local" => strtolower($src[1][$i]) === "local",
                "uri" => $src[2][$i],
                "format" => strtolower($src[4][$i]),
                "path" => Helpers::build_url($this->_protocol, $this->_base_host, $this->_base_path, $src[2][$i]),
            );

            if (!$source["local"] && in_array($source["format"], array("", "truetype"))) {
                $valid_sources[] = $source;
            }

            $sources[] = $source;
        }

        // No valid sources
        if (empty($valid_sources)) {
            return;
        }

        $style = array(
            "family" => $descriptors->get_font_family_raw(),
            "weight" => $descriptors->font_weight,
            "style" => $descriptors->font_style,
        );

        $this->getFontMetrics()->registerFont($style, $valid_sources[0]["path"], $this->_dompdf->getHttpContext());
    }
1247472
private function getAssetUrl($path)
    {
        $url = $this->assetsPackages->getUrl($path);
        if (!$url) {
            return $path;
        }

        /**
         * If `framework.assets.version: some_version` set, then $version = '?some_version'.
         * If `framework.assets: json_manifest_path` is used, then $version = '/'.
         */
        $version = $this->assetsPackages->getVersion($path);
        if (false === strpos($version, '?')) {
            return $url;
        }

        return preg_replace('/\?' . $version . '/', '', $url);
    }
1272157
public function getFont($id)
    {
        $fonts = $this->getFonts();

        if (isset($fonts[$id])) {
            return $fonts[$id];
        } else {
            $id = preg_replace('/[^0-9\.\-_]/', '', $id);

            if (isset($fonts[$id])) {
                return $fonts[$id];
            } else {
                return null;
            }
        }
    }
839945
public function setFont( $key, $font )
	{
		#	Set Fonts
	
		if( $key != 'background_text' && $key != 'front_text' )
			throw new CaptchaException( __METHOD__ . '($key, ) $key must be background_text or front_text.' );
		
		# check font file existence
		$font_file = Config::get( 'images.captcha.font_dir' ) . DIRECTORY_SEPARATOR . $font;

		if( !file_exists( $font_file ) )
			throw new CaptchaException( __METHOD__ . "( , $font) provided font file '$font_file' doesn't exists." );

		$property = '_' . $key;

		$this->{$property}['font'] = $font_file;

		return $this;
		# Method End
	}
1170625
private function createDeleteForm(Font $font)
    {
        return $this->createFormBuilder()
            ->setAction($this->generateUrl('coreextra_font_delete', array('id' => $font->getId())))
            ->setMethod('DELETE')
            ->getForm()
        ;
    }
1139384
public function setFontPath($fontPath)
    {
        if (is_file($fontPath)) {
            $this->fontTruetype = true;
            $this->fontPath = $fontPath;
        }

        return $this;
    }
1086034
public static function getTextWidthPixelsExact($text, PHPExcel_Style_Font $font, $rotation = 0)
    {
        if (!function_exists('imagettfbbox')) {
            throw new PHPExcel_Exception('GD library needs to be enabled');
        }

        // font size should really be supplied in pixels in GD2,
        // but since GD2 seems to assume 72dpi, pixels and points are the same
        $fontFile = self::getTrueTypeFontFileFromFont($font);
        $textBox = imagettfbbox($font->getSize(), $rotation, $fontFile, $text);

        // Get corners positions
        $lowerLeftCornerX  = $textBox[0];
//        $lowerLeftCornerY  = $textBox[1];
        $lowerRightCornerX = $textBox[2];
//        $lowerRightCornerY = $textBox[3];
        $upperRightCornerX = $textBox[4];
//        $upperRightCornerY = $textBox[5];
        $upperLeftCornerX  = $textBox[6];
//        $upperLeftCornerY  = $textBox[7];

        // Consider the rotation when calculating the width
        $textWidth = max($lowerRightCornerX - $upperLeftCornerX, $upperRightCornerX - $lowerLeftCornerX);

        return $textWidth;
    }
519640
public function renderSVG($path)
    {
        $fullPath   = $this->themeFullPath($path);
        $handle     = fopen($fullPath, "r");
        $contents   = fread($handle, filesize($fullPath));
        fclose($handle);


        return $contents;
    }
289966
public function setFont(PHPRtfLite_Font $font)
    {
        $columns = $this->_table->getColumns();
        foreach ($columns as $i => $column) {
            $cell = $this->_table->getCell($this->_rowIndex, $column->getColumnIndex());
            $cell->setFont($font);
        }
    }