diff --git a/es-core/src/resources/Font.cpp b/es-core/src/resources/Font.cpp index c91f7e100..5a1d35ea6 100644 --- a/es-core/src/resources/Font.cpp +++ b/es-core/src/resources/Font.cpp @@ -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; @@ -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()); @@ -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;