Page 1 of 1

PerlMagick (6.40) Annotate - unable to change fonts

Posted: 2008-07-25T15:45:02-07:00
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 that 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 40
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 40
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 40
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 40


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

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

Posted: 2008-07-25T20:57:32-07:00
by fmw42
I am not knowledgeable about PerlMagick and am not trying to dissuade you from asking here, but you may get a more prompt reply by inquiring on the PerlMagick forum rather than here, which is mostly for command line processing. See viewforum.php?f=7

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

Posted: 2008-07-26T06:16:13-07:00
by wrnelson55
fmw43 thank you, I have reposted under PerlMagick. Being new to this forum I simply chose the wrong entry.

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

Posted: 2008-07-27T17:26:09-07:00
by anthony
The IM Examples shell script
http://www.imagemagick.org/Usage/scripts/show_fonts
will do the same job, though each image uses a fixed string for each font, with just the font label showing the font name. It is based on techniques discussed in the "montage" section of IM Examples, specifically http://www.imagemagick.org/Usage/montage/#reuse

The input font names can be IM defined names, or TTF files. I often use this to display a whole directory of fonts to pick the one I want to use.

I did not use the font name itself as not all fonts are 'readable'. many are symbol fonts, that do not show readable letters.