Page 1 of 3

Additional fonts on shared host

Posted: 2014-02-11T09:59:25-07:00
by doyley3
Version: ImageMagick 6.6.0-4 2012-05-03 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

Hello, ImageMagick is installed on my shared hosting (to which I have ssh but not root access). I want to add a list of additional fonts but as I'm not able to access the root and add fonts there, I'm wondering how to change the path or add an additional path for my new fonts?

Re: Additional fonts on shared host

Posted: 2014-02-11T10:54:06-07:00
by snibgo
In general, you can specify the full path to a font file in your command.

Re: Additional fonts on shared host

Posted: 2014-02-11T11:10:07-07:00
by doyley3
Thanks for the reply.

I don't think I'm issuing any commands as such. I have a custom module within a Magento installation which is using ImageMagick for frontend customisation of svg files. Fonts are embedded in the svgs so I need them to be visible to the user.

I tried uploading the font and then convert -font /home/under/private/fonts/Aleo-Regular.otf

but get convert.bin: option requires an argument `-font' @ error/convert.c/ConvertImageCommand/1464.

Re: Additional fonts on shared host

Posted: 2014-02-11T11:30:12-07:00
by snibgo
I think SVG files can also specify the full path.

MAGICK_FONT_PATH might do the trick. See http://www.imagemagick.org/script/resou ... nvironment

"convert -font {fontfile}" won't do anything.

Re: Additional fonts on shared host

Posted: 2014-02-11T11:33:41-07:00
by doyley3
Sorry, I'm a bit dim with ssh commands... what would I need to type?

Re: Additional fonts on shared host

Posted: 2014-02-11T11:48:49-07:00
by snibgo
Sorry, I don't know ssh.

Re: Additional fonts on shared host

Posted: 2014-02-11T11:52:28-07:00
by fmw42
I am not an expert on this but see http://www.imagemagick.org/script/resou ... nvironment for MAGICK_FONT_PATH. But I suspect that is needed in your PATH and you may not have access to that. But that does not help you upload new fonts.

You should be able to upload them via FTP.

However, I am not sure why you cannot just provide the full path to any fonts you upload in your command line. MAGICK_FONT_PATH should not really be needed.

Re: Additional fonts on shared host

Posted: 2014-02-11T13:21:30-07:00
by doyley3
MAGIC_FONT_PATH looks promising.

I've made a fonts directory here home/under/private/fonts and this is where I've uploaded the otf files for my new fonts.

Would I have to put MAGIC_FONT_PATH=/home/under/private/fonts somewhere in the custom module files that are using ImageMagick for dynamic svgs?

Or is it a command that i run in ssh?

Re: Additional fonts on shared host

Posted: 2014-02-11T13:57:03-07:00
by doyley3
This is the advice my hosts gave:

You could upload the additional fonts to a separate folder, /home/under/private/fonts/ for example. Then, you need to modify your website software, and change

convert -font FontName

to

convert -font /home/under/private/fonts/FontName.otf

You need to modify the PHP code of the website script that runs "convert", so that it can use your custom fonts as well, not just the default system fonts.

But I can't find anything even similar to "convert"in the website files.

Re: Additional fonts on shared host

Posted: 2014-02-11T14:20:29-07:00
by snibgo
How about "mogrify" or "composite"?

Re: Additional fonts on shared host

Posted: 2014-02-11T15:14:35-07:00
by fmw42
Your ISP suggestion is correct. That is what I mentioned before. Just FTP some fonts to a directory in your account. Then use the full path to the font, when you need to use it.

You would need to run PHP exec() or Imagick to make use of convert on your web site. What is the exact command you have been trying to run?

Re: Additional fonts on shared host

Posted: 2014-02-15T02:59:06-07:00
by doyley3
It's a custom Magento extension that allows frontend personalisation of text on an svg so i can't find a command as such as it's dynamic.

I've instructed my developers to add an environment variable to the php code of the custom extension that uses MAGICK_FONT_PATH (then the path to the font folder) - but they say that's not possible.

I'm in deadlock now as I'm being told the only way I can get Imagmagick to use additional fonts is if I am on a VPS with access to root. This can't be right surely???

Re: Additional fonts on shared host

Posted: 2014-02-15T11:29:32-07:00
by fmw42
If you are running IM and using command line syntax or command line syntax via PHP exec(), I see no reason you cannot have fonts in your own directory (rather than root) and just put the full path to the font when using -font fullpath2/somefont.suffix. IM may not be able to use all font suffixes. I typically use .ttf fonts.

If you are using some other tool to access IM, I would not be able to comment about how it interfaces with IM.

Re: Additional fonts on shared host

Posted: 2014-02-16T07:57:53-07:00
by doyley3
I'm looking for something like this in the current code:

<?php

putenv('MAGICK_HOME=/usr/local');
putenv('PATH=' . getenv('MAGICK_HOME') . '/bin:' . getenv('PATH'));
putenv('DYLD_LIBRARY_PATH=' . getenv('MAGICK_HOME') . '/lib');

so i can add a new font path

is that correct?

Re: Additional fonts on shared host

Posted: 2014-02-16T08:13:53-07:00
by doyley3
I can find no references to "convert" - the only references to imagemagick that I can find are like the one below:

$out_image_file = 'test_' . $rand . '.png';
$image = new Imagick();
$image->readImageBlob($replace_file_content);
$image->setImageFormat("png24");
//$image->resizeImage(600, 600, imagick::FILTER_LANCZOS, 1);
$image->writeImage($out_image_file);