Enqueue google fonts.

@access public
@return null
511712
public function enqueue_fonts() {

		// Check if we need to exit early.
		if ( empty( self::$fields ) || ! is_array( self::$fields ) ) {
			return;
		}

		foreach ( self::$fields as $field ) {

			// Process typography fields.
			if ( isset( $field['type'] ) && 'typography' === $field['type'] ) {

				// Check if we've got everything we need.
				if ( ! isset( $field['kirki_config'] ) || ! isset( $field['settings'] ) ) {
					continue;
				}
				$value = self::get_option( $field['kirki_config'], $field['settings'] );
				if ( isset( $value['font-family'] ) ) {
					$url              = '//fonts.googleapis.com/css?family=' . str_replace( ' ', '+', $value['font-family'] );
					$value['variant'] = ( isset( $value['variant'] ) ) ? $value['variant'] : '';
					$url             .= ( empty( $value['variant'] ) ) ? '' : ':' . $value['variant'];

					$key = md5( $value['font-family'] . $value['variant'] );

					// Check that the URL is valid. we're going to use transients to make this faster.
					$url_is_valid = get_transient( $key );

					// If transient does not exist.
					if ( false === $url_is_valid ) {
						$response = wp_remote_get( 'https:' . $url );
						if ( ! is_array( $response ) ) {

							// The url was not properly formatted,
							// cache for 12 hours and continue to the next field.
							set_transient( $key, null, 12 * HOUR_IN_SECONDS );
							continue;
						}

						// Check the response headers.
						if ( isset( $response['response'] ) && isset( $response['response']['code'] ) ) {
							if ( 200 === $response['response']['code'] ) {

								// URL was ok. Set transient to true and cache for a week.
								set_transient( $key, true, 7 * 24 * HOUR_IN_SECONDS );
								$url_is_valid = true;
							}
						}
					}

					// If the font-link is valid, enqueue it.
					if ( $url_is_valid ) {
						wp_enqueue_style( $key, $url, array(), '1.0' );
					}
				}
			}
		}
	}
300826
public static function enumFonts() {
        return [
            FontAwesomeIconInterface::FONT_AWESOME_FONT,
            FontAwesomeIconInterface::FONT_AWESOME_FONT_BOLD,
            FontAwesomeIconInterface::FONT_AWESOME_FONT_LIGHT,
            FontAwesomeIconInterface::FONT_AWESOME_FONT_REGULAR,
            FontAwesomeIconInterface::FONT_AWESOME_FONT_SOLID,
        ];
    }
441666
protected function _load_font($font, $encoding = null, $options = "")
    {
        // Set up font paths
        if ($this->_pdf->get_parameter("FontOutline", 1) === "") {
            $families = $this->_dompdf->getFontMetrics()->getFontFamilies();
            foreach ($families as $files) {
                foreach ($files as $file) {
                    $face = basename($file);
                    $afm = null;

                    // Prefer ttfs to afms
                    if (file_exists("$file.ttf")) {
                        $outline = "$file.ttf";

                    } else if (file_exists("$file.TTF")) {
                        $outline = "$file.TTF";

                    } else if (file_exists("$file.pfb")) {
                        $outline = "$file.pfb";
                        if (file_exists("$file.afm")) {
                            $afm = "$file.afm";
                        }

                    } else if (file_exists("$file.PFB")) {
                        $outline = "$file.PFB";
                        if (file_exists("$file.AFM")) {
                            $afm = "$file.AFM";
                        }
                    } else {
                        continue;
                    }

                    $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}");

                    if (!is_null($afm)) {
                        $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}");
                    }
                }
            }
        }

        // Check if the font is a native PDF font
        // Embed non-native fonts
        $test = strtolower(basename($font));
        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];
        } else {
            $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options);
            return $this->_fonts[$key];
        }
    }
449225
public function saveFontFamilies()
    {
        // replace the path to the DOMPDF font directories with the corresponding constants (allows for more portability)
        $cacheData = sprintf("<?php return array (%s", PHP_EOL);
        foreach ($this->fontLookup as $family => $variants) {
            $cacheData .= sprintf("  '%s' => array(%s", addslashes($family), PHP_EOL);
            foreach ($variants as $variant => $path) {
                $path = sprintf("'%s'", $path);
                $path = str_replace('\'' . $this->getOptions()->getFontDir() , '$fontDir . \'' , $path);
                $path = str_replace('\'' . $this->getOptions()->getRootDir() , '$rootDir . \'' , $path);
                $cacheData .= sprintf("    '%s' => %s,%s", $variant, $path, PHP_EOL);
            }
            $cacheData .= sprintf("  ),%s", PHP_EOL);
        }
        $cacheData .= ") ?>";
        file_put_contents($this->getCacheFile(), $cacheData);
    }
