You are here

function _cufon_find_fonts in Cufón 6

Same name and namespace in other branches
  1. 7.2 cufon.module \_cufon_find_fonts()

_cufon_find_fonts().

Find all installed Cufon fonts.

  • <current_theme>
  • profiles/<profile>/libraries/cufon-fonts/
  • sites/all/libraries/cufon-fonts/
  • sites/<current_site>/libraries/cufon-fonts/
2 calls to _cufon_find_fonts()
cufon_admin in ./cufon.admin.inc
Administration settings page
cufon_preprocess_page in ./cufon.module
Implementation of hook_preprocess_page().

File

./cufon.module, line 44
Adds simple Cufón support to Drupal.

Code

function _cufon_find_fonts() {
  global $language;
  $pattern = '.*\\.js$';
  $conf_path = conf_path();

  // Search for fonts in this order:
  // - theme folders (only enabled themes)
  // - site library folder
  // - if you want to use different fonts for different languages put them into <langcode>/ subfolder
  // - default font MUST exist!
  $files = array();
  foreach (list_themes() as $theme) {
    if ($theme->status === '0') {
      continue;
    }
    $files += file_scan_directory(drupal_get_path('theme', $theme->name), $pattern);
  }
  $files += drupal_system_listing('\\.js$', 'libraries/cufon-fonts', 'name', 0);
  $fonts = array();
  foreach ($files as $file) {

    // Check for language specific font
    if (!empty($language)) {
      $f = dirname($file->filename) . '/' . $language->language . '/' . $file->filename;
      if (file_exists($f)) {
        $file->uri = $f;
      }
    }

    // Resolve font families...
    $families = _cufon_get_font_families($file->filename);
    if (empty($families)) {
      continue;
    }
    foreach ($families as $family) {

      // ... and keep complete file info if not set already
      if (!isset($fonts[$family])) {
        $fonts[$family] = $file;
      }
    }
  }
  return $fonts;
}