Hello,
I recently received the following bug report http://pecl.php.net/bugs/bug.php?id=19907, which I am not sure about. Should the QueryFontMetrics honour resolution?
QueryFontMetrics / Resolution
QueryFontMetrics / Resolution
Mikko Koppanen
My blog: http://valokuva.org
My blog: http://valokuva.org
Re: QueryFontMetrics / Resolution
Imagick is missing a method to set the drawing / annotation resolution. $im->setResolution() sets the image resolution. Imagick needs a $draw->setResolution() method that sets the draw_info->density member. Since density is a string, you simply take the setResolution() float values and convert them to a string and assign it to the density member of the DrawInfo structure. Imagick should also have a $draw->setPointsize() method as well.
Re: QueryFontMetrics / Resolution
There's no actual API method to set the draw resolution though, right? And, of course, using the Magick wand setresolution would cause an assertion failure for being a drawing wand.
Re: QueryFontMetrics / Resolution
Also, I'm not sure if this is related, but there seems to be a wild correlation between the textheight, and the boundingbox height. For example, here's a sample fontmetrics output of "Hello World", with resolution set to 300, and point size of 72 (I've quickly knocked together a DrawSetResolution function in drawing-wand.c). It should be around the equivalent of 1 inch.
array(10) {
["characterWidth"]=>
float(300)
["characterHeight"]=>
float(300)
["ascender"]=>
float(272)
["descender"]=>
float(-64)
["textWidth"]=>
float(1541)
["textHeight"]=>
float(345)
["maxHorizontalAdvance"]=>
float(600)
["boundingBox"]=>
array(4) {
["x1"]=>
float(0)
["y1"]=>
float(-3)
["x2"]=>
float(279)
["y2"]=>
float(215)
}
["originX"]=>
float(1545)
["originY"]=>
float(0)
}
The interesting thing is, after drawing the image, trimming, and identify'ing the output, the height of the image is 218px. the height of the bounding box in the queryfontmetrics output above, and not the textHeight.
Adding in a character with a descender lowers the y1 value as expected, but the sum of y1 and y2 are still not equal with the textHeight.
array(10) {
["characterWidth"]=>
float(300)
["characterHeight"]=>
float(300)
["ascender"]=>
float(272)
["descender"]=>
float(-64)
["textWidth"]=>
float(1541)
["textHeight"]=>
float(345)
["maxHorizontalAdvance"]=>
float(600)
["boundingBox"]=>
array(4) {
["x1"]=>
float(0)
["y1"]=>
float(-3)
["x2"]=>
float(279)
["y2"]=>
float(215)
}
["originX"]=>
float(1545)
["originY"]=>
float(0)
}
The interesting thing is, after drawing the image, trimming, and identify'ing the output, the height of the image is 218px. the height of the bounding box in the queryfontmetrics output above, and not the textHeight.
Adding in a character with a descender lowers the y1 value as expected, but the sum of y1 and y2 are still not equal with the textHeight.