Example #1
0
void FontMan::loadFontCB(const std::string& assetName, bool error,
                         size_t bytesRead, uint8_t* buffer,
                         int32_t numRetries, CPM_ES_NS::ESCoreBase& core)
{
  if (!error)
  {
    // Generate a new ID for this font.
    ++mLastFontID;
    uint64_t fontID = mLastFontID;

    // No error. We have loaded the font file and are ready to load it up.
    // Remember, we are toying with the idea that the texture will not be
    // applied onto the object itself, but onto a ficticious font entity which
    // will be responsible for holding onto the texture until it is garbage
    // collected.
    mIDToFont.insert(std::make_pair(fontID, FontInfo(fontID, assetName)));

    auto it = mIDToFont.find(fontID);
    if (it != mIDToFont.end())
    {
      BMFont& font = it->second.fontInfo;
      font.loadFromBuffer(buffer, bytesRead);
    }
    else
    {
      std::cerr << "FontMan: Failed promise for " << assetName 
                << ". Unable to find newly inserted value!" << std::endl;
    }
  }
  else
  {
    if (numRetries > 0)
    {
      // Reattempt the request
      --numRetries;
      requestFont(core, assetName, numRetries);
    }
    else
    {
      std::cerr << "FontMan: Failed promise for " << assetName << std::endl;
    }
  }
}
Example #2
0
void initUiFont(const SpriteDb& sprite_db) {
	IntRect font_spr = sprite_db.lookup("ui_font");
	ui_font = FontInfo(' ', 8, 8, font_spr.x, font_spr.y, 16, 6);
}
Example #3
0
/**
*  @brief
*    Get font information
*/
FontInfo Font::GetFontInfo() const
{
	// Return font info
	return FontInfo(m_sFilename, m_sFamily, m_nHeight, m_nWeight, m_nStyle);
}