Page 1 of 1

Unable to read font Arial-Bold

Posted: 2013-11-13T15:40:28-07:00
by Marcel71
Hi,

This might be a php problem, but maybe somebody can help anyway :)

I installed 6.8.7-5 on an Ubuntu server.
Version: ImageMagick 6.8.7-5 Q16 x86_64 2013-11-10 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib djvu fontconfig freetype jng jp2 jpeg lcms lqr openexr pangocairo png tiff x xml zlib

I run php:
PHP Version 5.3.10-1ubuntu3.8

When i run the following command on a command line, all goes well:

Code: Select all

convert -background none -density 72 -fill red -font Arial-Bold -pointsize 30 label:Atext out1.png
However, if i run it through php exec, the font can not be found. A message in the apache error log shows:
convert: unable to read font `Arial-Bold' @ warning/annotate.c/RenderType/871.

When i run the exact command as www-data on a shell, it works good.
I have this issue with some fonts, most of the fonts work just fine.

The fonts are in: /usr/share/fonts/truetype/

When i do with php exec:

Code: Select all

identify -list font
The Arial-Bold is missing (a lot self installed fonts are available)

When i do the same command on the prompt (also as www-data) it returns also Arial-Bold.
Anybody have an idea where i need to look for fixing this issue?

Re: Unable to read font Arial-Bold

Posted: 2013-11-13T16:06:43-07:00
by snibgo
I don't know what PHP is doing differently, but you can probably work around it by specifying the full path to the font file, eg:

Code: Select all

convert -background none -density 72 -fill red -font /usr/share/fonts/truetype/arialbld.ttf -pointsize 30 label:Atext out1.png
(But I probably have the filename wrong.)

Re: Unable to read font Arial-Bold

Posted: 2013-11-14T00:18:06-07:00
by Marcel71
Hi,

It indeeds works properly when i use the whole path to the font.
But can i find out (like debugging) why it can't be found by just using the font name?

Regards,
Marcel

Re: Unable to read font Arial-Bold

Posted: 2013-11-14T08:41:18-07:00
by snibgo
Sorry, I don't know PHP.

Re: Unable to read font Arial-Bold

Posted: 2013-11-14T10:43:52-07:00
by fmw42
Marcel71 wrote:Hi,

It indeeds works properly when i use the whole path to the font.
But can i find out (like debugging) why it can't be found by just using the font name?

Regards,
Marcel
PHP and IM use different environment variables and such. In IM one has to create a special file for text names to link to their paths. See http://www.imagemagick.org/Usage/script ... k_type_gen. PHP probably has no information about this file.

Re: Unable to read font Arial-Bold

Posted: 2013-11-14T11:13:02-07:00
by Marcel71
Hi,

I found out the paths used with:

Code: Select all

<?php
        $cmd="convert -debug Configure -background none -density 72 -fill red -font Arial-Bold -pointsize 30 label:ImageMagick /var/www/out1.png 2>&1";
        system($cmd,$output);
        var_dump($output);
?>
Thanks for the replies.

Regards, Marcel