function _google_fonts_admin_font_example in Google Fonts 7
Same name and namespace in other branches
- 6.2 google_fonts.admin.inc \_google_fonts_admin_font_example()
- 7.2 google_fonts.admin.inc \_google_fonts_admin_font_example()
Returns the font family name, including a span with added styling
1 call to _google_fonts_admin_font_example()
- google_fonts_admin_settings_form in ./
google_fonts.admin.inc - Implements hook_admin_settings() for configuring the module
File
- ./
google_fonts.admin.inc, line 222 - Administrative page callbacks for the Google Fonts module.
Code
function _google_fonts_admin_font_example($font, $display_with_icons = TRUE) {
$module_path = base_path() . drupal_get_path('module', 'google_fonts');
$class_name = _google_fonts_family_array_key_encode($font->family);
$example = '<span class="' . $class_name . ' font_example">' . $font->family . '</span>';
if ($display_with_icons && isset($font->subsets)) {
// Add the subset icons
$example .= '<span class="subsets">';
foreach ($font->subsets as $subset) {
switch ($subset) {
/* To prevent double icons, we can ignore the extended subsets */
case 'cyrillic-ext':
case 'greek-ext':
case 'latin-ext':
case 'khmer-ext':
break;
case 'cyrillic':
$example .= '<img src="' . $module_path . '/icons/cyrillic.png" alt="Cyrillic" title="' . t('Available for the @subset character range', array(
'@subset' => 'cyrillic',
)) . '" />';
break;
case 'greek':
$example .= '<img src="' . $module_path . '/icons/greek.png" alt="Greek" title="' . t('Available for the @subset character range', array(
'@subset' => 'greek',
)) . '" />';
break;
case 'khmer':
$example .= '<img src="' . $module_path . '/icons/khmer.png" alt="Khmer" title="' . t('Available for the @subset character range', array(
'@subset' => 'khmer',
)) . '" />';
break;
case 'vietnamese':
$example .= '<img src="' . $module_path . '/icons/vietnamese.png" alt="Vietnamese" title="' . t('Available for the @subset character range', array(
'@subset' => 'vietnamese',
)) . '" />';
break;
default:
$example .= '<img src="' . $module_path . '/icons/latin.png" alt="Latin" title="' . t('Available for the @subset character range', array(
'@subset' => 'latin',
)) . '" />';
break;
}
}
$example .= '</span>';
// Add variant descriptions
if (sizeof($font->variants) > 1) {
$example .= '<span class="variants">' . t('<span>@count</span> variants (@variants)', array(
'@count' => sizeof($font->variants),
'@variants' => implode(', ', _google_fonts_format_variants($font->variants)),
)) . '</span>';
}
}
return $example;
}