void TryLoadFonts() { TTFFontSetDescriptor * font = LanguagesDescriptors[gCurrentLanguage].font; if (font != FONT_OPENRCT2_SPRITE) { if (!String::IsNullOrEmpty(gConfigFonts.file_name)) { if (LoadCustomConfigFont()) { return; } Console::Error::WriteLine("Unable to initialise configured TrueType font -- falling back to Language default."); } if (LoadFont(font)) { return; } Console::Error::WriteLine("Unable to initialise prefered TrueType font -- falling back to Arial."); if (LoadFont(&TTFFontArial)) { return; } Console::Error::WriteLine("Unable to initialise prefered TrueType font -- Falling back to sprite font."); } LoadSpriteFont(); }
CFGAS_GEFont* CFGAS_FontMgr::LoadFont(const FX_WCHAR* pszFontFamily, uint32_t dwFontStyles, uint16_t wCodePage) { uint32_t dwHash = FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage); CFGAS_GEFont* pFont = nullptr; if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; FX_FONTDESCRIPTOR const* pFD = FindFont(pszFontFamily, dwFontStyles, true, wCodePage); if (!pFD) pFD = FindFont(pszFontFamily, dwFontStyles, false, wCodePage); if (!pFD) return nullptr; if (wCodePage == 0xFFFF) wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); pFont = CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); if (!pFont) return nullptr; m_Fonts.Add(pFont); m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); return LoadFont(pFont, dwFontStyles, wCodePage); }
void InitFonts() { LoadFont("Courier New", &fonts[0], 10, FW_NORMAL, "default"); LoadFont("Courier New", &fonts[1], 14, FW_NORMAL, "log_screen"); LoadFont("Times New Roman", &fonts[2], 14, FW_BOLD, "debug"); LoadFont("Courier New", &fonts[3], 10, FW_NORMAL, "star"); }
CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCodePage( uint16_t wCodePage, uint32_t dwFontStyles, const FX_WCHAR* pszFontFamily) { uint32_t dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); CFGAS_GEFont* pFont = nullptr; if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; } FX_FONTDESCRIPTOR const* pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage); if (!pFD) pFD = FindFont(nullptr, dwFontStyles, TRUE, wCodePage); if (!pFD) pFD = FindFont(nullptr, dwFontStyles, FALSE, wCodePage); if (!pFD) return nullptr; pFont = CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); if (pFont) { m_Fonts.Add(pFont); m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage); m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); return LoadFont(pFont, dwFontStyles, wCodePage); } return nullptr; }
CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, const FX_WCHAR* pszFontAlias, uint32_t dwFontStyles, uint16_t wCodePage, FX_BOOL bSaveStream) { ASSERT(pFontStream && pFontStream->GetLength() > 0); CFGAS_GEFont* pFont = nullptr; if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) { if (pFont) { if (pszFontAlias) { uint32_t dwHash = FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); } return LoadFont(pFont, dwFontStyles, wCodePage); } } pFont = CFGAS_GEFont::LoadFont(pFontStream, this, bSaveStream); if (pFont) { m_Fonts.Add(pFont); m_StreamFonts.SetAt((void*)pFontStream, (void*)pFont); if (pszFontAlias) { uint32_t dwHash = FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); } return LoadFont(pFont, dwFontStyles, wCodePage); } return nullptr; }
bool CTextRenderer::Init() { //Cleaning for(int i=0; i<m_Fonts.size(); i++) delete m_Fonts[i]; for(int i=0; i<m_GlyphCaches.size(); i++) delete m_GlyphCaches[i]; m_Fonts.clear(); m_GlyphCaches.clear(); //Init caches m_GlyphCaches.set_size(NUM_FONT_SIZES); for(int i=0; i<m_GlyphCaches.size(); i++) { m_GlyphCaches[i] = new CGlyphCache(Kernel()); m_GlyphCaches[i]->Init(s_aFontSizes[i]); } //Load FreeType if(FT_Init_FreeType(&m_FTLibrary) != FT_Err_Ok) return false; //Load Font if(!LoadFont("fonts/DejaVuSans.ttf")) return false; LoadFont("fonts/NotoSansCJKjp-Medium.ttf"); return true; }
FontManager::FontManager() { TTF_Init(); TTF_Font *pScriptFont = LoadFont("script",96); mFontData.insert(std::pair<std::string,TTF_Font*>("script",pScriptFont)); TTF_Font *pAirStrike = LoadFont("airstrike",56); mFontData.insert(std::pair<std::string,TTF_Font*>("airstrike",pAirStrike)); TTF_Font *pOrange = LoadFont("orange",56); mFontData.insert(std::pair<std::string,TTF_Font*>("orange",pOrange)); }
// **************************************************************************************** // Init // **************************************************************************************** void Resources::Init() { // load all _pFontDebug =LoadFont("Data/Verdana60.fnt", 0.4f); _pFontScore =LoadFont("Data/Bauhaus93.fnt"); _pFontTitle =LoadFont("Data/Bauhaus93.fnt"); _pFontMenus =LoadFont("Data/Verdana60.fnt", 0.5f); _pFontMessages =LoadFont("Data/Lucida70.fnt"); // _BallTexture =hge->Texture_Load("Data/TennisBall3.png"); // _pSpriteBall =new hgeSprite(_BallTexture,0,0,16,16); // _pSpriteBall->SetHotSpot(8,8); const Float32 TileSize =32.0f; const Int32 x=3; const Int32 y=2; _TexBall =hge->Texture_Load("Data/particles.png"); _pSpriteBall =new hgeSprite(_TexBall, x*TileSize, y*TileSize, TileSize, TileSize); _pSpriteBall->SetHotSpot(16,16); _pSpriteBallTrail =new hgeSprite(*_pSpriteBall); _texPowerBar =hge->Texture_Load("Data/PowerBar.png"); _texRacketTrail =hge->Texture_Load("Data/RacketTrail.png"); _pSpriteRacketTrail =new hgeSprite(_texRacketTrail, 0.0f, 0.0f, 16.0f, 16.0f); _pSpriteRacketTrail->SetBlendMode(BLEND_COLORADD); // ---- help ---- _texPadXbox =hge->Texture_Load("Data/Common_Controller_NoStick.png"); const Int32 nPadXboxSizeX =hge->Texture_GetWidth(_texPadXbox, true); const Int32 nPadXboxSizeY =hge->Texture_GetHeight(_texPadXbox, true); _pSpritePadXbox =new hgeSprite(_texPadXbox, 0, 0, (Float32)nPadXboxSizeX, (Float32)nPadXboxSizeY); _pSpritePadXbox->SetHotSpot((Float32)(nPadXboxSizeX/2), (Float32)(nPadXboxSizeY/2)); _texPadStick =hge->Texture_Load("Data/Stick.png"); const Int32 nPadStickSizeX =hge->Texture_GetWidth(_texPadStick, true); const Int32 nPadStickSizeY =hge->Texture_GetHeight(_texPadStick, true); _pSpritePadStick =new hgeSprite(_texPadStick, 0, 0, (Float32)nPadStickSizeX, (Float32)nPadStickSizeY); _pSpritePadStick->SetHotSpot((Float32)(nPadStickSizeX/2), (Float32)(nPadStickSizeY/2)); // ---- AUDIO --- Audio& audio =Otb::GetInstance()->GetAudio(); _hsBoing =audio.SampleLoad("Data/snd/player_bounce3.wav"); _hsShoot =audio.SampleLoad("Data/snd/shine_reject2.wav"); _hsNetHit =audio.SampleLoad("Data/snd/bang1.wav"); _hsRacketFlap =audio.SampleLoad("Data/snd/flap.wav"); _hsMenuChangeItem =audio.SampleLoad("Data/snd/menu.wav"); _hsZion =audio.SampleLoad("Data/snd/zion.wav"); _hsMenuValidate =audio.SampleLoad("Data/snd/bedroom_switch_a.wav"); _hsMenuCancel =audio.SampleLoad("Data/snd/bedroom_switch_b.wav"); }
void Game_sys::LoadDatafiles() { //LOAD ALL THE DATAFILES backgrounds = LoadDatafile( "Datafiles/backgrounds.dat" ); bgmusic = LoadDatafile( "Datafiles/bgmusic.dat" ); s_samples = LoadDatafile( "Datafiles/samples.dat" ); playerSprites = LoadDatafile( "Datafiles/playerSprites.dat" ); evilBubbleSprites = LoadDatafile( "Datafiles/evilBubbleSprites.dat" ); interfaceFont = LoadFont("Fonts/interfaceFont.pcx"); titleFont = LoadFont("Fonts/titlesFont.pcx"); }
Font::Font(const char *filename) { m_texture = NULL; m_characters.resize(256); LoadFont(filename); }
/* ============================== idFont::idFont ============================== */ idFont::idFont( const char* n ) : name( n ) { fontInfo = NULL; alias = RemapFont( n ); if( alias != NULL ) { // Make sure we don't have a circular reference for( idFont* f = alias; f != NULL; f = f->alias ) { if( f == this ) { idLib::FatalError( "Font alias \"%s\" is a circular reference!", n ); } } return; } if( !LoadFont() ) { if( name.Icmp( DEFAULT_FONT ) == 0 ) { idLib::FatalError( "Could not load default font \"%s\"", DEFAULT_FONT ); } else { idLib::Warning( "Could not load font %s", n ); alias = renderSystem->RegisterFont( DEFAULT_FONT ); } } }
Label::Label(const sf::String& text, unsigned int size, const sf::Vector2f& pos, float rot) { LoadFont(); m_Text.setString(text); m_Text.setCharacterSize(size); setPosition(pos); setRotation(rot); }
int main(int argc, char* argv[]) { if(argc != 4) { std::cout<<"ERROR: missing parameters."<<std::endl; system("PAUSE"); return 0; } gInputFile = std::string(argv[1]); gFontFile = std::string(argv[2]); gSize = atoi(argv[3]); SDL_Init(SDL_INIT_EVERYTHING); TTF_Init(); pFont = LoadFont(gFontFile,gSize); std::string line; std::ifstream iFile (gInputFile); if (iFile.is_open()) { while ( getline (iFile,line) ) { SDL_Surface *pSurface = GetSurface(line); SDL_SaveBMP(pSurface,(std::string(line)+".bmp").c_str()); SDL_FreeSurface(pSurface); } iFile.close(); } TTF_CloseFont(pFont); return 0; }
bool LoadFont(const bfs::path && path, const std::string & font) { if(bfs::exists(path)) { if( is_regular_file(path) ) { if(path.filename() == font) { sf::Font * f = new sf::Font(); f->loadFromFile(path.string()); loaded_fonts[const_cast<std::string&>(font)] = f; return true; } } if( is_directory(path) ) { std::vector<bfs::path> ls_path; std::copy(bfs::directory_iterator(path), bfs::directory_iterator(), std::back_inserter(ls_path)); for(auto it = ls_path.begin(); it != ls_path.end(); ++it) { if( LoadFont(std::move(*it), font) ) return true; } } } return false; }
VOID ScrLoadFontTable(UINT32 CodePage) { PHYSICAL_ADDRESS BaseAddress; PUCHAR Bitplane; PUCHAR FontBitfield = NULL; NTSTATUS Status = STATUS_SUCCESS; FontBitfield = (PUCHAR) ExAllocatePoolWithTag(NonPagedPool, 2048, TAG_BLUE); if(FontBitfield) { /* open bit plane for font table access */ OpenBitPlane(); /* get pointer to video memory */ BaseAddress.QuadPart = BITPLANE_BASE; Bitplane = (PUCHAR)MmMapIoSpace (BaseAddress, 0xFFFF, MmNonCached); Status = ExtractFont(CodePage, FontBitfield); if (NT_SUCCESS(Status)) LoadFont(Bitplane, FontBitfield); MmUnmapIoSpace(Bitplane, 0xFFFF); ExFreePool(FontBitfield); /* close bit plane */ CloseBitPlane(); } }
Gwen::Point DirectX9::MeasureText( Gwen::Font* pFont, const Gwen::UnicodeString & text ) { // If the font doesn't exist, or the font size should be changed if ( !pFont->data || fabs( pFont->realsize - pFont->size * Scale() ) > 2 ) { FreeFont( pFont ); LoadFont( pFont ); } FontData* pFontData = ( FontData* ) pFont->data; Gwen::Point size; if ( text.empty() ) { RECT rct = {0, 0, 0, 0}; pFontData->pFont->DrawTextW( NULL, L"W", -1, &rct, DT_CALCRECT, 0 ); return Gwen::Point( 0, rct.bottom ); } RECT rct = {0, 0, 0, 0}; pFontData->pFont->DrawTextW( NULL, text.c_str(), -1, &rct, DT_CALCRECT | DT_LEFT | DT_TOP | DT_SINGLELINE, 0 ); for ( int i = text.length() - 1; i >= 0 && text[i] == L' '; i-- ) { rct.right += pFontData->iSpaceWidth; } return Gwen::Point( rct.right / Scale(), rct.bottom / Scale() ); }
Gwen::Point SFML::MeasureText( Gwen::Font* pFont, const Gwen::UnicodeString& text ) { const sf::Font* pSFFont = (sf::Font*)(pFont->data); // If the font doesn't exist, or the font size should be changed if ( !pSFFont || fabs( pFont->realsize - pFont->size * Scale() ) > 2 ) { FreeFont( pFont ); LoadFont( pFont ); } if ( !pSFFont ) { pSFFont = &(sf::Font::GetDefaultFont()); } #if SFML_VERSION_MAJOR == 2 sf::Text sfStr( text ); sfStr.SetFont( *pSFFont ); sfStr.SetCharacterSize( pFont->realsize ); sf::FloatRect sz = sfStr.GetRect(); return Gwen::Point( sz.Width, sz.Height ); #else sf::String sfStr( text ); sfStr.SetFont( *pSFFont ); sfStr.SetSize( pFont->realsize ); sf::FloatRect sz = sfStr.GetRect(); return Gwen::Point( sz.GetWidth(), sz.GetHeight() ); #endif }
bool cGuiSkin::Load(std::string _filename){ filename = _filename; fParser = new cFileParser(); fParser->Load(filename); fParser->Parse(); cFileParserTag *tmpTag = fParser->GetTag("FILENAME"); if(tmpTag == NULL){ StormPrintLog(STORM_LOG_ERROR, "cGuiSkin", "Invalid config file"); delete fParser; fParser = NULL; return false; } skinTexture = S_LoadTexture(tmpTag->value); if(!LoadFont()) return false; bool status = false; status |= LoadCheckBoxSkin(); status |= LoadContainerSkin(); status |= LoadButtonSkin(); status |= LoadRadioSkin(); status |= LoadInputSkin(); status |= LoadComboBoxSkin(); status |= LoadHorSliderSkin(); status |= LoadVerSkiderSkin(); status |= LoadListSkin(); if(!status){ StormPrintLog(STORM_LOG_WARNING, "cGuiSkin", "Config file loaded, with errors"); return false; } return true; }
//---------------------------------------------------------------------------- //---------------------------------------------------------------------------- void FontProvider::CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) { Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept { LoadFont(in_location, in_filePath, in_delegate, out_resource); }); }
void CPrefView::OnInitialUpdate() { CFormView::OnInitialUpdate(); // AfxGetApp()->m_pMainWnd->GetMenu()->EnableMenuItem(ID_FILE_MRU_FILE1,MF_GRAYED); // GetMenu()->EnableMenuItem(ID_FILE_MRU_FILE2,MF_GRAYED); // AfxGetApp()->m_pMainWnd->GetMenu()->CheckMenuItem(ID_MENUITEM_SHOWGRAD,MF_UNCHECKED); //ReSize(); if (m_pM->m_is_grad) AfxGetApp()->m_pMainWnd->GetMenu()->CheckMenuItem(ID_MENUITEM_SHOWGRAD,MF_CHECKED); else AfxGetApp()->m_pMainWnd->GetMenu()->CheckMenuItem(ID_MENUITEM_SHOWGRAD,MF_UNCHECKED); fSize=1; for (int i=3; i>=0; i--) m_OtherC.DeleteColumn(i); LV_COLUMN lvc; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; lvc.pszText = (LPTSTR) "Наименование"; lvc.cx = m_OtherC.GetStringWidth(lvc.pszText) + 15; lvc.iSubItem = 0; m_OtherC.InsertColumn(0,&lvc); lvc.pszText = (LPTSTR) "Значение "; lvc.cx = m_OtherC.GetStringWidth(lvc.pszText) + 15; lvc.iSubItem = 1; m_OtherC.InsertColumn(1,&lvc); LoadFont(); SetDlgItemText(IDC_EDIT_GNAME,m_pG->GetName()); m_Slider.EnableWindow(FALSE); SetDlgItemText(IDC_EDIT_GOD,""); SetAxis(); GetDlgItem(IDC_MSFLEXGRID1)->SetFocus(); }
MHIContext::MHIContext(InteractiveTV *parent) : m_parent(parent), m_dsmcc(NULL), m_keyProfile(0), m_engine(NULL), m_stop(false), m_updated(false), m_displayWidth(StdDisplayWidth), m_displayHeight(StdDisplayHeight), m_face_loaded(false), m_engineThread(NULL), m_currentChannel(-1), m_currentStream(-1), m_isLive(false), m_currentSource(-1), m_audioTag(-1), m_videoTag(-1), m_lastNbiVersion(NBI_VERSION_UNSET), m_videoRect(0, 0, StdDisplayWidth, StdDisplayHeight), m_displayRect(0, 0, StdDisplayWidth, StdDisplayHeight) { m_xScale = (float)m_displayWidth / (float)MHIContext::StdDisplayWidth; m_yScale = (float)m_displayHeight / (float)MHIContext::StdDisplayHeight; if (!ft_loaded) { FT_Error error = FT_Init_FreeType(&ft_library); if (!error) ft_loaded = true; } if (ft_loaded) { // TODO: We need bold and italic versions. if (LoadFont(FONT_TO_USE)) m_face_loaded = true; } }
GSOsdManager::GSOsdManager() : m_atlas_h(0) , m_atlas_w(0) , m_max_width(0) , m_onscreen_messages(0) , m_texture_dirty(true) { m_log_enabled = theApp.GetConfigB("osd_log_enabled"); m_log_timeout = std::max(2, std::min(theApp.GetConfigI("osd_log_timeout"), 10)); m_monitor_enabled = theApp.GetConfigB("osd_monitor_enabled"); m_opacity = std::max(0, std::min(theApp.GetConfigI("osd_color_opacity"), 100)); m_max_onscreen_messages = theApp.GetConfigI("osd_max_log_messages"); m_size = theApp.GetConfigI("osd_fontsize"); int r = theApp.GetConfigI("osd_color_r"); int g = theApp.GetConfigI("osd_color_g"); int b = theApp.GetConfigI("osd_color_b"); m_color = r | (g << 8) | (b << 16) | (255 << 24); if (FT_Init_FreeType(&m_library)) { m_face = NULL; fprintf(stderr, "Failed to init the freetype library\n"); return; } LoadFont(); /* The space character's width is used in GeneratePrimitives() */ AddGlyph(' '); }
XMLFontRenderer::XMLFontRenderer(void) { LoadFont("Data/Fonts/Papyrus.fnt"); m_fontTexturePath = "Data/Fonts/Papyrus_0.png"; m_cursor = Vec2(0.f, 0.f); m_lastCursor = Vec2(0.f, 0.f); }
void LoadStdLanderFont (PLANET_INFO *info) { info->LanderFont = LoadFont (LANDER_FONT); info->LanderFontEff = CaptureDrawable ( LoadGraphic (LANDER_FONTEFF_PMAP_ANIM)); }
void CFontMgr::Init() { Assert( !m_bInitialized ); g_DefaultFont = LoadFont( "Verdana", 12 ); m_bInitialized = true; }
FontTTF::FontTTF(const char* file, int ptsize, SDL_Color textColor) { if (file && ptsize) { if (!LoadFont(file, ptsize, textColor)) throw std::exception("Font load failed in FontTTF constructor"); } }
bool LoadFont(const std::string & font) { for(auto it = font_directories.begin(); it != font_directories.end(); ++it) { if( LoadFont(bfs::path(*it), font) ) return true; } return false; }
static pointer speedoSetup(pointer module, pointer opts, int *errmaj, int *errmin) { speedoModule.module = module; LoadFont(&speedoModule); /* Need a non-NULL return */ return (pointer)1; }
static pointer bitmapSetup(pointer mod, pointer opts, int *errmaj, int *errmin) { bitmapModule.module = mod; LoadFont(&bitmapModule); /* Need a non-NULL return */ return (pointer)1; }
static pointer type1Setup(pointer module, pointer opts, int *errmaj, int *errmin) { type1Module.module = module; LoadFont(&type1Module); /* Need a non-NULL return */ return (pointer)1; }