You are here

function _google_fonts_load_css in Google Fonts 7

Same name and namespace in other branches
  1. 6.2 google_fonts.module \_google_fonts_load_css()
  2. 7.2 google_fonts.module \_google_fonts_load_css()

Add the CSS include to the HEAD of the page

2 calls to _google_fonts_load_css()
google_fonts_admin_settings_form in ./google_fonts.admin.inc
Implements hook_admin_settings() for configuring the module
google_fonts_init in ./google_fonts.module
Implements hook_init().

File

./google_fonts.module, line 80
This module enables Google Fonts on your website.

Code

function _google_fonts_load_css($fonts_to_load, $chunksize = 15) {
  $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
  $chunks = array_chunk($fonts_to_load, $chunksize);
  foreach ($chunks as $chunk) {
    drupal_add_css($protocol . '://fonts.googleapis.com/css?family=' . implode('|', $chunk), array(
      'type' => 'external',
      'weight' => CSS_SYSTEM,
    ));
  }
}