Set the font by giving a file path as font
@param string $font
@return sFire\Captcha\Captcha
766780
public function setFont($font) {

		if(false === is_string($font)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($font)), E_USER_ERROR);
		}

		$file = new File($font);

		if(false === $file -> exists()) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be an existing font', __METHOD__), E_USER_ERROR);
		}

		$this -> font = $file;

		return $this;
	}
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);
        }
    }
745865
public function setFont(SVGFont $font)
    {
        $this->font = $font;
        $this->setStyle('font-family', $font->getFontName());
        return $this;
    }
731187
private function getOrCreateFont($fontName) {
    /** @var \Drupal\social_font\Entity\Font $font_entities */
    foreach (Font::loadMultiple() as $font_entities) {
      if ($fontName == $font_entities->get('name')->value) {
        return $font_entities->id();
      }
    }

    // Ok, so it doesn't exist.
    /* @var Font $font */
    $font = Font::create([
      'name' => $fontName,
      'user_id' => 1,
      'created' => \Drupal::time()->getRequestTime(),
      'field_fallback' => '0',
    ]);
    $font->save();
    // Return the id.
    return $font->id();

  }
763478
public static function registerFonts($fonts = array())
    {
        if (empty($fonts))
            return;

        foreach ($fonts as $font) {
            Icon::registerIconFontSet($font);
        }
    }
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;
	}
831102
def set_font_path(self, path, onerror = None):
        """"""
        request.SetFontPath(display = self.display,
                            onerror = onerror,
                            path = path)
99348
protected Font initializeDefaultFont() {
        /*
         * Set the default font to Lucida Grande if available, else use Lucida
         * Sans Unicode. Grande is a later font and a bit nicer looking, but it
         * is a derivation of Sans Unicode, so they're compatible.
         */
        if (defaultFont == null) {
    
            if (PlatformUtils.isMac()) {
                defaultFont = new Font("Lucida Grande", Font.PLAIN, 13);
            }
    
            if (defaultFont == null) {
                defaultFont = new Font("Dialog", Font.PLAIN, 13);
            }
    
            if (defaultFont == null) {
                defaultFont = new Font("SansSerif", Font.PLAIN, 13);
            }
        }

        return defaultFont;
    }
602255
public function build(): SetFontSizesRequest
	{
		$instance = new SetFontSizesRequest();
		if ($this->fontSizes === null) {
			throw new BuilderException('Property [fontSizes] is required.');
		}
		$instance->fontSizes = $this->fontSizes;
		return $instance;
	}
183902
public function cloneFontFrom(&$pdf)
    {
        $this->n                = &$pdf->getN();
        $this->fonts            = &$pdf->getFonts();
        $this->FontFiles        = &$pdf->getFontFiles();
        $this->diffs            = &$pdf->getDiffs();
        $this->fontlist         = &$pdf->getFontList();
        $this->numfonts         = &$pdf->getNumFonts();
        $this->fontkeys         = &$pdf->getFontKeys();
        $this->font_obj_ids     = &$pdf->getFontObjIds();
        $this->annotation_fonts = &$pdf->getAnnotFonts();
    }
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];
    }
614648
function getFont($fontId) {
    $this->parse();

    if (!isset($this->collectionOffsets[$fontId])) {
      throw new OutOfBoundsException();
    }

    if (isset($this->collection[$fontId])) {
      return $this->collection[$fontId];
    }

    $font    = new File();
    $font->f = $this->f;
    $font->setTableOffset($this->collectionOffsets[$fontId]);

    return $this->collection[$fontId] = $font;
  }
388587
public static function registerIconFontSet($fontName, $forceCopyAssets = false)
    {
        if (!in_array($fontName, static::getAvailableIconFontSets())) {
            return false;
        }

        $fontPath = \Yii::getPathOfAlias('foundation.fonts.foundation_icons_' . $fontName);
        $fontUrl  = \Yii::app()->assetManager->publish($fontPath, true, -1, $forceCopyAssets);

        \Yii::app()->clientScript->registerCssFile($fontUrl . "/stylesheets/{$fontName}_foundicons.css");

        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7.0')) {
            \Yii::app()->clientScript->registerCssFile($fontUrl . "/stylesheets/{$fontName}_foundicons_ie7.css");
        }
    }
1076060
def _getFont(self, font):
        
        if os.path.isfile(font):
            font_files = [font]
        else:
            font_files = fc.query(family=font)
            if not font_files:
                raise ValueError('No such font')
        return font_files
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;
    }
