Page 1 of 1

Font availability feedback in Magick++

Posted: 2011-09-27T05:31:53-07:00
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());
}