Page 1 of 1

How to find text length in pixels?

Posted: 2012-06-07T06:24:51-07:00
by cicada
Hi,

Need help with the following:

1.
I need to convert the following string to a bmp image:
"Hello World".

The spacing between the words "Hello" and "World" needs to be 20 pixels. How do I accomplish this spacing using MagickWand?

2.
I need to display the text "Hello" with the rightmost end at a distance of 20 pixels from the right edge of the image. Any ideas on how to do this using MagickWand?


Thanks!
Cathy.

Re: How to find text length in pixels?

Posted: 2012-06-07T09:24:29-07:00
by el_supremo
The MagickQueryFontMetrics(mw, dw, text) function returns metric information for the given text string from which you can compute where the strings should be placed.
See my fontmetrics example.

Pete

Re: How to find text length in pixels?

Posted: 2012-06-19T17:32:08-07:00
by anthony
For command line see..
Determining Font Metrics, without using an API
http://www.imagemagick.org/Usage/text/#font_info