1314732
static public function getIconsFromFont($fontPath)
	{
		if (!$fontPath || !file_exists(TL_ROOT . '/' . $fontPath)) {
			return array();
		}

		// calculate the cache key
		$cacheKey = md5_file(TL_ROOT . '/' . $fontPath);
		if (file_exists($infoFilePath = TL_ROOT . '/' . substr($fontPath, 0, -4) . '.html')) {
			$cacheKey = md5($cacheKey . md5_file($infoFilePath));
		}
		if (file_exists($infoFilePath = TL_ROOT . '/' . substr($fontPath, 0, -4) . '.css')) {
			$cacheKey = md5($cacheKey . md5_file($infoFilePath));
		}
		$cacheDirPaths = static::getCacheDirPaths();
		$cacheFilePath = $cacheDirPaths['path'] . '/' . $cacheKey . '.php';
		$cacheFileFullPath = $cacheDirPaths['fullPath'] . '/' . $cacheKey . '.php';
		if (file_exists($cacheFileFullPath)) {
			return include $cacheFileFullPath;
		}

		$font = new \SimpleXMLElement(TL_ROOT . '/' . $fontPath, null, true);
		if(
			!isset($font->defs[0]->font[0]->glyph) ||
			!count($font->defs[0]->font[0]->glyph)
		) {
			return array();
		}

		$glyphs = array();

		foreach ($font->defs[0]->font[0]->glyph as $xmlGlyph) {

			if ($xmlGlyph['unicode']) {

				$glyph = array();
				$char = (string)$xmlGlyph['unicode'];

				$unicode = unpack('N', mb_convert_encoding($char, 'UCS-4BE', 'UTF-8'));
				$glyph['code'] = dechex($unicode[1]);

				if(isset($xmlGlyph['glyph-name'])){
					$glyph['name'] = (string)$xmlGlyph['glyph-name'];
				}

				// ignore white space and control characters
				if (hexdec($glyph['code']) > 32 && !empty($xmlGlyph['d']) && (string)$xmlGlyph['d'] !== 'M0 0v0v0v0v0z') {
					$glyphs[] = $glyph;
				}
			}

		}

		if (
			file_exists($infoFilePath = TL_ROOT . '/' . substr($fontPath, 0, -4) . '.html') ||
			file_exists($infoFilePath = TL_ROOT . '/' . substr($fontPath, 0, -4) . '.css')
		) {

			$infoFileContents = file_get_contents($infoFilePath);

			if (
				preg_match_all(
					'(\\sdata-icon="(?P<key>[^"]+)".*?\\sclass="class-name"[^>]*>icon-(?P<value>[0-9a-z_-]*))is',
					$infoFileContents,
					$matches
				) ||
				preg_match_all(
					'((?P<value>[^}]+)?content\\s*:\\s*["\'](?P<key>[^"\']+)["\'])is',
					$infoFileContents,
					$matches
				)
			) {

				$iconNames = array_combine(array_map(function($key) {
					if (substr($key, 0, 3) === '&#x') {
						return rtrim(substr($key, 3), ';');
					}
					if (substr($key, 0, 1) === '\\') {
						return substr($key, 1);
					}
					if (mb_strlen($key, 'UTF-8') === 1) {
						return ltrim(implode('',
							unpack('H*', mb_convert_encoding($key, 'UCS-4BE', 'UTF-8'))
						), '0');
					}
					return '';

				}, $matches['key']), $matches['value']);

				$iconNames = array_map('trim', preg_replace(
					array('(/\\*.*?\\*/|:before|:after)is', '([^a-z0-9]+)is'),
					array('', ' '),
					$iconNames
				));

				foreach ($glyphs as $key => $glyph) {
					if (isset($iconNames[$glyph['code']]) && (empty($glyph['name']) || stripos($glyph['name'], $iconNames[$glyph['code']]) === false)) {
						$glyphs[$key]['name'] = (empty($glyph['name']) ? '' : $glyph['name'] . ' ')
							. $iconNames[$glyph['code']];
					}
				}

			}

		}

		$cacheFile = new \File($cacheFilePath, true);
		$cacheFile->write('<?php' . "\n" . 'return ' . var_export($glyphs, true) . ';');
		$cacheFile->close();

		return $glyphs;
	}
45757
public static function js($pro = false)
    {
        if($pro)
        {
            $url = 'pro.fontawesome.com';
            $integrity = 'sha384-GBwm0s/0wYcqnK/JmrCoRqWYIWzFiGEucsfFqkB76Ouii5+d4R31vWHPQtfhv55b';
        }
        else
        {
            $url = 'use.fontawesome.com';
            $integrity = 'sha384-g5uSoOSBd7KkhAMlnQILrecXvzst9TdC09/VM+pjDTCM+1il8RHz5fKANTFFb+gQ';
        }

        return '<script defer src="https://' . $url . '/releases/v' .
        self::FA_VERSION . '/js/all.js" integrity="' . $integrity . '" crossorigin="anonymous"></script>';
    }