You are here

class TextimageFontsHandlerFontyourface in Textimage 7.3

Fonts handler for @font-your-face.

Currently only provides access to fonts uploaded locally via the local font uploading features.

Hierarchy

Expanded class hierarchy of TextimageFontsHandlerFontyourface

File

classes/font_handlers/fontyourface.inc, line 13
Textimage - Fonts handler class for @font-your-face.

View source
class TextimageFontsHandlerFontyourface implements TextimageFontsHandlerInterface {

  /**
   * Return an array of fonts.
   *
   * @param array $options
   *   an array of additional options.
   *
   * @return array
   *   Array of font names.
   */
  public function getList($options) {
    $list = array();
    $font_list = fontyourface_get_fonts("enabled = 1 and provider = 'local_fonts'", 'name ASC');
    if ($font_list) {
      foreach ($font_list as $font) {
        $list[] = $font->name;
      }
    }
    return $list;
  }

  /**
   * Return the URI of a font file, given its name.
   *
   * @param string $font_name
   *   the name of the font.
   * @param array $options
   *   an array of additional options.
   *
   * @return string
   *   the URI of the font file.
   */
  public function getUri($font_name, $options) {
    $font = fontyourface_get_fonts("enabled = 1 and provider = 'local_fonts' and name = '{$font_name}'");
    if (!empty($font)) {
      $font = array_shift($font);
      $metadata = unserialize($font->metadata);
      if (isset($metadata['font_uri']['truetype'])) {
        return $metadata['font_uri']['truetype'];
      }
    }
    return NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TextimageFontsHandlerFontyourface::getList public function Return an array of fonts. Overrides TextimageFontsHandlerInterface::getList
TextimageFontsHandlerFontyourface::getUri public function Return the URI of a font file, given its name. Overrides TextimageFontsHandlerInterface::getUri