GetTextExtentPoint32 API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fromethius
    New Member
    • Apr 2007
    • 38

    GetTextExtentPoint32 API

    --------------------------------------------------------------------------------

    When using this with the DrawText API, I make the rectangle that the text is contained in the width of the return value of GetTextExtentPo int32


    I know I am using the right parameters, but sometimes the rectangle is way too big (over 15 pixels wider than the actual width of the text) and sometimes the rectangle is too small.



    It seems that this API is a little.. screwed up perhaps? If I input "WWWWWWWWWW WW" for example, the rectangle containing the text is around 20 pixels too big but if I input "iiiiiiiiii ii", the rectangle is around 20 pixels too small.



    I tried using SetTextCharacte rExtra, but that just screwed things up even more. I'm looking for a more accurate and precise way to set the rectangle's width via the width of the text. Btw, there will never be any spaces, numbers, or symbols as the text. The width of the text will only ever contain the 26 lowercase letters and 26 uppercase letters.



    Thanks for any help. :)
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    From the Microsoft docs:
    Originally posted by Microsoft
    Because some devices kern characters, the sum of the extents of the characters in a string does not always equal to the extent of the string.

    Comment

    Working...