fpath FontManager::getFontPath(fkey key) { if (paths.count(key)) return "font/"+paths[key]; if (key!=to_uppercase(k_DEFAULT)) return getFontPath(k_DEFAULT); std::cout<<"Error: no default font found!\n(Did you edit font.cfg?)\n"; assert(false); return ""; }
/** * @brief Loads Bitmap Fonts Images from Files * @param fontName * @return */ bool SurfaceManager::loadBitmapFontImage() { std::string path = getFontPath(); path.append(m_currentFont); std::cout << "loading Font -> : " << path << std::endl; // Loading Bitmap first time, or reloading, If already Exists remove it. if(surfaceExists(SURFACE_FONT)) { delSurface(SURFACE_FONT); } // Load the Font into the Surface. surface_ptr fontSurface( new Surfaces( SDL_LoadBMP(path.c_str()) ) ); if(!fontSurface->exists()) { SDL_Log("loadBitmapImage() fontSurface font: %s", path.c_str()); SDL_Delay(1500); assert(false); } // Convert and Add to Surface Manager. if(!fontSurface->convert()) { SDL_Log("Error Converting Font Surface!"); return false; } addSurface(SURFACE_FONT, fontSurface); return true; /* * WIP, Implement this! */ /* // Redraw Cursor with new font! // When no data received, this is when we want to show the cursor! // Setup cursor in current x/y position Cursor. if(TheSequenceParser::Instance()->isCursorActive()) { setupCursorChar(); renderCursorOnScreen(); drawTextureScreen(); } m_previousFont = m_currentFont; // Current to Previous m_currentFont = fontName; // New to Current. return m_cachedSurface != nullptr;*/ }
std::shared_ptr<Font> FontManager::getFont(fkey key_case,int size) { fkey key = to_uppercase(key_case.c_str()); size_list* store = sizes[key]; if (!store) { store = new size_list(); sizes.insert(std::pair<fkey,size_list*>(key,store)); store->l_size.push_back(size); } lkey lk(key,size); std::shared_ptr<Font> f = locks[lk]; if (!f){ f = resourceHandler->fnt.getResource(spec_font(getFontPath(key),size)); locks.insert(std::pair<lkey,std::shared_ptr<Font>>(lk,f)); store->l_size.push_back(size); } return f; }
void ZFonts::slot_install() { int n = lbFonts->currentItem(); if ( n<0 ) if ( lbFonts->count()>0 ) n=0; else return; QString sFontPath = getFontPath(lbFonts->item(n)); QString sFontName = QFileInfo(sFontPath).baseName(); ZSingleSelectDlg * ssdInstallAs = new ZSingleSelectDlg( sFontName, tr("FMT_RID_INSTRUCTIONALTXT_INSTALLING_1","Install to").arg("") ); QStringList list; list.append( tr("TXT_RID_OPTION_TEXT", "Text") ); list.append( tr("TXT_RID_STANDARD_JAVAPIM_CONTACT_PHONENUMBER", "Phone Number") ); ssdInstallAs->addItemsList( list ); if ( ssdInstallAs->exec() == QDialog::Accepted ) { ZMessageDlg * dlg = new ZMessageDlg("zFonts", QObject::tr("TXT_RID_INSTRUCTIONALTXT_PLEASE_WAIT","Update..."), ZMessageDlg::TypeCustom, 0, this); dlg->setTitleIcon( "info_pop.g" ); dlg->show(); qApp->processEvents(); QString sInstallTo; if ( ssdInstallAs->getCheckedItemIndex()==0 ) sInstallTo = "/ezxlocal/fonts/AMCSL.TTF"; else sInstallTo = "/ezxlocal/fonts/NUMBER.TTF"; system(QString("cp -a %1 %2").arg(sFontPath).arg(sInstallTo) ); system("mot_reboot"); } }
void ZFonts::slot_fontSelect(int n) { previewFont(getFontPath(lbFonts->item(n))); }