MagickSetFont silently failing?
Posted: 2010-10-09T23:00:08-07:00
I've got IM working for rendering some text using the C api. However setting the font appears to be failing even though it returns true.
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).
Code: Select all
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());
This is happening on both Windows XP (ImageMagick 6.6.0) and Kubuntu Linux (ImageMagick 6.5.7).