3 * @package php-font-lib
4 * @link https://github.com/PhenX/php-font-lib
5 * @author Fabien Ménager <fabien.menager@gmail.com>
6 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
12 * Autoloads FontLib classes
14 * @package php-font-lib
17 const PREFIX
= 'FontLib';
20 * Register the autoloader
22 public static function register() {
23 spl_autoload_register(array(new self
, 'autoload'));
31 public static function autoload($class) {
32 $prefixLength = strlen(self
::PREFIX
);
33 if (0 === strncmp(self
::PREFIX
, $class, $prefixLength)) {
34 $file = str_replace('\\', DIRECTORY_SEPARATOR
, substr($class, $prefixLength));
35 $file = realpath(__DIR__
. (empty($file) ?
'' : DIRECTORY_SEPARATOR
) . $file . '.php');
36 if (file_exists($file)) {
43 Autoloader
::register();