function fonts_com_preprocess_html in @font-your-face 7.2
Implements template_preprocess_html().
File
- modules/
fonts_com/ fonts_com.module, line 168
Code
function fonts_com_preprocess_html(&$vars) {
if (!empty($vars['fontyourface'])) {
$projects = array();
$preview_fonts = array();
foreach ($vars['fontyourface'] as $used_font) {
if ($used_font->provider == 'fonts_com') {
$metadata = unserialize($used_font->metadata);
if (isset($metadata['project_id']) && $metadata['project_id'] != '') {
$projects[$metadata['project_id']] = TRUE;
}
else {
$preview_fonts[] = $used_font;
}
// else
}
// if
}
// foreach
if (count($projects) > 0) {
$base = 'http://fast.fonts.com/jsapi/';
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$base = 'https://fast.fonts.com/jsapi/';
}
// if
foreach (array_keys($projects) as $project) {
drupal_add_js($base . $project . '.js', array(
'type' => 'external',
));
}
// foreach
}
// if
if (count($preview_fonts) > 0) {
$destination = file_build_uri('fontyourface/fonts_com/preview.css');
$css = '';
$destination_directory = dirname($destination);
if (file_prepare_directory($destination_directory, FILE_CREATE_DIRECTORY)) {
foreach ($preview_fonts as $font) {
$css .= fonts_com_font_inline_css($font) . "\n\n";
}
// foreach
}
// if
if ($css != '') {
drupal_add_css($css, array(
'group' => CSS_THEME,
'type' => 'inline',
));
}
// if
}
// if
}
// if
}