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.

migrated from stackoverflow.com May 15 '14 at 17:56

This question came from our site for professional and enthusiast programmers.

4

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.