Font availability feedback in Magick++

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Ghealron
Posts: 2
Joined: 2011-09-15T05:01:53-07:00
Authentication code: 8675308

Font availability feedback in Magick++

Post by Ghealron »

Hi,

It would be really helpful if the Magick++ API provided some way to determine what fonts are available. I know this can be done at the command line, but not in the API so far as I know. It would also be helpful if there was a safe way to determine if a font can be used. I am creating images using Image.read("label:<text>");. I have no way to know if the font I put in Image.font() will work until .read throws an exception.

Also, after the exception is thrown it is difficult/impossible to recover the object. I keep getting this error: magick/semaphore.c:288: LockSemaphoreInfo: Assertion `semaphore_info != (SemaphoreInfo *) ((void *)0)' failed.

Finally, it would be helpful if there was an operator== for TypeMetric objects. I am comparing them before and after setting the font name as a workaround -- if the metrics don't change, the font is probably invalid. Here is my operator== implementation which I release without license, obligation or warranty:

Code: Select all

bool operator==(const TypeMetric &left, const TypeMetric &right) {
	return (left.ascent() == right.ascent()) &&
	       (left.descent() == right.descent()) &&
	       (left.textWidth() == right.textWidth()) &&
	       (left.textHeight() == right.textHeight()) &&
	       (left.maxHorizontalAdvance() == right.maxHorizontalAdvance());
}
Post Reply