int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { CRLog::setFileLogger( "crengine.log" ); CRLog::setLogLevel( CRLog::LL_TRACE ); // TODO: Place code here. MSG msg; HACCEL hAccelTable; //make_dither_table(); //TestWol(); /* LVStreamRef zipfile = LVOpenFileStream( L"zip_test.zip", LVOM_READ ); if (!zipfile.isNull()) { LVContainerRef zip = LVOpenArchieve( zipfile ); if (!zip.isNull()) { LVStreamRef log = LVOpenFileStream("ziptest.log", LVOM_WRITE); for (int i=0; i<zip->GetObjectCount(); i++) { const LVContainerItemInfo * item = zip->GetObjectInfo(i); if (item) { // *log << UnicodeToLocal( item->GetName() ); *log << lString8::itoa( (int)item->GetSize() ); LVStreamRef unpstream = zip->OpenStream( item->GetName(), LVOM_READ ); if (!unpstream.isNull()) { *log << "\n arc stream opened ok \n"; LVStreamRef outstream = LVOpenFileStream( item->GetName(), LVOM_WRITE ); if ( !outstream.isNull() ) { int copiedBytes = (int)LVPumpStream( outstream, unpstream ); *log << " copied " << lString8::itoa(copiedBytes) << " bytes\n"; } else { *log << " error opening out stream\n"; } } } } } } */ lString8 exe_dir; char exe_fn[MAX_PATH+1]; GetModuleFileNameA( NULL, exe_fn, MAX_PATH ); int last_slash = -1; int i; for (i=0; exe_fn[i]; i++) if (exe_fn[i]=='\\' || exe_fn[i]=='/') last_slash = i; if (last_slash>0) exe_dir = lString8( exe_fn, last_slash ); // init hyphenation manager initHyph( (exe_dir + "\\russian_EnUS_hyphen_(Alan).pdb").c_str() ); lString8 fontDir = exe_dir; fontDir << "\\fonts"; // init bitmap font manager InitFontManager( fontDir ); // Load font definitions into font manager // fonts are in files font1.lbf, font2.lbf, ... font32.lbf #if (USE_FREETYPE==1) LVContainerRef dir = LVOpenDirectory( LocalToUnicode(fontDir).c_str() ); if ( !dir.isNull() ) for ( i=0; i<dir->GetObjectCount(); i++ ) { const LVContainerItemInfo * item = dir->GetObjectInfo(i); lString16 fileName = item->GetName(); if ( !item->IsContainer() && fileName.length()>4 && lString16(fileName, fileName.length()-4, 4)==L".ttf" ) { lString8 fn = UnicodeToLocal(fileName); printf("loading font: %s\n", fn.c_str()); if ( !fontMan->RegisterFont(fn) ) { printf(" failed\n"); } } } //fontMan->RegisterFont(lString8("arial.ttf")); #else #if (USE_WIN32_FONTS==0) #define MAX_FONT_FILE 32 for (i=0; i<MAX_FONT_FILE; i++) { char fn[32]; sprintf( fn, "font%d.lbf", i ); fontMan->RegisterFont( lString8(fn) ); } #endif #endif //LVCHECKPOINT("WinMain start"); text_view = new LVDocView; // stylesheet can be placed to file fb2.css // if not found, default stylesheet will be used lString8 css = readFileToString( (exe_dir + "\\fb2.css").c_str() ); if (css.length() > 0) text_view->setStyleSheet( css ); //LVCHECKPOINT("WinMain before loads"); if (!fontMan->GetFontCount()) { //error char str[1000]; #if (USE_FREETYPE==1) sprintf(str, "Cannot open font file(s) fonts/*.ttf \nCannot work without font\nPlace some TTF files to font\\ directory" ); #else sprintf(str, "Cannot open font file(s) font#.lbf \nCannot work without font\nUse FontConv utility to generate .lbf fonts from TTF" ); #endif MessageBoxA( NULL, str, "CR Engine :: Fb2Test -- fatal error!", MB_OK); return 1; } lString8 cmdline(lpCmdLine); cmdline.trim(); if ( cmdline == "test_format" ) { testFormatting(); return 1; } if (cmdline.empty()) { cmdline = OpenFileDialog( NULL ); //cmdline = "example2.fb2"; } if ( cmdline.empty() ) return 2; if ( !text_view->LoadDocument( cmdline.c_str() )) { //error char str[100]; sprintf(str, "Cannot open document file %s", cmdline.c_str()); MessageBoxA( NULL, str, "CR Engine :: Fb2Test -- fatal error!", MB_OK); return 1; } //LVCHECKPOINT("WinMain after loads"); // Initialize global strings MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_FONTTEST); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } delete text_view; ShutdownFontManager(); return msg.wParam; }
static void testPrintf(FILE* f) { testLongLine(f); testFormatting(f); }
void testObj::test<5>(void) { testFormatting(Priority::FATAL, "FATAL"); }
void testObj::test<4>(void) { testFormatting(Priority::ERROR, "ERROR"); }
void testObj::test<3>(void) { testFormatting(Priority::WARN, "WARN "); }
void testObj::test<2>(void) { testFormatting(Priority::INFO, "INFO "); }
void testObj::test<1>(void) { testFormatting(Priority::DEBUG, "DEBUG"); }