function advagg_relocate_font_face_parser in Advanced CSS/JS Aggregation 7.2
Given an array of font data output a new CSS string.
Parameters
array $font_faces: Array of font data.
Return value
string String of CSS font data.
2 calls to advagg_relocate_font_face_parser()
- advagg_relocate_css_alter in advagg_relocate/
advagg_relocate.module - Implements hook_css_alter().
- _advagg_relocate_callback in advagg_relocate/
advagg_relocate.advagg.inc - Gets external CSS files and puts the contents of it in the aggregate.
File
- advagg_relocate/
advagg_relocate.advagg.inc, line 313 - Advanced aggregation relocate module.
Code
function advagg_relocate_font_face_parser(array $font_faces) {
$new_css = '';
foreach ($font_faces as $values => $src) {
$output = '';
$output .= str_replace('; ', ";\n", $values);
if (isset($src['eot'])) {
$output .= "src: {$src['eot']};\n";
}
$output .= 'src:';
foreach ($src as $key => $location) {
if (is_numeric($key)) {
$output .= "{$location},";
}
}
if (isset($src['eot'])) {
$src['eot'] = str_replace('.eot', '.eot?#iefix', $src['eot']);
$output .= "{$src['eot']} format('embedded-opentype'),";
}
if (isset($src['woff2'])) {
$output .= "{$src['woff2']},";
}
if (isset($src['woff'])) {
$output .= "{$src['woff']},";
}
if (isset($src['ttf'])) {
$output .= "{$src['ttf']},";
}
if (isset($src['svg'])) {
$output .= "{$src['svg']},";
}
$output = str_replace(array(
'),l',
'),u',
), array(
"),\nl",
"),\nu",
), trim($output, ',') . ';');
$new_css .= "@font-face {\n{$output}\n}\n";
}
return $new_css;
}