1086170
public function registerFont(PHPRtfLite_Font $font)
    {
        $font->setColorTable($this->getColorTable());
        $font->setFontTable($this->getFontTable());
    }
919699
public function fontSet()
    {
        $family = strtolower($this->value['font-family']);

        $b = ($this->value['font-bold']        ? 'B' : '');
        $i = ($this->value['font-italic']      ? 'I' : '');
        $u = ($this->value['font-underline']   ? 'U' : '');
        $d = ($this->value['font-linethrough'] ? 'D' : '');
        $o = ($this->value['font-overline']    ? 'O' : '');

        // font style
        $style = $b.$i;

        if ($this->defaultFont) {
            if ($family === 'arial') {
                $family='helvetica';
            } elseif ($family === 'symbol' || $family === 'zapfdingbats') {
                $style='';
            }

            $fontkey = $family.$style;
            if (!$this->pdf->isLoadedFont($fontkey)) {
                $family = $this->defaultFont;
            }
        }

        if ($family === 'arial') {
            $family='helvetica';
        } elseif ($family === 'symbol' || $family === 'zapfdingbats') {
            $style='';
        }

        // complete style
        $style.= $u.$d.$o;

        // size : mm => pt
        $size = $this->value['font-size'];
        $size = 72 * $size / 25.4;

        // apply the font
        $this->pdf->SetFont($family, $style, $this->value['mini-size']*$size);
        $this->pdf->SetTextColorArray($this->value['color']);
        if ($this->value['background']['color']) {
            $this->pdf->SetFillColorArray($this->value['background']['color']);
        } else {
            $this->pdf->SetFillColor(255);
        }
    }
1283568
public function the_css() {
		foreach ( $this->fonts_to_load as $font ) {
			$family  = str_replace( ' ', '+', trim( $font['family'] ) );
			$weights = join( ',', $font['weights'] );
			$url     = "https://fonts.googleapis.com/css?family={$family}:{$weights}&subset=cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai";

			$transient_id = 'kirki_gfonts_' . md5( $url );
			$contents     = get_site_transient( $transient_id );
			/**
			 * Note to code reviewers:
			 * There's no need to check nonces or anything else, this is a simple true/false evaluation.
			 */
			if ( ! empty( $_GET['action'] ) && 'kirki-reset-cache' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
				$contents = false;
			}
			if ( ! $contents ) {

				// Get the contents of the remote URL.
				$contents = Helper::get_remote_url_contents(
					$url,
					[
						'headers' => [
							/**
							 * Set user-agent to firefox so that we get woff files.
							 * If we want woff2, use this instead: 'Mozilla/5.0 (X11; Linux i686; rv:64.0) Gecko/20100101 Firefox/64.0'
							 */
							'user-agent' => 'Mozilla/5.0 (X11; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0',
						],
					]
				);

				/**
				 * Allow filtering the font-display property.
				 */
				$font_display = apply_filters( 'kirki_googlefonts_font_display', 'swap' );

				if ( $contents ) {

					// Add font-display:swap to improve rendering speed.
					$contents = str_replace( '@font-face {', '@font-face{', $contents );
					$contents = str_replace( '@font-face{', '@font-face{font-display:' . $font_display . ';', $contents );

					// Remove blank lines and extra spaces.
					$contents = str_replace(
						[ ': ', ';  ', '; ', '  ' ],
						[ ':', ';', ';', ' ' ],
						preg_replace( "/\r|\n/", '', $contents )
					);

					// Use local fonts.
					if ( apply_filters( 'kirki_use_local_fonts', true ) ) {
						$contents = $this->use_local_files( $contents );
					}

					// Set the transient for a week.
					set_site_transient( $transient_id, $contents, WEEK_IN_SECONDS );
				}
			}
			if ( $contents ) {
				/**
				 * Note to code reviewers:
				 *
				 * Though all output should be run through an escaping function, this is pure CSS
				 * and it is added on a call that has a PHP `header( 'Content-type: text/css' );`.
				 * No code, script or anything else can be executed from inside a stylesheet.
				 * For extra security we're using the wp_strip_all_tags() function here
				 * just to make sure there's no <script> tags in there or anything else.
				 */
				echo wp_strip_all_tags( $contents ); // phpcs:ignore WordPress.Security.EscapeOutput
			}
		}
	}
