Fixing freetype init/uninit code.
Removing debug output from stream.
Change-Id: I401232e77cc011953e5ccc59069b22ec59958214
diff --git a/rsFont.cpp b/rsFont.cpp
index 694ea16..2a47ca4 100644
--- a/rsFont.cpp
+++ b/rsFont.cpp
@@ -39,6 +39,7 @@
mAllocLine = __LINE__;
mInitialized = false;
mHasKerning = false;
+ mFace = NULL;
}
bool Font::init(const char *name, uint32_t fontSize, uint32_t dpi)
@@ -63,8 +64,6 @@
mFontSize = fontSize;
mDpi = dpi;
- //LOGE("Font initialized: %s", fullPath.string());
-
error = FT_Set_Char_Size(mFace, fontSize * 64, 0, dpi, 0);
if(error) {
LOGE("Unable to set font size on %s", fullPath.string());
@@ -206,8 +205,6 @@
newGlyph->mGlyphIndex = FT_Get_Char_Index(mFace, glyph);
newGlyph->mIsValid = false;
- //LOGE("Glyph = %c, face index: %u", (unsigned char)glyph, newGlyph->mGlyphIndex);
-
updateGlyphCache(newGlyph);
return newGlyph;
@@ -261,6 +258,7 @@
mMaxNumberOfQuads = 1024;
mCurrentQuadIndex = 0;
mRSC = NULL;
+ mLibrary = NULL;
}
FontState::~FontState()
@@ -281,13 +279,12 @@
return NULL;
}
}
+
return mLibrary;
}
void FontState::init(Context *rsc)
{
- //getLib();
-
mRSC = rsc;
}
@@ -350,8 +347,6 @@
uint32_t endX = startX + bitmap->width;
uint32_t endY = startY + bitmap->rows;
- //LOGE("Bitmap width, height = %i, %i", (int)bitmap->width, (int)bitmap->rows);
-
uint32_t cacheWidth = getCacheTextureType()->getDimX();
unsigned char *cacheBuffer = (unsigned char*)mTextTexture->getPtr();
@@ -508,13 +503,6 @@
initVertexArrayBuffers();
- /*mTextMeshRefs = new ObjectBaseRef<SimpleMesh>[mNumMeshes];
-
- for(uint32_t i = 0; i < mNumMeshes; i ++){
- SimpleMesh *textMesh = createTextMesh();
- mTextMeshRefs[i].set(textMesh);
- }*/
-
mInitialized = true;
}
@@ -626,6 +614,11 @@
}
currentFont = mDefault.get();
}
+ if(!currentFont) {
+ LOGE("Unable to initialize any fonts");
+ return;
+ }
+
currentFont->renderUTF(text, len, startIndex, numGlyphs, x, y);
if(mCurrentQuadIndex != 0) {
@@ -681,8 +674,14 @@
mDefault.clear();
+ Vector<Font*> fontsToDereference = mActiveFonts;
+ for(uint32_t i = 0; i < fontsToDereference.size(); i ++) {
+ fontsToDereference[i]->zeroUserRef();
+ }
+
if(mLibrary) {
FT_Done_FreeType( mLibrary );
+ mLibrary = NULL;
}
}