Hi,
I convert text to image both from command line and using MagickWand API.
I noticed difference for some fonts.
Here's an example, try to generate image for text, say "7", using this font:
http://www.atwss.com/vav/trikotnr1.ttf
For pointsize = 300, command line produces 187x251 pixels image, API returns size 187x352. Moreover vertical shift is different. I take into account text descender, when drawing text from API.
Here's example images,
for command line: http://www.atwss.com/vav/7.png
and for API: http://www.atwss.com/vav/test1.png
MagickQueryFontMetrics() differs from command line
Sure, here it is:
Code: Select all
convert -background none -pointsize 300 -font trikotnr1.ttf label:7 7.png
Code: Select all
<?php
$mgck_wnd = NewMagickWand();
$drw_wnd = NewDrawingWand();
DrawSetFont($drw_wnd, 'trikotnr1.ttf');
DrawSetFontSize($drw_wnd, 300);
list( , , $text_ascent, $text_descent, $text_width, $text_height, $max_horizontal_advance) = MagickQueryFontMetrics($mgck_wnd, $drw_wnd, '7');
MagickNewImage($mgck_wnd, $text_width, $text_height, 'none');
MagickAnnotateImage($mgck_wnd, $drw_wnd, 0, $text_height + $text_descent, 0, '7');
MagickSetImageFormat($mgck_wnd, 'png');
MagickWriteImage($mgck_wnd, 'test.png');
DestroyDrawingWand($drw_wnd);
DestroyMagickWand($mgck_wnd);
?>