Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
std::string sample="abcdefghijklmnopqrstuvwxyz";
//pick the appropriate font
std::string fontName;
#ifdef _WIN32
if (Type==VARIABLE_SERIF)
fontName="Times New Roman";
else if (Type==VARIABLE_SANSERIF)
fontName="Arial";
else if (Type==FIXED_SERIF)
fontName="Courier New";
#else
if (Type==VARIABLE_SERIF)
fontName="Serif";
else if (Type==VARIABLE_SANSERIF)
fontName="Sans Serif";
else if (Type==FIXED_SERIF)
fontName="Monospace";
#endif
else
MPMA::ErrorReport()<<"Unhandled font type in FontCacheEntry::Build: "<<Type<<"\n";
//render the string
MagickCore::MagickWand *wand=MagickCore::NewMagickWand();
if (!MagickCore::MagickSetFont(wand, fontName.c_str()))
MPMA::ErrorReport()<<"In FontCacheEntry::Build, MagickSetFont failed for "<<fontName<<"\n";
MagickCore::MagickSetSize(wand, 100, 0);
MagickCore::MagickSetPointsize(wand, Size);
MagickCore::MagickSetOption(wand, "fill", "black");
MagickCore::MagickSetOption(wand, "background", "transparent");
MagickCore::MagickSetGravity(wand, MagickCore::NorthGravity);
MagickCore::MagickReadImage(wand, (std::string("caption:")+sample).c_str());
In this case, MagickCore::MagickSetFont returns true as if it succeeded, but has no effect at all. Everything else (SetPointSize, etc) is working fine.
This is happening on both Windows XP (ImageMagick 6.6.0) and Kubuntu Linux (ImageMagick 6.5.7).
MagickSetFont() assigns the font as a string to an internal structure and returns MagickTrue. MagickFalse is returned only if the font is null or empty.
I see. The documentation at http://www.imagemagick.org/api/magick-p ... ickSetFont is misleading then: "MagickSetFont() sets the font associated with the MagickWand.". It's worded the same way as the others which actually have an effect: "MagickSetPointsize() sets the font pointsize associated with the MagickWand.".
What's the correct method to use to set the font then?
From looking through RenderType in annotate.c, it looks like it calls GetTypeInfo on draw_info->font (which fails when font is a name like "Times New Roman") and GetTypeInfoByFamily on draw_info->family. I see in there that it tries to load (using GetTypeInfoByFamily) strings "arial" and "helvetica"... it looks like there just needs to be an accessor to set draw_info->family... does that sound right?
Is this fixed in IM 6.8.9-10 because I also can see there is no effect of MagickSetFont in my case. I am doing MagickReadImage(wand, "pango:some text") before this I am setting some font, which is not taking any effect, even if I set some random string in the place of font name then also nothing happens, I mean it returns true. One strange thing I noticed is if you don't set the font then text shrinks to smaller font size automatically and when you set the font it comes back to your set point size. How can we set font in this case. Please help