rtText::rtText() { // VBO glGenBuffers(1, &textVertexBuffer); glGenBuffers(1, &textTexCoordBuffer); // VAO glGenVertexArrays(1, &textVertexArrayObject); glBindVertexArray(textVertexArrayObject); { glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, textVertexBuffer); glVertexAttribPointer( 0, // attribute 0. No particular reason for 0, but must match the layout in the shader. 3, // size GL_FLOAT, // type GL_FALSE, // normalized? 0, // stride (void*)0 // array buffer offset ); glBindBuffer(GL_ARRAY_BUFFER, 0); glEnableVertexAttribArray(1); // UV glBindBuffer(GL_ARRAY_BUFFER, textTexCoordBuffer); glVertexAttribPointer( 1, // attribute. No particular reason for 1, but must match the layout in the shader. 2, // size : U+V => 2 GL_FLOAT, // type GL_FALSE, // normalized? 0, // stride (void*)0 // array buffer offset ); glBindBuffer(GL_ARRAY_BUFFER, 0); } glBindVertexArray(0); // Load TTF File fFileBuffer = LoadFontFile(rtConstants::IconFontFile.c_str(), fFontFileSize); InitFontLibrary(); // Default font size SetFontSize(rtConstants::TextFontSize); // create texture glActiveTexture(GL_TEXTURE0); // select 0 glGenTextures(1, &fTextureText); glBindTexture(GL_TEXTURE_2D, fTextureText); { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ALIGNMENT, 1); } glBindTexture(GL_TEXTURE_2D, 0); }
bool ResourceFont::Load() { if ( LoadFontFile( GetFilename().GetFullPath() ) ) { BuildLists(); m_State = ResourceState::Loaded; return true; } else { return false; } }
/** * \brief Loads fonts from font files in the specified directory. * * Non-recursive function called by the recursive MythFontManager::LoadFonts() * function. * * \param directory The directory to scan * \param registeredFor The user of the font. */ void MythFontManager::LoadFontsFromDirectory(const QString &directory, const QString ®isteredFor) { if (directory.isEmpty() || directory == "/" || registeredFor.isEmpty()) return; LOG(VB_FILE, LOG_DEBUG, LOC + QString("Scanning directory '%1' for font files.").arg(directory)); QDir dir(directory); QStringList nameFilters = QStringList() << "*.ttf" << "*.otf" << "*.ttc"; QStringList fontFiles = dir.entryList(nameFilters); for (QStringList::const_iterator it = fontFiles.begin(); it != fontFiles.end(); ++it) { LoadFontFile(dir.absoluteFilePath(*it), registeredFor); } }
void CGeneral::LoadFonts() { // Small fonts m_fontKai = LoadFontFile(FONTS_DIR "gkai00mp.ttf", 24); // Chinese fonts (Kai Ti) m_fontBrush = LoadFontFile(FONTS_DIR "brush.ttf", 24); // English/Number fonts // Large fonts m_fontKaiL = LoadFontFile(FONTS_DIR "gkai00mp.ttf", 36); // Chinese fonts (Kai Ti) m_fontBrushL = LoadFontFile(FONTS_DIR "brush.ttf", 36); // English/Number fonts // Huge fonts m_fontKaiH = LoadFontFile(FONTS_DIR "gkai00mp.ttf", 72); // Chinese fonts (Kai Ti) m_fontBrushH = LoadFontFile(FONTS_DIR "brush.ttf", 72); // English/Number fonts }
bool TopedApp::OnInit() { // DATC = DEBUG_NEW DataCenter(); initDBLib(); Toped = DEBUG_NEW tui::TopedFrame( wxT( "wx_Toped" ), wxPoint(50,50), wxSize(1200,900) ); console::ted_log_ctrl *logWindow = DEBUG_NEW console::ted_log_ctrl(Toped->logwin()); delete wxLog::SetActiveTarget(logWindow); CmdList = Toped->cmdlist(); // Create the main block parser block - WARNING! blockSTACK structure MUST already exist! CMDBlock = DEBUG_NEW parsercmd::cmdMAIN(); tellstdfunc::initFuncLib(Toped, Toped->view()); InitInternalFunctions(static_cast<parsercmd::cmdMAIN*>(CMDBlock)); SetTopWindow(Toped); Toped->Show(TRUE); GetFontDir(); if (!LoadFontFile("arial1")) return FALSE; GetLogDir(); if (!GetLogFileName()) return FALSE; bool recovery_mode = false; if (CheckCrashLog()) { wxMessageDialog* dlg1 = DEBUG_NEW wxMessageDialog(Toped, wxT("Last session didn't exit normally. Start recovery?"), wxT("Toped"), wxYES_NO | wxICON_WARNING); if (wxID_YES == dlg1->ShowModal()) recovery_mode = true; else tell_log(console::MT_WARNING,"Recovery rejected."); dlg1->Destroy(); if (!recovery_mode) SaveIgnoredCrashLog(); } if (recovery_mode) { tell_log(console::MT_WARNING,"Starting recovery ..."); wxString inputfile; inputfile << wxT("#include \"") << logFileName.c_str() << wxT("\""); Console->parseCommand(inputfile, false); tell_log(console::MT_WARNING,"Exit recovery mode."); static_cast<parsercmd::cmdMAIN*>(CMDBlock)->recoveryDone(); LogFile.init(std::string(logFileName.mb_str()), true); } else { LogFile.init(std::string(logFileName.mb_str())); // wxLog::AddTraceMask("thread"); if (1 < argc) { wxString inputfile; for (int i=1; i<argc; i++) { inputfile.Clear(); inputfile << wxT("#include \"") << argv[i] << wxT("\""); Console->parseCommand(inputfile); } } } tell_log(console::MT_WARNING,"Please report a bugs to [email protected] or [email protected]"); return TRUE; }
BOOLEAN InitializeFonts( ) { //INT16 zWinFontName[128]; // unused (jonathanl) //COLORVAL Color; // usused (jonathanl) // Initialize fonts // gpLargeFontType1 = LoadFontFile( "FONTS\\lfont1.sti" ); gpLargeFontType1 = LoadFontFile( "FONTS\\LARGEFONT1.sti" ); gvoLargeFontType1 = GetFontObject( gpLargeFontType1 ); CHECKF( CreateFontPaletteTables( gvoLargeFontType1 ) ); // gpSmallFontType1 = LoadFontFile( "FONTS\\6b-font.sti" ); gpSmallFontType1 = LoadFontFile( "FONTS\\SMALLFONT1.sti" ); gvoSmallFontType1 = GetFontObject( gpSmallFontType1 ); CHECKF( CreateFontPaletteTables( gvoSmallFontType1 ) ); // gpTinyFontType1 = LoadFontFile( "FONTS\\tfont1.sti" ); gpTinyFontType1 = LoadFontFile( "FONTS\\TINYFONT1.sti" ); gvoTinyFontType1 = GetFontObject( gpTinyFontType1 ); CHECKF( CreateFontPaletteTables( gvoTinyFontType1 ) ); // gp12PointFont1 = LoadFontFile( "FONTS\\font-12.sti" ); gp12PointFont1 = LoadFontFile( "FONTS\\FONT12POINT1.sti" ); gvo12PointFont1 = GetFontObject( gp12PointFont1 ); CHECKF( CreateFontPaletteTables( gvo12PointFont1 ) ); // gpClockFont = LoadFontFile( "FONTS\\DIGI.sti" ); gpClockFont = LoadFontFile( "FONTS\\CLOCKFONT.sti" ); gvoClockFont = GetFontObject( gpClockFont ); CHECKF( CreateFontPaletteTables( gvoClockFont ) ); // gpCompFont = LoadFontFile( "FONTS\\compfont.sti" ); gpCompFont = LoadFontFile( "FONTS\\COMPFONT.sti" ); gvoCompFont = GetFontObject( gpCompFont ); CHECKF( CreateFontPaletteTables( gvoCompFont ) ); // gpSmallCompFont = LoadFontFile( "FONTS\\scfont.sti" ); gpSmallCompFont = LoadFontFile( "FONTS\\SMALLCOMPFONT.sti" ); gvoSmallCompFont = GetFontObject( gpSmallCompFont ); CHECKF( CreateFontPaletteTables( gvoSmallCompFont ) ); // gp10PointRoman = LoadFontFile( "FONTS\\Roman10.sti" ); gp10PointRoman = LoadFontFile( "FONTS\\FONT10ROMAN.sti" ); gvo10PointRoman = GetFontObject( gp10PointRoman ); CHECKF( CreateFontPaletteTables( gvo10PointRoman ) ); // gp12PointRoman = LoadFontFile( "FONTS\\Roman12.sti" ); gp12PointRoman = LoadFontFile( "FONTS\\FONT12ROMAN.sti" ); gvo12PointRoman = GetFontObject( gp12PointRoman ); CHECKF( CreateFontPaletteTables( gvo12PointRoman ) ); // gp14PointSansSerif = LoadFontFile( "FONTS\\SansSerif14.sti" ); gp14PointSansSerif = LoadFontFile( "FONTS\\FONT14SANSERIF.sti" ); gvo14PointSansSerif = GetFontObject( gp14PointSansSerif); CHECKF( CreateFontPaletteTables( gvo14PointSansSerif) ); // DEF: Removed. Replaced with BLOCKFONT // gpMilitaryFont1 = LoadFontFile( "FONTS\\milfont.sti" ); // gvoMilitaryFont1 = GetFontObject( gpMilitaryFont1); // CHECKF( CreateFontPaletteTables( gvoMilitaryFont1) ); // gp10PointArial = LoadFontFile( "FONTS\\Arial10.sti" ); gp10PointArial = LoadFontFile( "FONTS\\FONT10ARIAL.sti" ); gvo10PointArial = GetFontObject( gp10PointArial); CHECKF( CreateFontPaletteTables( gvo10PointArial) ); // gp14PointArial = LoadFontFile( "FONTS\\Arial14.sti" ); gp14PointArial = LoadFontFile( "FONTS\\FONT14ARIAL.sti" ); gvo14PointArial = GetFontObject( gp14PointArial); CHECKF( CreateFontPaletteTables( gvo14PointArial) ); // gp10PointArialBold = LoadFontFile( "FONTS\\Arial10Bold2.sti" ); gp10PointArialBold = LoadFontFile( "FONTS\\FONT10ARIALBOLD.sti" ); gvo10PointArialBold = GetFontObject( gp10PointArialBold); CHECKF( CreateFontPaletteTables( gvo10PointArialBold) ); // gp12PointArial = LoadFontFile( "FONTS\\Arial12.sti" ); gp12PointArial = LoadFontFile( "FONTS\\FONT12ARIAL.sti" ); gvo12PointArial = GetFontObject( gp12PointArial); CHECKF( CreateFontPaletteTables( gvo12PointArial) ); // gpBlockyFont = LoadFontFile( "FONTS\\FONT2.sti" ); gpBlockyFont = LoadFontFile( "FONTS\\BLOCKFONT.sti" ); gvoBlockyFont = GetFontObject( gpBlockyFont); CHECKF( CreateFontPaletteTables( gvoBlockyFont) ); // gpBlockyFont2 = LoadFontFile( "FONTS\\interface_font.sti" ); gpBlockyFont2 = LoadFontFile( "FONTS\\BLOCKFONT2.sti" ); gvoBlockyFont2 = GetFontObject( gpBlockyFont2); CHECKF( CreateFontPaletteTables( gvoBlockyFont2) ); gpBlockyFont3 = LoadFontFile( "FONTS\\BLOCKFONT2.sti" ); gvoBlockyFont3 = GetFontObject( gpBlockyFont3); CHECKF( CreateFontPaletteTables( gvoBlockyFont3) ); // gp12PointArialFixedFont = LoadFontFile( "FONTS\\Arial12FixedWidth.sti" ); gp12PointArialFixedFont = LoadFontFile( "FONTS\\FONT12ARIALFIXEDWIDTH.sti" ); gvo12PointArialFixedFont = GetFontObject( gp12PointArialFixedFont ); CHECKF( CreateFontPaletteTables( gvo12PointArialFixedFont ) ); gp16PointArial = LoadFontFile( "FONTS\\FONT16ARIAL.sti" ); gvo16PointArial = GetFontObject( gp16PointArial ); CHECKF( CreateFontPaletteTables( gvo16PointArial ) ); gpBlockFontNarrow = LoadFontFile( "FONTS\\BLOCKFONTNARROW.sti" ); gvoBlockFontNarrow = GetFontObject( gpBlockFontNarrow ); CHECKF( CreateFontPaletteTables( gvoBlockFontNarrow ) ); gp14PointHumanist = LoadFontFile( "FONTS\\FONT14HUMANIST.sti" ); gvo14PointHumanist = GetFontObject( gp14PointHumanist ); CHECKF( CreateFontPaletteTables( gvo14PointHumanist ) ); #if defined( JA2EDITOR ) && defined( ENGLISH ) gpHugeFont = LoadFontFile( "FONTS\\HUGEFONT.sti" ); gvoHugeFont = GetFontObject( gpHugeFont ); CHECKF( CreateFontPaletteTables( gvoHugeFont ) ); #endif // Set default for font system SetFontDestBuffer( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE ); gfFontsInit = TRUE; // ATE: Init WinFont System and any winfonts we wish... if ( iUseWinFonts ) { InitWinFonts( ); } return( TRUE ); }
void Draw(SDL_Surface *screen) { int i, rotation; char *myfont; char mytext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; int x,y,yold; /* Black screen */ ClearScreen(screen); y=0; /* Try all horizontal rotations */ rotation = 0; gfxPrimitivesSetFontRotation(rotation); /* Render all fonts */ for (i=0; i<NUM_SDLGFX_FONTS; i++) { fprintf(stderr,"Drawing Font: size %ix%i, file '%s', %i bytes, rotation %i\n",fontw[i], fonth[i], fontfile[i],fontsize[i], rotation); /* Reset line pos */ x=4; myfont = NULL; if (i>0) { myfont=LoadFontFile(i); } /* Set font data and use it */ gfxPrimitivesSetFont(myfont,fontw[i],fonth[i]); y += fonth[i]; stringRGBA(screen,x,y,fontfile[i],255,255,255,255); x += 100; stringRGBA(screen,x,y,mytext,255,255,255,255); y += 10; if (i>0) { /* Clean up font-data */ free(myfont); } } y += 20; yold = y; rotation = 2; gfxPrimitivesSetFontRotation(rotation); /* Render all fonts */ for (i=0; i<NUM_SDLGFX_FONTS; i++) { fprintf(stderr,"Drawing Font: size %ix%i, file '%s', %i bytes, rotation %i\n",fontw[i], fonth[i], fontfile[i],fontsize[i], rotation); /* Reset line pos */ x=WIDTH - 14; myfont = NULL; if (i>0) { myfont=LoadFontFile(i); } /* Set font data and use it */ gfxPrimitivesSetFont(myfont,fontw[i],fonth[i]); y += fonth[i]; stringRGBA(screen,x,y,fontfile[i],255,255,255,255); x -= 100; stringRGBA(screen,x,y,mytext,255,255,255,255); y += 10; if (i>0) { /* Clean up font-data */ free(myfont); } } y += 20; /* Try all vertical rotations */ rotation = 1; gfxPrimitivesSetFontRotation(rotation); x = 14; /* Render all fonts */ for (i=0; i<NUM_SDLGFX_FONTS; i++) { fprintf(stderr,"Drawing Font: size %ix%i, file '%s', %i bytes, rotation %i\n",fontw[i], fonth[i], fontfile[i],fontsize[i], rotation); /* Reset line pos */ y=yold; myfont = NULL; if (i>0) { myfont=LoadFontFile(i); } /* Set font data and use it */ gfxPrimitivesSetFont(myfont,fontw[i],fonth[i]); x += fonth[i]; stringRGBA(screen,x,y,fontfile[i],255,255,255,255); y += 100; stringRGBA(screen,x,y,mytext,255,255,255,255); x += 10; if (i>0) { /* Clean up font-data */ free(myfont); } } x += 20; rotation = 3; gfxPrimitivesSetFontRotation(rotation); /* Render all fonts */ for (i=0; i<NUM_SDLGFX_FONTS; i++) { fprintf(stderr,"Drawing Font: size %ix%i, file '%s', %i bytes, rotation %i\n",fontw[i], fonth[i], fontfile[i],fontsize[i], rotation); /* Reset line pos */ y=HEIGHT - 14; myfont = NULL; if (i>0) { if (i>0) { myfont=LoadFontFile(i); } /* Set font data and use it */ gfxPrimitivesSetFont(myfont,fontw[i],fonth[i]); x += fonth[i]; stringRGBA(screen,x,y,fontfile[i],255,255,255,255); y -= 100; stringRGBA(screen,x,y,mytext,255,255,255,255); x += 10; if (i>0) { /* Clean up font-data */ free(myfont); } } /* Display by flipping screens */ SDL_Flip(screen); } }
bool TopedApp::OnInit() { //Memory leakages check for Windows /* #ifdef _DEBUG int tmpDbgFlag; HANDLE hLogFile=CreateFile("log.txt",GENERIC_WRITE,FILE_SHARE_WRITE, NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE|_CRTDBG_MODE_WNDW|_CRTDBG_MODE_DEBUG); _CrtSetReportMode(_CRT_WARN,_CRTDBG_MODE_FILE|_CRTDBG_MODE_DEBUG); _CrtSetReportMode(_CRT_ERROR,_CRTDBG_MODE_FILE|_CRTDBG_MODE_WNDW|_CRTDBG_MODE_DEBUG); _CrtSetReportFile(_CRT_ASSERT,hLogFile); _CrtSetReportFile(_CRT_WARN,hLogFile); _CrtSetReportFile(_CRT_ERROR,hLogFile); tmpDbgFlag=_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); tmpDbgFlag|=_CRTDBG_ALLOC_MEM_DF; tmpDbgFlag|=_CRTDBG_DELAY_FREE_MEM_DF; tmpDbgFlag|=_CRTDBG_LEAK_CHECK_DF; _CrtSetDbgFlag(tmpDbgFlag); //_CrtSetBreakAlloc(5919); #endif*/ DATC = new DataCenter(); Toped = new tui::TopedFrame( wxT( "wx_Toped" ), wxPoint(50,50), wxSize(1200,900) ); console::ted_log_ctrl *logWindow = new console::ted_log_ctrl(Toped->logwin()); delete wxLog::SetActiveTarget(logWindow); Browsers = Toped->browsers(); CmdList = Toped->cmdlist(); // Create the main block parser block - WARNING! blockSTACK structure MUST already exist! CMDBlock = new parsercmd::cmdMAIN(); InitInternalFunctions(static_cast<parsercmd::cmdMAIN*>(CMDBlock)); SetTopWindow(Toped); Toped->Show(TRUE); GetFontDir(); if (!LoadFontFile("arial1")) return FALSE; GetLogDir(); if (!GetLogFileName()) return FALSE; bool recovery_mode = false; if (CheckCrashLog()) { wxMessageDialog* dlg1 = new wxMessageDialog(Toped, wxT("Last session didn't exit normally. Start recovery?\n\n WARNING! Recovery mode is experimental.\nMake sure that you've backed-up your database before proceeding"), wxT("Toped"), wxYES_NO | wxICON_WARNING); if (wxID_YES == dlg1->ShowModal()) recovery_mode = true; else tell_log(console::MT_WARNING,"Recovery rejected."); dlg1->Destroy(); if (!recovery_mode) SaveIgnoredCrashLog(); } if (recovery_mode) { tell_log(console::MT_WARNING,"Starting recovery ..."); wxString inputfile; inputfile << wxT("#include \"") << logFileName.c_str() << wxT("\""); Console->parseCommand(inputfile, false); tell_log(console::MT_WARNING,"Previous session recovered."); static_cast<parsercmd::cmdMAIN*>(CMDBlock)->recoveryDone(); LogFile.init(std::string(logFileName.mb_str()), true); } else { LogFile.init(std::string(logFileName.mb_str())); // wxLog::AddTraceMask("thread"); if (1 < argc) { wxString inputfile; for (int i=1; i<argc; i++) { inputfile.Clear(); inputfile << wxT("#include \"") << argv[i] << wxT("\""); Console->parseCommand(inputfile); } } } return TRUE; }