Additional fonts on shared host

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
doyley3
Posts: 23
Joined: 2014-02-11T09:52:48-07:00
Authentication code: 6789

Additional fonts on shared host

Post 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?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Additional fonts on shared host

Post by snibgo »

In general, you can specify the full path to a font file in your command.
snibgo's IM pages: im.snibgo.com
doyley3
Posts: 23
Joined: 2014-02-11T09:52:48-07:00
Authentication code: 6789

Re: Additional fonts on shared host

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Additional fonts on shared host

Post 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.
snibgo's IM pages: im.snibgo.com
doyley3
Posts: 23
Joined: 2014-02-11T09:52:48-07:00
Authentication code: 6789

Re: Additional fonts on shared host

Post by doyley3 »

Sorry, I'm a bit dim with ssh commands... what would I need to type?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Additional fonts on shared host

Post by snibgo »

Sorry, I don't know ssh.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Additional fonts on shared host

Post 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.
doyley3
Posts: 23
Joined: 2014-02-11T09:52:48-07:00
Authentication code: 6789

Re: Additional fonts on shared host

Post 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?
doyley3
Posts: 23
Joined: 2014-02-11T09:52:48-07:00
Authentication code: 6789

Re: Additional fonts on shared host

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Additional fonts on shared host

Post by snibgo »

How about "mogrify" or "composite"?
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Additional fonts on shared host

Post 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?
doyley3
Posts: 23
Joined: 2014-02-11T09:52:48-07:00
Authentication code: 6789

Re: Additional fonts on shared host

Post 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???
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Additional fonts on shared host

Post 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.
doyley3
Posts: 23
Joined: 2014-02-11T09:52:48-07:00
Authentication code: 6789

Re: Additional fonts on shared host

Post 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?
doyley3
Posts: 23
Joined: 2014-02-11T09:52:48-07:00
Authentication code: 6789

Re: Additional fonts on shared host

Post 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);
Post Reply