コード例 #1
0
ファイル: Drawing.cpp プロジェクト: Monsterovich/SLADE
/* FontManager::initFonts
 * Loads all needed fonts for rendering. SFML 2.x implementation
 *******************************************************************/
int FontManager::initFonts()
{
	// --- Load general fonts ---
	int ret = 0;

	// Normal
	ArchiveEntry* entry = theArchiveManager->programResourceArchive()->entryAtPath("fonts/dejavu_sans.ttf");
	if (entry) ++ret, font_normal.loadFromMemory((const char*)entry->getData(), entry->getSize());

	// Condensed
	entry = theArchiveManager->programResourceArchive()->entryAtPath("fonts/dejavu_sans_c.ttf");
	if (entry) ++ret, font_condensed.loadFromMemory((const char*)entry->getData(), entry->getSize());

	// Bold
	entry = theArchiveManager->programResourceArchive()->entryAtPath("fonts/dejavu_sans_b.ttf");
	if (entry) ++ret, font_bold.loadFromMemory((const char*)entry->getData(), entry->getSize());

	// Condensed Bold
	entry = theArchiveManager->programResourceArchive()->entryAtPath("fonts/dejavu_sans_cb.ttf");
	if (entry) ++ret, font_boldcondensed.loadFromMemory((const char*)entry->getData(), entry->getSize());

	// Monospace
	entry = theArchiveManager->programResourceArchive()->entryAtPath("fonts/dejavu_mono.ttf");
	if (entry) ++ret, font_small.loadFromMemory((const char*)entry->getData(), entry->getSize());

	return ret;
}
コード例 #2
0
ファイル: FontHandler.cpp プロジェクト: ItsJackson/gqe
  bool FontHandler::LoadFromMemory(const typeAssetID theAssetID, sf::Font& theAsset)
  {
    // Start with a return result of false
    bool anResult = false;

    // TODO: Retrieve the const char* pointer to load data from
    const char* anData = NULL;
    // TODO: Retrieve the size in bytes of the font to load from memory
    size_t anDataSize = 0;
    // TODO: Retrieve the character size for this font
    unsigned int anCharSize = 30;

    // Try to obtain the font from the memory location specified
    if(NULL != anData && anDataSize > 0)
    {
      // Load the font from the memory location specified
#if (SFML_VERSION_MAJOR < 2)
      anResult = theAsset.LoadFromMemory(anData, anDataSize, anCharSize);
#else
      anResult = theAsset.loadFromMemory(anData, anDataSize);
#endif
    }
    else
    {
      ELOG() << "FontHandler::LoadFromMemory(" << theAssetID
        << ") Bad memory location or size!" << std::endl;
    }

    // Return anResult of true if successful, false otherwise
    return anResult;
  }
コード例 #3
0
	const sf::Font& ResourceManager::getDefaultFont() {
		static sf::Font font;
		static bool loaded = false;

		if (!loaded)
		{
			static const signed char data[] =
					{
#include "Arial.hpp"
					};
			font.loadFromMemory(data, sizeof(data));
			loaded = true;
		}
		return font;
	}