You are here

function fontyourface_add_theme_info_fonts in @font-your-face 7.2

Load and display fonts that have been added through THEMENAME.info.

1 call to fontyourface_add_theme_info_fonts()
fontyourface_init in ./fontyourface.module
Implements hook_init().

File

./fontyourface.module, line 42

Code

function fontyourface_add_theme_info_fonts() {
  $theme_declarations = fontyourface_parse_theme_info_file();
  if (isset($theme_declarations)) {
    foreach ($theme_declarations as $font_provider => $fonts) {
      if (module_exists($font_provider)) {
        foreach ($fonts as $declaration) {
          $info_function = $font_provider . '_fontyourface_info';
          if (function_exists($info_function)) {
            $provider_info = $info_function();
            $font_url = $provider_info['base_path'] . trim($declaration);
            $font = fontyourface_load_font_by_url($font_url);
            if (!empty($font)) {
              $font->css_selector = '<none>';
              fontyourface_font_registry($font);
            }
            else {
              if (fontyourface_count_fonts($font_provider) > 0) {
                drupal_set_message(t('The font declaration %declaration that is added to the theme .info file cannot be loaded. Make sure the font exists in the %provider font list.', array(
                  '%declaration' => $declaration,
                  '%provider' => $font_provider,
                )), 'error');
              }
              elseif (module_exists('fontyourface_ui')) {
                drupal_set_message(t('The %provider font that is added to the theme .info file cannot be loaded. This is probably because the import has not been run yet. !import to add fonts.', array(
                  '%provider' => check_plain($font_provider),
                  '!import' => l(t('Run import'), 'admin/config/user-interface/fontyourface'),
                )), 'error');
              }
              else {
                drupal_set_message(t('The %provider font that is added to the theme .info file cannot be loaded. This is probably because the import has not been run yet. Enable !module module and run import to add fonts.', array(
                  '%provider' => check_plain($font_provider),
                  '!module' => l('@font-your-face UI', 'admin/modules', array(
                    'fragment' => 'edit-modules-font-your-face',
                  )),
                )), 'error');
              }

              // else
            }

            // else
          }

          // if
        }

        // foreach
      }
      else {
        drupal_set_message(t('The font provider @provider is not enabled yet. Please <a href="!module_path">enable</a> it first.', array(
          '@provider' => $font_provider,
          '!module_path' => url('admin/modules', array(
            'fragment' => 'edit-modules-font-your-face',
          )),
        )), 'error');
      }

      // else
    }

    // foreach
  }

  // if
}