[C++] GdiPlus: How to Get Text Extent Pixel Size
#include <GdiPlus.h>
using namespace Gdiplus;
#pragma comment(lib, "Gdiplus.lib")
void GetTextSize(const WCHAR* szText, Gdiplus::Font* font, UINT32& nTextWidth, UINT32& nTextHeight)
{
RectF boundRect;
Gdiplus::Bitmap bmp(4, 4);
Gdiplus::Graphics *g = Gdiplus::Graphics::FromImage(&bmp);
g->MeasureString(szText, (INT)wcslen(szText), font, Gdiplus::PointF(0, 0), &boundRect);
nTextWidth = (UINT32)boundRect.Width;
nTextHeight = (UINT32)boundRect.Height;
delete g;
}