DrawSetFont not working, but still returning true
Posted: 2008-08-24T19:19:48-07:00
On Ubuntu Desktop 8.04, I'm trying to annotate an image and everything seems to work fine, except I cannot seem to set the font face. This happens across two different installs, one of which is using MagickWand and the other using Imagick. The code demonstrating this:
Nothing fails, and I indeed get back an image annotated with text. The ttf file specified exists and is readable (chmodded to 777), and it works fine with GD. The font size is set correctly, and I can even use a PixelWand to set the text color, but no matter what ttf file I specify, it uses a default font face. And the DrawSetFont function returns a true value, as does Imagick's setFont method.
I had to compile ImageMagick from source, and had to disable OpenMP, could this have something to do with it? If not, what could be the problem?
Code: Select all
<?php
// get current path
$path = dirname(__FILE__);
// die if font permissions are bad
if(!is_readable("{$path}/sample/FreeMono.ttf")) {
die('Font is not readable!');
}
if(extension_loaded('imagick')) {
$resource = new Imagick();
$status = $resource->readImage("{$path}/sample/scale.gif");
$draw = new ImagickDraw();
$status = $draw->setFont("{$path}/sample/FreeMono.ttf");
if($status !== TRUE) die('DrawSetFont failed!');
$status = $draw->setFontSize(20.0);
if($status !== TRUE) die('DrawSetFontSize failed!');
$status = $resource->annotateImage($draw, 0, 50, 0, 'The quick fox jumps over the lazy dog.');
header('Content-Type: image/gif');
echo $resource;
exit;
}
if(extension_loaded('magickwand')) {
$resource = NewMagickWand();
$status = MagickReadImage($resource, "{$path}/sample/scale.gif");
$draw = NewDrawingWand();
$status = DrawSetFont($draw, "{$path}/sample/FreeMono.ttf");
if($status !== TRUE) die('DrawSetFont failed!');
DrawSetFontSize($draw, 20.0);
$status = MagickAnnotateImage($resource, $draw, 0, 50, 0, 'The quick fox jumps over the lazy dog.');
header('Content-Type: image/gif');
echo MagickEchoImageBlob($resource);
exit;
}
die('No IM extension loaded');
I had to compile ImageMagick from source, and had to disable OpenMP, could this have something to do with it? If not, what could be the problem?