当前位置: 首页>>代码示例>>C++>>正文


C++ Font::loadFromMemory方法代码示例

本文整理汇总了C++中sf::Font::loadFromMemory方法的典型用法代码示例。如果您正苦于以下问题:C++ Font::loadFromMemory方法的具体用法?C++ Font::loadFromMemory怎么用?C++ Font::loadFromMemory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sf::Font的用法示例。


在下文中一共展示了Font::loadFromMemory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initFonts

/* 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;
}
开发者ID:Monsterovich,项目名称:SLADE,代码行数:30,代码来源:Drawing.cpp

示例2: LoadFromMemory

  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;
  }
开发者ID:ItsJackson,项目名称:gqe,代码行数:31,代码来源:FontHandler.cpp

示例3: sizeof

	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;
	}
开发者ID:Lirrec,项目名称:SchiffbruchEngine,代码行数:15,代码来源:ResourceManager.cpp


注:本文中的sf::Font::loadFromMemory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。