本文整理汇总了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;
}
示例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;
}
示例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;
}