我尝试了一点代码:
try {
InitializeMagick(*argv);
//create a base image
Image image("400x100",font_color);
//construct a drawing list
std::list<Magick::Drawable> drawList;
//add tracing elements
drawList.push_back(DrawableRectangle(0,0,400,100)); // Draw a rectangle ( the sign)
drawList.push_back(DrawableStrokeColor("black")); // Outline Color
drawList.push_back(DrawableFillColor(font_color)); // Fill color
drawList.push_back(DrawableStrokeWidth(5));
drawList.push_back(DrawablePointSize(50));
drawList.push_back(DrawableFont("@Arial"));
drawList.push_back(DrawableStrokeColor(police_color));
drawList.push_back(DrawableText(10,70,ville));
drawList.push_back(DrawableText(300,70,distance));
image.draw(drawList);
image.write(filedest);
}
catch(exception & error_)
{
cout<<"Caught exception : " << error_.what() << endl;
}
但是当我启动程序时出现此错误:
proto.exe:无法读取字体`@ Arial&#39; @ error / annotate.c / RenderFreetype / 1126
答案 0 :(得分:1)
只需将@
符号放在字体名称中即可。 Magick::DrawableFont
方法不需要它。
drawList.push_back(DrawableFont("Arial"));
您可以通过运行identify
实用程序来验证可用的字体。
identify -list font | more