911215
public function get_default_font( $font_type ) {

		$defaults = array_combine(
			array_keys( $this->font_types ),
			wp_list_pluck( $this->font_types, 'default' )
		);

		$default = isset( $defaults[ $font_type ] ) ? $defaults[ $font_type ] : $this->fonts[0];

		return $this->sanitize_font( $default );

	}
1031340
protected function fontsUrl($fonts): string
    {
        $font_families = \array_keys($fonts);

        $query_args = [
            'family' => \rawurlencode(\implode('|', $font_families)),
            'subset' => \rawurlencode('latin,latin-ext'),
        ];

        return \add_query_arg($query_args, 'https://fonts.googleapis.com/css');
    }
895840
public function generate_google_font( $args ) {

		// Process typography fields.
		if ( ( isset( $args['type'] ) && 'kirki-typography' === $args['type'] ) || ( isset( $args['choices'] ) && isset( $args['choices']['parent_type'] ) && 'kirki-typography' === $args['choices']['parent_type'] ) ) {

			// Get the value.
			$value = Values::get_sanitized_field_value( $args );

			// If we don't have a font-family then we can skip this.
			if ( ! isset( $value['font-family'] ) || in_array( $value['font-family'], $this->hosted_fonts, true ) ) {
				return;
			}

			// If not a google-font, then we can skip this.
			if ( ! isset( $value['font-family'] ) || ! Fonts::is_google_font( $value['font-family'] ) ) {
				return;
			}

			// Set a default value for variants.
			if ( ! isset( $value['variant'] ) ) {
				$value['variant'] = 'regular';
			}

			// Add the requested google-font.
			if ( ! is_array( $value ) || ! isset( $value['font-family'] ) || ! isset( $this->fonts[ $value['font-family'] ] ) ) {
				$this->fonts[ $value['font-family'] ] = [];
			}
			if ( ! in_array( $value['variant'], $this->fonts[ $value['font-family'] ], true ) ) {
				$this->fonts[ $value['font-family'] ][] = $value['variant'];
			}

			// Are we force-loading all variants?
			if ( true === self::$force_load_all_variants ) {
				$all_variants               = Fonts::get_all_variants();
				$args['choices']['variant'] = array_keys( $all_variants );
			}

			if ( ! empty( $args['choices']['variant'] ) && is_array( $args['choices']['variant'] ) ) {
				foreach ( $args['choices']['variant'] as $extra_variant ) {
					$this->fonts[ $value['font-family'] ][] = $extra_variant;
				}
			}
			return;
		}

		// Process non-typography fields.
		if ( isset( $args['output'] ) && is_array( $args['output'] ) ) {
			foreach ( $args['output'] as $output ) {

				// If we don't have a typography-related output argument we can skip this.
				if ( ! isset( $output['property'] ) || ! in_array( $output['property'], [ 'font-family', 'font-weight' ], true ) ) {
					continue;
				}

				// Get the value.
				$value = Values::get_sanitized_field_value( $args );

				if ( is_string( $value ) ) {
					if ( 'font-family' === $output['property'] ) {
						if ( ! array_key_exists( $value, $this->fonts ) ) {
							$this->fonts[ $value ] = [];
						}
					} elseif ( 'font-weight' === $output['property'] ) {
						foreach ( $this->fonts as $font => $variants ) {
							if ( ! in_array( $value, $variants, true ) ) {
								$this->fonts[ $font ][] = $value;
							}
						}
					}
				}
			}
		}
	}
275915
public function getAvailableFonts()
    {
        try {
            $ret    = array();
            $result = $this->getSoapClient()->GetFontNames();
            if ( isset($result->GetFontNamesResult->string) ) {
                $ret = $result->GetFontNamesResult->string;
            }

            return $ret;
        } catch ( SoapException $ex ) {
            throw new StatusException('Error while getting the list of available fonts' , $ex);
        }
    }
