".$eol; $args = self::_parameters($fonts, 'fonts'); $lastParam = $args->lastParam; $arguments = $args->arguments; $links = $args->cdnLinks; $strEx = NULL; foreach( $arguments as $font ) { if( is_array($font) ) { $font = ''; // @codeCoverageIgnore } $f = self::_fontName($font); $allFontExtensions = array_merge(Config::expressions('differentFontExtensions'), ['svg', 'woff', 'otf', 'ttf', 'eot']); if( ! empty($allFontExtensions) ) { foreach( $allFontExtensions as $of ) { $fontFile = THEMES_DIR . Theme::$active . $font; $baseUrl = Request::getBaseURL($fontFile); $isFontFile = $fontFile . ( $fontExtension = Base::prefix($of, '.') ); if( ! is_file($isFontFile) ) { $fontFile = EXTERNAL_THEMES_DIR . Theme::$active . $font; $baseUrl = Request::getBaseURL($fontFile); $isFontFile = $fontFile . $fontExtension; } if( is_file($isFontFile) ) { // @codeCoverageIgnoreStart if( $of === 'eot' ) { $str .= ''; $str .= $eol; } // @codeCoverageIgnoreEnd else { $str .= self::_face($f, $baseUrl . $fontExtension); } } } } $cndFont = isset($links[strtolower($font)]) ? $links[strtolower($font)] : NULL; if( ! empty($cndFont) ) $str .= self::_face(self::_fontName($cndFont), $cndFont); } $str .= ''.$eol; if( ! empty($str) ) { if( $lastParam === true ) { return $str; } else { echo $str; } } else { return false; // @codeCoverageIgnore } } /** * Protected Font Name */ protected static function _fontName($font) { $divide = explode('/', $font); $sub = NULL; $name = $divide[0]; // @codeCoverageIgnoreStart if( $sub = ($divide[1] ?? NULL) ) { if( $name === $sub ) { $sub = NULL; } } // @codeCoverageIgnoreEnd return $name . $sub; } /** * Protected Font Face */ protected static function _face($f, $baseUrl, $extension = NULL) { $base = $baseUrl; if( $extension !== NULL ) { $base = Base::suffix($baseUrl, '.' . $extension); // @codeCoverageIgnore } return '@font-face{font-family:"' . Filesystem::removeExtension($f) . '"; src:url("' . $base . '") format("truetype")}' . EOL; } }