CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    4

    Finding size of certain character

    How can I determine the pixel dimentions of a certain character of a certain font with Win32 API?


  2. #2
    Join Date
    May 1999
    Location
    Republic of Korea
    Posts
    74

    Re: Finding size of certain character

    Check GetCharABCWidths function.



  3. #3
    Join Date
    May 1999
    Location
    Farnborough, Hants, England
    Posts
    710

    Re: Finding size of certain character

    If hFont is the font you want to check, and you have a window hMyWindow, then use:

    --- char cString[] = "X";
    HDC hDC ;
    HFONT hFntOld ;
    int iLength ;
    SIZE sFontSize ;

    hDC = GetDC(hMyWindow);
    hFntOld = (HFONT)SelectObject(hDC, hFont);

    iLength = strlen(cString);
    GetTextExtentPoint32(hDC, cString, iLength, &sFontSize);

    // Now, sFontSize.cx has the width and sFontSize.cy has the height
    // of "X" in your font.

    // Tidy up.
    SelectObject(hDC, hFntOld);
    ReleaseDC(hMyWindow, hDC);




    ---

    Does this help?



    --
    Jason Teagle
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured