You are here

function fontscom_api_fontyourface_font_css in @font-your-face 8.3

Implements hook_fontyourface_font_css().

File

modules/fontscom_api/fontscom_api.module, line 180
Fonts.com API module file.

Code

function fontscom_api_fontyourface_font_css(FontInterface $font, FontDisplayInterface $font_style = NULL, $separator = ' ') {
  if ($font->pid->value == 'fontscom_api') {
    $css = [];

    // Enclose font family definition in single quotes if not already enclosed.
    if ($font->css_family->value[0] === "'") {
      $family_list = $font->css_family->value;
    }
    else {
      $family_list = "'" . $font->css_family->value . "'";
    }
    if ($font_style !== NULL) {
      if ($font_style->css_fallbacks) {
        $family_list .= ', ' . $font_style->css_fallbacks;
      }
    }
    $css[] = 'font-family: ' . $family_list . ';';
    $css[] = 'font-style: 400;';
    $css[] = 'font-weight: normal;';
    return implode($separator, $css);
  }
}