function adobe_edge_fonts_generate_font_family_css in @font-your-face 8.3
Generates font family css for multiple fonts.
Parameters
array $fonts: Array of FontInterface objects.
Return value
string URL to load fonts on page.
1 call to adobe_edge_fonts_generate_font_family_css()
- adobe_edge_fonts_page_attachments in modules/
adobe_edge_fonts/ adobe_edge_fonts.module - Implements hook_page_attachments().
File
- modules/
adobe_edge_fonts/ adobe_edge_fonts.module, line 89 - Adobe Edge Fonts module file.
Code
function adobe_edge_fonts_generate_font_family_css(array $fonts) {
$font_list = $families = [];
$url = '';
foreach ($fonts as $font) {
$metadata = $font
->getMetadata();
$font_list[$font->css_family->value][] = $metadata['subset'];
}
foreach ($font_list as $key => $font) {
$families[] = $key . ':' . implode(',', $font);
}
if (!empty($families)) {
$url = 'https://use.edgefonts.net/' . implode(';', $families) . '.js';
}
return $url;
}