Thank you for your reply. I think the QueryFont() call you are referring to in the C++ code is Image::fontTypeMetrics(..). When I call this, the information returned is not quite what I need.
Code: Select all
Image myimage("100x50", "black");
myimage.magick("PNG");
myimage.antiAlias(false);
myimage.matteColor("yellow");
myimage.frame("1x1");
myimage.fillColor("white");
myimage.fontPointsize(16);
myimage.font("Arial");
myimage.boxColor("orange");
TypeMetric typemetric;
myimage.fontTypeMetrics("a", &typemetric);
cout<<"Width: "<<typemetric.textWidth()<<" Height: "<<typemetric.textHeight();
cout<<" Ascent: "<<typemetric.ascent()<<" Descent: "<<typemetric.descent();
cout<<" MaxHorizAdvance: "<<typemetric.maxHorizontalAdvance()<<endl;
myimage.draw( DrawableText(1, 16, "a"));
myimage.fontTypeMetrics("f", &typemetric);
cout<<"Width: "<<typemetric.textWidth()<<" Height: "<<typemetric.textHeight();
cout<<" Ascent: "<<typemetric.ascent()<<" Descent: "<<typemetric.descent();
cout<<" MaxHorizAdvance: "<<typemetric.maxHorizontalAdvance()<<endl;
myimage.draw( DrawableText(14, 16, "f"));
myimage.fontTypeMetrics("g", &typemetric);
cout<<"Width: "<<typemetric.textWidth()<<" Height: "<<typemetric.textHeight();
cout<<" Ascent: "<<typemetric.ascent()<<" Descent: "<<typemetric.descent();
cout<<" MaxHorizAdvance: "<<typemetric.maxHorizontalAdvance()<<endl;
myimage.draw( DrawableText(22, 16, "g"));
myimage.write("forumpic.png");
In my example, the only value that varies from glyph to glyph is width. However, the glyphs clearly are not all the same height (see output image). "a", "f", and "g" do not appear to have the same ascent, descent, and height, yet fontTypeMetrics() says they do.
This is the screen output of the code.
This is the image the code creates.
How can I obtain metric information like what is shown in this pic?