5

I am currently trying to install php-font-lib in joomla, i have been working with custom libraries in joomla for the last 3 hours, So I have absolutely no idea whats going on.

I have Joomla 3.3.

I have gotten it to kind of work, if i remove the namespacing from a file and call it via: jimport('fontlib.Font');

then i tried the following: JLoader::registerNamespace('FontLib', JPATH_LIBRARIES . '/fontlib/');

but i still can not seem to call the Font class.

Is there something I am doing incorrectly?

Any Help Greatly Appreciated.

0

1 Answer 1

3

There are two ways you can do it.

I copied php-font-lib in the path shown in the image below.

enter image description here

Using jimport (with basically just replaces dots with slashes), you can choose to use the Autoloader provided by php-font-lib, which might decouple you nicely from Joomla.

jimport('php-font-lib.src.FontLib.Autoloader');

$font = \FontLib\Font::load('Norasi.ttf');
var_dump($font);

Using the Joomla Autoloader

JLoader::registerNamespace('FontLib', JPATH_LIBRARIES . '/php-font-lib/src/');

$font = \FontLib\Font::load('Norasi.ttf');
var_dump($font);

Enjoy.

2
  • Wow, Thank you... went with using jimport.. the Joomla Autoloader didn't work out..
    – user404
    May 18, 2014 at 8:58
  • Nice to hear that. JLoader should have worked as well, tested myself in 3.3. Anyway, glad I could help. May 18, 2014 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.