Bounding Rectangle For Text?

Started by
1 comment, last by mameman 16 years, 11 months ago
Hi, Does anyone know of a good way to calculate the EXACT bounding rectangle for some text using any TrueType font?. I've gone through a hole host of techniques (including examining the GDI path) for the font but I've not had ANY success :(. I always seem to be one or two pixels out either on the horizontal or vertical axis. Using Win32/C++ and OGL. ANY ideas/suggestions on how to lance this problem MUCH appreciated. MAMEman.
Advertisement
Perhaps GetTextExtentPoint32() is what you're looking for:

http://msdn2.microsoft.com/en-us/library/ms534223.aspx

Haven't used it myself because I mostly use Delphi for GDI stuff (which offers more convenient and properly named functions for such things, but anyway).
Thanks for the infos prototype but this isn't what I'm looking for!. Probably didn't explain the problem correctly. Anyways let me simplify. Basically try to draw some text at 0, 0 using DrawText(), TextOut() or any other GDI function you care to use, and try to put a rectangle around it WITHOUT leaving any space on the left, top, right and bottom sides of the text. Note this assumes that you can use any TrueType font and memory permitting any pointsize too.

Hope this simplifies,

MAMEman.

This topic is closed to new replies.

Advertisement