user565739
user565739

Reputation: 1332

Geometry of fonts

If I want to draw a text on a control, I can get "a bounding rectangle" first and place it at an appropriate place (using GetTextExtentPoint32 function).

But I also need to know where some baselines are, e.g the two red lines in the picture. (Their positions are calculated respect to the top of the bounding rectangle.)

I didn't figure a way to get these information. Please help.

enter image description here

Upvotes: 1

Views: 98

Answers (1)

Jonathan Potter
Jonathan Potter

Reputation: 37142

The function GetTextMetrics will get you this. Select your font into the DC first, then call GetTextMetrics. The fields tmAscent and tmDescent of the TEXTMETRIC structure are probably the ones you need.

Upvotes: 4

Related Questions