1189214
public function enqueue() {
		parent::enqueue();

		// Enqueue the script.
		wp_enqueue_script( 'kirki-control-color-palette', URL::get_from_path( dirname( __DIR__ ) . '/assets/scripts/control.js' ), [ 'jquery', 'customize-base', 'kirki-dynamic-control' ], self::$control_ver, false );

		// Enqueue the style.
		wp_enqueue_style( 'kirki-control-color-palette-style', URL::get_from_path( dirname( __DIR__ ) . '/assets/styles/style.css' ), [], self::$control_ver );
	}
154335
public function writeFont()
	{
		$font_outline = 0;
		$font_shadow = 0;

		$icv = $this->_colorIndex; // Index to color palette
		if ($this->_font->getSuperScript()) {
			$sss = 1;
		} else if ($this->_font->getSubScript()) {
			$sss = 2;
		} else {
			$sss = 0;
		}
		$bFamily = 0; // Font family
		$bCharSet = PHPExcel_Shared_Font::getCharsetFromFontName($this->_font->getName()); // Character set

		$record = 0x31;		// Record identifier
		$reserved = 0x00;	// Reserved
		$grbit = 0x00;		// Font attributes
		if ($this->_font->getItalic()) {
			$grbit |= 0x02;
		}
		if ($this->_font->getStrikethrough()) {
			$grbit |= 0x08;
		}
		if ($font_outline) {
			$grbit |= 0x10;
		}
		if ($font_shadow) {
			$grbit |= 0x20;
		}

		$data = pack("vvvvvCCCC",
			$this->_font->getSize() * 20,						//	Fontsize (in twips)
			$grbit,
			$icv,												//	Colour
			self::_mapBold($this->_font->getBold()),			//	Font weight
			$sss,												//	Superscript/Subscript
			self::_mapUnderline($this->_font->getUnderline()),
			$bFamily,
			$bCharSet,
			$reserved
		);
		$data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($this->_font->getName());

		$length = strlen($data);
		$header = pack("vv", $record, $length);

		return($header . $data);
	}
17661
public function get_google_fonts_by_args( $args = [] ) {
		$cache_name = 'kirki_googlefonts_' . md5( wp_json_encode( $args ) );
		$cache      = get_site_transient( $cache_name );
		if ( $cache ) {
			return $cache;
		}

		$args['sort'] = isset( $args['sort'] ) ? $args['sort'] : 'alpha';

		$fonts         = $this->get_array();
		$ordered_fonts = $fonts['order'][ $args['sort'] ];
		if ( isset( $args['count'] ) ) {
			set_site_transient( $cache_name, $ordered_fonts, HOUR_IN_SECONDS );
			$ordered_fonts = array_slice( $ordered_fonts, 0, $args['count'] );
			return $ordered_fonts;
		}
		set_site_transient( $cache_name, $ordered_fonts, HOUR_IN_SECONDS );
		return $ordered_fonts;
	}
988704
public function enqueue_scripts() {
		wp_enqueue_style( 'kirki-control-typography-style', URL::get_from_path( dirname( __DIR__ ) . '/assets/styles/style.css' ), [], '1.0' );

		wp_enqueue_script( 'kirki-typography', URL::get_from_path( dirname( __DIR__ ) . '/assets/scripts/script.js' ), [], '1.0', true );
		wp_localize_script( 'kirki-typography', 'kirkiTypographyControls', self::$typography_controls );

		if ( ! self::$gfonts_var_added ) {
			echo '<script>kirkiGoogleFonts=';
			$google = new GoogleFonts();
			$google->print_googlefonts_json( false );
			echo ';</script>';
			self::$gfonts_var_added = true;
		}
	}
364110
protected function enqueueStyle()
    {
        wp_enqueue_style(
            $this->getHandle(),
            $this->getUrl(),
            $this->getDependencies(),
            $this->getVersion(),
            $this->getArgument()
        );

        if (! empty($this->inline)) {
            foreach ($this->inline as $code) {
                wp_add_inline_style($this->getHandle(), $code['code']);
            }
        }
    }
1110183
public function enqueueDeviconLibs()
    {
        if (($data = $this->didEnqueueLibs(__METHOD__))) {
            return $data; // Did this already.
        } // We only need to enqueue once.

        $data = [
            'styles' => [
                'devicons' => [
                    'version' => '4f6a4b08efdad6bb29f9cc801f5c07e263b39907',
                    'url'     => '//cdn.rawgit.com/konpa/devicon/%1$s/devicon.min.css',
                ],
            ],
        ];
        return $this->enqueueLibs(__METHOD__, $data);
    }