You are here

function fontsquirrel_api_page_attachments in @font-your-face 8.3

Implements hook_page_attachments().

File

modules/fontsquirrel_api/fontsquirrel_api.module, line 78
Font Squirrel API module file.

Code

function fontsquirrel_api_page_attachments(&$page) {
  $enabled_fonts =& drupal_static('fontyourface_fonts', []);
  foreach ($enabled_fonts as $font) {
    if ($font->pid->value == 'fontsquirrel_api' && $font
      ->isActivated()) {
      $directory_location = _fontsquirrel_api_get_font_directory_location($font);
      $page['#attached']['html_head'][] = [
        [
          '#type' => 'html_tag',
          '#tag' => 'link',
          '#attributes' => [
            'rel' => 'stylesheet',
            'href' => file_create_url($directory_location . '/fontyourface-stylesheet.css'),
            'media' => 'all',
          ],
        ],
        'fontsquirrel-api-' . $font
          ->id(),
      ];
    }
  }
}