How to find text length in pixels?

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
cicada
Posts: 4
Joined: 2012-06-07T00:36:33-07:00
Authentication code: 13

How to find text length in pixels?

Post by cicada » 2012-06-07T06:24:51-07:00

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.

el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: How to find text length in pixels?

Post by el_supremo » 2012-06-07T09:24:29-07:00

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
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to find text length in pixels?

Post by anthony » 2012-06-19T17:32:08-07:00

For command line see..
Determining Font Metrics, without using an API
http://www.imagemagick.org/Usage/text/#font_info
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Post Reply