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).