Unable to read font Arial-Bold

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?".
Post Reply
Marcel71
Posts: 49
Joined: 2011-04-13T13:57:34-07:00
Authentication code: 8675308

Unable to read font Arial-Bold

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

Re: Unable to read font Arial-Bold

Post 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.)
snibgo's IM pages: im.snibgo.com
Marcel71
Posts: 49
Joined: 2011-04-13T13:57:34-07:00
Authentication code: 8675308

Re: Unable to read font Arial-Bold

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

Re: Unable to read font Arial-Bold

Post by snibgo »

Sorry, I don't know PHP.
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: Unable to read font Arial-Bold

Post 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.
Marcel71
Posts: 49
Joined: 2011-04-13T13:57:34-07:00
Authentication code: 8675308

Re: Unable to read font Arial-Bold

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