Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion es-core/src/resources/Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Font::Font(int size, const std::string& path) : mSize(size), mPath(path)
{
assert(mSize > 0);

mTextures.reserve(10);
mLoaded = true;
mMaxGlyphHeight = 0;

Expand Down Expand Up @@ -211,6 +212,13 @@ void Font::getTextureForNewGlyph(const Vector2i& glyphSize, FontTexture*& tex_ou
return; // yes
}

if(mTextures.size() >= mTextures.capacity())
{
LOG(LogError) << "Glyph too many to create a new texture!";
tex_out = NULL;
return;
}

// current textures are full,
// make a new one
mTextures.push_back(FontTexture());
Expand Down Expand Up @@ -684,7 +692,7 @@ TextCache* Font::buildTextCache(const std::string& text, Vector2f offset, unsign
unsigned int i = 0;
for(auto it = vertMap.cbegin(); it != vertMap.cend(); it++)
{
TextCache::VertexList& vertList = cache->vertexLists.at(i);
TextCache::VertexList& vertList = cache->vertexLists.at(i++);

vertList.textureIdPtr = &it->first->textureId;
vertList.verts = it->second;
Expand Down