// Create POV file do do TrueType credits #include #include #include HINSTANCE hiApp; BOOL CALLBACK dlgProcMain( HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam); void WriteString(HWND hwEdit); int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { hiApp = hInstance; DialogBox( hiApp, "IDD_DIALOG1", NULL, dlgProcMain ); return 0; } BOOL CALLBACK dlgProcMain( HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch( uMsg ) { case WM_INITDIALOG: SetFocus( GetDlgItem( hwndDlg, 103)); return 0; case WM_COMMAND: switch( wParam ) { case 102: // exit EndDialog(hwndDlg,0); break; case 101: // write file { WriteString(GetDlgItem( hwndDlg, 103)); SetFocus( GetDlgItem( hwndDlg, 103)); } break; } break; } return 0; } void WriteString(HWND hwEdit) { LOGFONT lf = { 111,0,0,0,FW_NORMAL,0,0,0,ANSI_CHARSET,OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_PITCH|FF_DONTCARE, "Arial" }; HFONT hfFont,hfOld; HDC hdc; SIZE size; int n,len; int nLines; char str[100]; FILE *f; f = fopen("ttf.inc","wt"); hdc = CreateCompatibleDC( NULL ); hfFont = CreateFontIndirect( &lf ); hfOld = SelectObject( hdc, hfFont ); nLines = SendMessage( hwEdit, EM_GETLINECOUNT,0,0); for( n = 0; n < nLines; n++ ) { str[0] = 99; len = SendMessage(hwEdit, EM_GETLINE, n, (LPARAM)str ); if( len > 0 ) { str[len] = 0; GetTextExtentPoint32( hdc,str,strlen(str),&size); fprintf( f, "text{ttf Font ,"); fprintf( f, "\"%s\"", str); fprintf( f, ",.2,0 texture{TTF_T} translate"); fprintf( f, "<%f,%f,0>}\n", (double)size.cx / -200,8.0-n); } } fclose(f); SelectObject( hdc, hfOld ); DeleteDC(hdc ); DeleteObject( hfFont ); }