You are here

public function TextimageFontsHandlerTextimage::getUri in Textimage 7.3

Return the URI of a font file, given its name.

Parameters

string $font_name: the name of the font.

array $options: an array of additional options.

Return value

string the URI of the font file.

Overrides TextimageFontsHandlerInterface::getUri

File

classes/font_handlers/textimage.inc, line 58
Textimage - Fonts handler class for Textimage.

Class

TextimageFontsHandlerTextimage
Fonts handler for Textimage.

Code

public function getUri($font_name, $options) {
  $fonts_path = isset($options['fonts_path']) ? $options['fonts_path'] : _textimage_get_variable('fonts_path');
  if (is_dir($fonts_path) && ($handle = opendir($fonts_path))) {
    while ($file_name = readdir($handle)) {
      if (preg_match("/\\.[ot]tf\$/i", $file_name) == 1) {
        $font = self::getData($fonts_path . '/' . $file_name);
        if ($font_name == $font['name']) {
          return $font['file'];
        }
      }
    }
    closedir($handle);
  }
  return NULL;
}