Reputation: 25163
I have a variable width word that I would like to center in a fixed sized box. How can I calculate the width of the text so that I know how far the left offset should be?
Upvotes: 2
Views: 625
Reputation: 8143
You did not specify your programming language so I am assuming you are using C.
You can determine the width with the MagickQueryFontMetrics methods (http://www.graphicsmagick.org/wand/magick_wand.html#magickqueryfontmetrics) this returns a double array containing the following information:
Or if you could use use the GetTypeMetrics method that gives you the information in a nice struct:
Upvotes: 1