PerlMagick (6.40) Annotate - unable to change fonts

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
wrnelson55

PerlMagick (6.40) Annotate - unable to change fonts

Post by wrnelson55 »

I am having an issue with the Annotate function of PerlMagick (6.40).
In a test perl module I am requesting a list of the fonts available and walking through the list to generate an image containing the font name, written in that font. The images are created and the text is displayed, however the text appears in the same font in each image.

My script:
my $image;
my $font_image;
my $x = "";
my $i = 0;
$image = Image::Magick->new;
my @fonts = $image->QueryFont();
for ($i=0;$i<scalar @fonts;$i++)
{
$font_image = Image::Magick->new;
$font_image->ReadImage('xc:white');
$font_image->Set(debug=>'Annotate');
$x = $font_image->Resize(width=>640, height=>640);
warn "$x" if "$x";
my $text = $fonts[$i];
$x = $font_image->Annotate(font=>$text, x=>10, y=>160, fill=>'green',
text=>$text);
warn "$x" if "$x";
my $full_preview_name := "/appl/images/fonts/a_".$text.".gif";
$x = $font_image->Write(filename=>$full_preview_name,
compression=>'NONE');
warn "$x" if "$x";
}


With debug set for Annotate, I receive these msgs that indicate it is selecting the correct font and I have checked that each of these file exist.

2008-07-25T17:03:30-05:00 0:11 8.670u 6.4.1 Annotate PerlMagick[26371]: annotate.c/unknown/1789/Annotate
Font /usr/share/fonts/default/Type1/n022004l.pfb; pointsize 12
2008-07-25T17:03:31-05:00 0:12 9.610u 6.4.1 Annotate PerlMagick[26371]: annotate.c/unknown/1789/Annotate
Font /usr/share/fonts/default/Type1/n022024l.pfb; pointsize 12
2008-07-25T17:03:31-05:00 0:12 9.620u 6.4.1 Annotate PerlMagick[26371]: annotate.c/unknown/1789/Annotate
Font /usr/share/fonts/default/Type1/n022024l.pfb; pointsize 12
2008-07-25T17:03:32-05:00 0:13 10.560u 6.4.1 Annotate PerlMagick[26371]: annotate.c/unknown/1789/Annotate
Font /usr/share/fonts/default/Type1/n022023l.pfb; pointsize 12


So, any ideas why the text annotation in each of the images never changes fonts?
Any help is greatly appreciated
Craig-IM

Re: PerlMagick (6.40) Annotate - unable to change fonts

Post by Craig-IM »

Since you are just testing this, I would print your $text or $fonts[$i] variable just before you annotate. Then you know what font you are trying to use.

Normally when I set a font using annotate I give it the complete path to the font file.

I believe if annotate can not find the font it just uses a default font.

Craig
wrnelson55

Re: PerlMagick (6.40) Annotate - unable to change fonts

Post by wrnelson55 »

I had been printing the $text and $fonts[$i] until i was able to start creating images. Now the images are being created and the filename and contents use the font name. So I see the fonts it is trying to use for each image.
I just tried hard coding the full path and filename when setting the font and get the same result.

The type-ghostscript.xml file seems to be corect as it contains the the fonts that I get back from my Query and it points to the Type1 directory that contains the fonts.

Thanks for your suggestion.
Post Reply