void AManager::setMenuRessource() { addImage("../ressources/images/MainBG.jpg", "MainBG"); addImage("../ressources/images/bg.jpg", "bg"); addImage("../ressources/images/r_type-logo.png", "rtype_logo"); addImage("../ressources/images/highlight.png", "highlight"); addImage("../ressources/images/earth.png", "earth"); addFont("../ressources/fonts/font.ttf", "default"); addFont("../ressources/fonts/spaceage.ttf", "spaceage"); addFont("../ressources/fonts/Android.ttf", "Android"); }
//=================================================================================== void CDrawManager::Initialize() { if(gInts.Surface == nullptr) return; gInts.Engine->GetScreenSize(gScreenSize.iScreenWidth, gScreenSize.iScreenHeight); font_t font; font.setFont("Visitor TT2 (BRK)", ESP_HEIGHT, 400, CDrawManager::FONTFLAG_OUTLINE, "esp"); addFont(font); font.setFont("Tahoma", HUD_HEIGHT, 500, CDrawManager::FONTFLAG_ANTIALIAS, "hud"); addFont(font); }
int GUIFontManager::addFont(const TiXmlElement *fontNode) { GUIFont *newFont = new GUIFont(); int index = -1; if(newFont->loadXMLSettings(fontNode)) { index = findFontIndex(newFont); if(index >= 0) { deleteObject(newFont); } else { if(!newFont->build()) { deleteObject(newFont); } else { if(newFont->build()) { addFont(newFont); index = int(guiFontList.size() - 1); } } } } return index; }
Document::Document( Compiler& c, const char* loc ) : compiler( c ), nls( new Nls( loc ) ), hdr( new IpfHeader() ), eHdr( new IpfExtHeader() ), strings( new StringTable() ), extfiles( new ExternalFiles() ), controls( new Controls() ), gnames( new GNames() ), dict( new GlobalDictionary() ), lastPrintableItem( 0 ), maxHeaderLevel( 3 ), headerLevel( 1 ), currentLeftMargin( 1 ), lastPrintableToken( Lexer::END ), inDoc( false ), spacing( true ) { fonts.reset( new FontCollection( codePage() ) ); FontEntry fnt; char buffer[ sizeof( fnt.faceName ) ]; size_t size( std::wcstombs( buffer, cgraphicFontFaceName().c_str(), sizeof( fnt.faceName ) ) ); if( size == static_cast< size_t>( -1 ) ) throw FatalError( ERR_T_CONV ); std::strncpy( fnt.faceName, buffer, sizeof( fnt.faceName ) ); fnt.height = cgraphicFontHeight(); fnt.width = cgraphicFontWidth(); fnt.codePage = codePage(); addFont( fnt ); }
CFont * RessourcesManager::getCFont(std::string fontname, uint32_t size) { if (!exist(fontname, size)) { addFont(fontname, size); } return m_fonts.back(); }
void TextManager::addText(std::string name, std::string text, int x, int y) { auto debug = name; if(_fonts.find(name) == _fonts.end() ) { addFont(name); } _queue.push_back({name, text, x, y}); }
void PropertiesDialog::pageChanged( KPageWidgetItem *current, KPageWidgetItem * ) { if ( current == m_fontPage && !m_fontScanStarted ) { connect( m_document, SIGNAL(gotFont(Okular::FontInfo)), m_fontModel, SLOT(addFont(Okular::FontInfo)) ); connect( m_document, SIGNAL(fontReadingProgress(int)), this, SLOT(slotFontReadingProgress(int)) ); connect( m_document, SIGNAL(fontReadingEnded()), this, SLOT(slotFontReadingEnded()) ); QTimer::singleShot( 0, this, SLOT(reallyStartFontReading()) ); m_fontScanStarted = true; }
void KFontChooser::getFontList( QStrList &list, const char *pattern ) { int num; char **xFonts = XListFonts( qt_xdisplay(), pattern, 2000, &num ); for ( int i = 0; i < num; i++ ) { addFont( list, xFonts[i] ); } XFreeFontNames( xFonts ); }
GR_CharWidths* GR_CharWidthsCache::getWidthsForFont(const GR_Font* pFont) { GR_CharWidths* pCharWidths; UT_ASSERT(m_pFontHash); pCharWidths = m_pFontHash->pick(pFont->hashKey()); if (!pCharWidths) { addFont(pFont); UT_DEBUGMSG(("added font widths to cache for font with hashkey '%s'\n", pFont->hashKey().c_str())); pCharWidths = m_pFontHash->pick(pFont->hashKey()); UT_ASSERT(pCharWidths); } return pCharWidths; }
void QFontDatabasePrivate::addQPF2File(const QByteArray &file) { #ifndef QT_FONTS_ARE_RESOURCES struct stat st; if (stat(file.constData(), &st)) return; int f = QT_OPEN(file, O_RDONLY, 0); if (f < 0) return; const uchar *data = (const uchar *)mmap(0, st.st_size, PROT_READ, MAP_SHARED, f, 0); const int dataSize = st.st_size; #else QResource res(QLatin1String(file.constData())); const uchar *data = res.data(); const int dataSize = res.size(); //qDebug() << "addQPF2File" << file << data; #endif if (data && data != (const uchar *)MAP_FAILED) { if (QFontEngineQPF::verifyHeader(data, dataSize)) { QString fontName = QFontEngineQPF::extractHeaderField(data, QFontEngineQPF::Tag_FontName).toString(); int pixelSize = QFontEngineQPF::extractHeaderField(data, QFontEngineQPF::Tag_PixelSize).toInt(); QVariant weight = QFontEngineQPF::extractHeaderField(data, QFontEngineQPF::Tag_Weight); QVariant style = QFontEngineQPF::extractHeaderField(data, QFontEngineQPF::Tag_Style); QByteArray writingSystemBits = QFontEngineQPF::extractHeaderField(data, QFontEngineQPF::Tag_WritingSystems).toByteArray(); if (!fontName.isEmpty() && pixelSize) { int fontWeight = 50; if (weight.type() == QVariant::Int || weight.type() == QVariant::UInt) fontWeight = weight.toInt(); bool italic = static_cast<QFont::Style>(style.toInt()) & QFont::StyleItalic; QList<QFontDatabase::WritingSystem> writingSystems; for (int i = 0; i < writingSystemBits.count(); ++i) { uchar currentByte = writingSystemBits.at(i); for (int j = 0; j < 8; ++j) { if (currentByte & 1) writingSystems << QFontDatabase::WritingSystem(i * 8 + j); currentByte >>= 1; } } addFont(fontName, /*foundry*/ "prerendered", fontWeight, italic, pixelSize, file, /*fileIndex*/ 0, /*antialiased*/ true, writingSystems); } } else {
void AManager::setGameRessource() { addImage("../ressources/images/shoot1.png", "shoot1"); addImage("../ressources/images/shoot2.png", "shoot2"); addImage("../ressources/images/shoot3.png", "shoot3"); addImage("../ressources/images/EBall.png", "EBall"); addImage("../ressources/images/Eeye.png", "Eeye"); addImage("../ressources/images/Eredship.png", "Eredship"); addImage("../ressources/images/eshoot.png", "eshoot"); addImage("../ressources/images/background.png", "background"); addImage("../ressources/images/explode.png", "explode"); addImage("../ressources/images/nabibi.png", "nabibi"); addImage("../ressources/images/loadshoot.png", "loadshoot"); addImage("../ressources/images/Player.png", "Player"); addImage("../ressources/images/spininglazor.png", "spininglazor"); addFont("../ressources/fonts/tec.ttf", "tec"); }
bool ofxFontStash::setup(string firstFontFile, float lineHeightPercent , int _texDimension /*has to be powerfOfTwo!*/, bool createMipMaps, int intraCharPadding, float dpiScale_){ if (stash == NULL){ dpiScale = dpiScale_; extraPadding = intraCharPadding; lineHeight = lineHeightPercent; texDimension = ofNextPow2(_texDimension); stash = ofx_sth_create(texDimension,texDimension, createMipMaps, intraCharPadding, dpiScale); stash->doKerning = 0; //kerning disabled by default stash->charSpacing = 0.0; //spacing neutral by default addFont(firstFontFile); }else{ ofLogError("ofxFontStash") << "don't call setup() more than once!"; } return false; }
void Parser::parseFont(const string& s) { // this contains multiple params separated by spaces. StringTokenizer<string> tok(s, ' '); auto& l = tok.getTokens(); // remove empty strings. l.erase(std::remove_if(l.begin(), l.end(), [](const string& s) { return s.empty(); }), l.end()); if(l.size() < 2) // the last 2 params (font size & font family) are compulsory. return; // the last param (font family) may contain spaces; merge if that is the case. while(*(l.back().end() - 1) == '\'' && (l.back().size() <= 1 || *l.back().begin() != '\'')) { *(l.end() - 2) += ' ' + std::move(l.back()); l.erase(l.end() - 1); if(l.size() < 2) return; } // parse the last param (font family). /// @todo handle multiple fonts separated by commas... auto& family = l.back(); family.erase(std::remove(family.begin(), family.end(), '\''), family.end()); if(family.empty()) return; contexts.back().font = addFont("\\fnil " + std::move(family)); // parse the second to last param (font size). /// @todo handle more than px sizes auto& size = *(l.end() - 2); parseFontSize(size); // parse the optional third to last param (font weight). if(l.size() > 2 && Util::toInt(*(l.end() - 3)) >= FW_BOLD) { contexts.back().setFlag(Context::Bold); } // parse the optional first param (font style). if(l.size() > 2 && l[0] == "italic") { contexts.back().setFlag(Context::Italic); } }
sf::Font * DataManager::getFont( const std::string path ) { if(DataManager::singleton == NULL) { DataManager::singleton = new DataManager; } sf::Font * f = NULL; std::map< std::string, sf::Font * >::iterator i = DataManager::singleton->fonts.find( path ); if( i == DataManager::singleton->fonts.end() ) { f = addFont( path ); } else { f = (*i).second; } return f; }
void ResourceManager::loadFilesFromDirectory(std::string folder) { std::cout << "loading images" << std::endl; std::vector<std::string> names; std::string specPath = folder + "\\*.*"; folder += "\\"; WIN32_FIND_DATA fd; //declare variable to hold file data HANDLE hFind = FindFirstFile(specPath.c_str(), &fd); //find first file and store data if(hFind != INVALID_HANDLE_VALUE) { //if that data is not corrupt do { // read all (real) files in current folder // , delete '!' read other 2 default folder . and .. if(! (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ) { names.push_back(fd.cFileName); } }while(FindNextFile(hFind, &fd)); //find the next file FindClose(hFind); } //at this point "names" vector has all file names in directory for(int indice = 0; indice < names.size(); indice++) { int dotLoc = names[indice].size(); //location of '.' in string std::string extension = ""; //parsed file extension std::string notExtension = ""; //just the name for(int ii = 0; ii<names[indice].size(); ii++) { if(names[indice][ii] == '.') //if the character is a period { dotLoc = ii; //store that indice } else if(ii > dotLoc) //if the indice is after the period { extension+= names[indice][ii]; //store the character } else if(ii < dotLoc) { notExtension+= names[indice][ii]; } } std::string fullPath = folder+names[indice]; if(extension == "jpg" || //Checking for all texture file extensions extension == "jpeg" || extension == "png" || extension == "bmp") { addTexture(fullPath, notExtension); //if so load texture from that path std::cout << notExtension << std::endl; } else if(extension == "ttf") { addFont(fullPath, notExtension, 32); } else if(extension == ".wav" || //checks for valid sound extensions extension == ".aif" || extension == ".mp3" || extension == ".mp2" || extension == ".ogg" || extension == ".raw") { addSound(fullPath, notExtension); } } }
ViVulcanoThemeFonts::ViVulcanoThemeFonts() : ViThemeFonts() { addFont("harabara", "Harabara", ViThemeFonts::MainFont); }
bool FontManager::loadFontsFromFile(const std::string &fontsDescriptionFileName) { rapidjson::Document document; if (!parseJsonFromFile(fontsDescriptionFileName, &document)) return false; // Load the referenced fonts first. auto basePath = dirname(fontsDescriptionFileName); if (document.HasMember("include")) { auto &inclusionValue = document["include"]; if (!inclusionValue.IsObject()) return false; for (auto it = inclusionValue.MemberBegin(); it != inclusionValue.MemberEnd(); ++it) { //auto name = it->name.GetString(); auto &fileNameValue = it->value; if (!fileNameValue.IsString()) return false; auto fileName = fileNameValue.GetString(); if (!loadFontsFromFile(joinPath(basePath, fileName))) return false; } } // Load the fonts. if (document.HasMember("fonts")) { auto &fontsDesc = document["fonts"]; if (!fontsDesc.IsObject()) return false; for (auto it = fontsDesc.MemberBegin(); it != fontsDesc.MemberEnd(); ++it) { auto fontName = it->name.GetString(); auto &fontDesc = it->value; if (!fontDesc.IsObject() || !fontDesc.HasMember("faces")) return false; // Create the font auto font = std::make_shared<Font> (); addFont(fontName, font); // Load the faces auto &facesDesc = fontDesc["faces"]; for (auto faceIt = facesDesc.MemberBegin(); faceIt != facesDesc.MemberEnd(); ++faceIt) { auto faceName = faceIt->name.GetString(); auto &faceDesc = faceIt->value; if (!faceDesc.IsObject() || !faceDesc.HasMember("file")) return false; auto &faceFileName = faceDesc["file"]; if (!faceFileName.IsString()) return false; auto face = loadFaceFromFile(joinPath(basePath, faceFileName.GetString())); if (face) font->addFace(faceName, face); } // Cache the special faces. font->loadSpecialFaces(); } } // Load the defaults. if (document.HasMember("default-font") && document["default-font"].IsString()) defaultFont = getFont(document["default-font"].GetString()); if (document.HasMember("default-mono-font") && document["default-mono-font"].IsString()) defaultMononospacedFont = getFont(document["default-mono-font"].GetString()); if (document.HasMember("default-sans-font") && document["default-sans-font"].IsString()) defaultSansFont = getFont(document["default-sans-font"].GetString()); if (document.HasMember("default-serif-font") && document["default-serif-font"].IsString()) defaultSerifFont = getFont(document["default-serif-font"].GetString()); return true; }
MainMenu::MainMenu(const sf::FloatRect &zone) : APanelScreen(zone) { addFont("default", "../client/assets/default.TTF"); }
/*--------------------------------------------------------------------------*/ static int xlfont_one_rhs(char * fname) { SciErr sciErr; if ((checkInputArgumentType(pvApiCtx, 1, sci_strings))) { int* piAddrl1 = NULL; int* l1 = NULL; char* strl1 = NULL; int m1 = 0, n1 = 0; sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl1); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 1. if (getAllocatedSingleString(pvApiCtx, piAddrl1, &strl1)) { Scierror(202, _("%s: Wrong type for argument #%d: A string expected.\n"), fname, 1); return 1; } if (strcmp(strl1, "AVAILABLE_FONTS") == 0) { int nbElements = 0; char **fontsname = getAvailableFontsName(&nbElements); m1 = nbElements; n1 = 1; sciErr = createMatrixOfString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, m1, n1, (const char * const*)fontsname); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } freeArrayOfString(fontsname, nbElements); freeAllocatedSingleString(strl1); AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return 0; } else if (strcmp(strl1, "reset") == 0) { resetFontManager(); freeAllocatedSingleString(strl1); AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; } else { if (isAvailableFontsName(strl1)) { int fontID = addFont(strl1); m1 = 1; n1 = 1; sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, nbInputArgument(pvApiCtx) + 1, m1, n1, &l1); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } l1[0] = fontID; freeAllocatedSingleString(strl1); AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return 0; } else if (FileExist(strl1)) { int fontID = addFontFromFilename(strl1); m1 = 1; n1 = 1; sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, nbInputArgument(pvApiCtx) + 1, m1, n1, &l1); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } l1[0] = fontID; freeAllocatedSingleString(strl1); AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return 0; } else { Scierror(999, _("%s: Wrong value for input argument #%d: A valid fontname expected.\n"), fname, 1); } } freeAllocatedSingleString(strl1); } else { Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1); return 0; } return 0; }
LayoutAliasEditDialog::LayoutAliasEditDialog(NineMLLayout * inSrcNineMLLayout, QWidget *parent) : QDialog(parent) { srcNineMLLayout = inSrcNineMLLayout; this->setModal(true); this->setMinimumSize(450, 400); this->setWindowTitle("Edit Aliases"); //this->setWindowIcon(); // width of the delete box: int delWidth = 30; // add the main layout this->setLayout(new QVBoxLayout); this->layout()->setContentsMargins(0,0,0,0); // make the dialog scrollable this->layout()->addWidget(new QScrollArea); QWidget * content = new QWidget; ((QScrollArea *) this->layout()->itemAt(0)->widget())->setWidget(content); ((QScrollArea *) this->layout()->itemAt(0)->widget())->setWidgetResizable(true); content->setLayout(new QVBoxLayout); QVBoxLayout * contentLayout = (QVBoxLayout *) content->layout(); // start adding the items, header first: QHBoxLayout * header = new QHBoxLayout; header->addWidget(new QLabel("<b>Name</b>"), 1); header->addWidget(new QLabel("<b>Maths</b>"),3); header->addWidget(new QLabel("")); header->itemAt(2)->widget()->setFixedWidth(delWidth); contentLayout->addLayout(header); // add the aliases for (uint i = 0; i < srcNineMLLayout->AliasList.size(); ++i) { // add to main layout contentLayout->addLayout(drawAlias(srcNineMLLayout->AliasList[i])); } QFont addFont("Helvetica [Cronyx]", 8); // add new alias button QPushButton * addAlias = new QPushButton("Alias"); addAlias->setIcon(QIcon(":/icons/toolbar/addShad.png")); addAlias->setMaximumWidth(110); addAlias->setFlat(true); addAlias->setFocusPolicy(Qt::NoFocus); addAlias->setToolTip("Add a new Alias"); addAlias->setFont(addFont); addAlias->setProperty("layout", qVariantFromValue((void *) contentLayout)); QObject::connect(addAlias, SIGNAL(clicked()), this, SLOT(addAlias())); contentLayout->addWidget(addAlias); // make sure it all goes to the top of the dialog contentLayout->addStretch(); QHBoxLayout * exitLayout = new QHBoxLayout; exitLayout->addStretch(); QPushButton * exit = new QPushButton("Finished"); exit->setMaximumWidth(100); QObject::connect(exit, SIGNAL(clicked()), this, SLOT(close())); exitLayout->addWidget(exit); contentLayout->addLayout(exitLayout); }