/**
  * Return font full path
  *
  * @param string $fontdir Original font directory
  * @param string $file    Font file name.
  *
  * @return string Font full path or empty string
  */
 protected function getFontFullPath($fontdir, $file)
 {
     $dirobj = new Dir();
     // directories where to search for the font definition file
     $dirs = array_unique(array('', $fontdir, defined('K_PATH_FONTS') ? K_PATH_FONTS : '', $dirobj->findParentDir('fonts', __DIR__)));
     foreach ($dirs as $dir) {
         if (@is_readable($dir . $file)) {
             return $dir . $file;
         }
     }
     throw new FontException('Unable to locate the file: ' . $file);
 }
 /**
  * Find the path where to store the processed font.
  *
  * @param string $output_path    Output path for generated font files (must be writeable by the web server).
  *                               Leave null for default font folder (K_PATH_FONTS).
  *
  * @return string
  */
 protected function findOutputPath($output_path = null)
 {
     if (!empty($output_path) && is_writable($output_path)) {
         return $output_path;
     }
     if (defined('K_PATH_FONTS') && is_writable(K_PATH_FONTS)) {
         return K_PATH_FONTS;
     }
     $dirobj = new Dir();
     $dir = $dirobj->findParentDir('fonts', __DIR__);
     if ($dir == '/') {
         $dir = sys_get_temp_dir();
     }
     if (substr($dir, -1) !== '/') {
         $dir .= '/';
     }
     return $dir;
 }
Exemple #3
0
 /**
  * Returns a list of font directories
  *
  * @return array Font directories
  */
 protected function findFontDirectories()
 {
     $dirobj = new Dir();
     $dirs = array('');
     if (defined('K_PATH_FONTS')) {
         $dirs[] = K_PATH_FONTS;
         $dirs = array_merge($dirs, array_filter(glob(K_PATH_FONTS . '/*'), 'is_dir'));
     }
     $parent_font_dir = $dirobj->findParentDir('fonts', __DIR__);
     if (!empty($parent_font_dir)) {
         $dirs[] = $parent_font_dir;
         $dirs = array_merge($dirs, array_filter(glob($parent_font_dir . '/*'), 'is_dir'));
     }
     return array_unique($dirs);
 }