siodine
02-12-2005, 05:27 AM
this is a stripped down version of IMessageChars::GetStringLength, all this does is get the width and height of text, its useful for console stuff like making a editline cursor
void GetStringLength( vgui::HFont hCustomFont, int *width, int *height, const char *fmt, ... )
{
va_list argptr;
char data[1024];
int len;
va_start( argptr, fmt );
len = Q_vsnprintf( data, sizeof( data ), fmt, argptr );
va_end(argptr);
data[1023] = 0;
*width = g_pDraw->DrawTextLen( hCustomFont, (char *)data );
*height = g_pSurface->GetFontTall( hCustomFont );
}
credits: valve sdk
void GetStringLength( vgui::HFont hCustomFont, int *width, int *height, const char *fmt, ... )
{
va_list argptr;
char data[1024];
int len;
va_start( argptr, fmt );
len = Q_vsnprintf( data, sizeof( data ), fmt, argptr );
va_end(argptr);
data[1023] = 0;
*width = g_pDraw->DrawTextLen( hCustomFont, (char *)data );
*height = g_pSurface->GetFontTall( hCustomFont );
}
credits: valve sdk