function local_fonts_page_attachments in @font-your-face 8.3
Implements hook_page_attachments().
File
- modules/
local_fonts/ local_fonts.module, line 25 - Local Fonts module file.
Code
function local_fonts_page_attachments(&$page) {
$enabled_fonts =& drupal_static('fontyourface_fonts', []);
foreach ($enabled_fonts as $font) {
if ($font->pid->value == 'local_fonts') {
$metadata = $font
->getMetadata();
$font_id = $metadata['id'];
$directory = file_build_uri('fontyourface/local_fonts/' . $font_id);
$page['#attached']['html_head'][] = [
[
'#type' => 'html_tag',
'#tag' => 'link',
'#attributes' => [
'rel' => 'stylesheet',
'href' => file_create_url($directory . '/font.css'),
'media' => 'all',
],
],
'local-fonts-' . $font_id,
];
}
}
}