Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6b34891 authored by Alex Sakhartchouk's avatar Alex Sakhartchouk
Browse files

Fixing freetype init/uninit code.

Removing debug output from stream.

Change-Id: I401232e77cc011953e5ccc59069b22ec59958214
parent 81ea83d1
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ Font::Font(Context *rsc) : ObjectBase(rsc), mCachedGlyphs(NULL)
    mAllocLine = __LINE__;
    mInitialized = false;
    mHasKerning = false;
    mFace = NULL;
}

bool Font::init(const char *name, uint32_t fontSize, uint32_t dpi)
@@ -63,8 +64,6 @@ bool Font::init(const char *name, uint32_t fontSize, uint32_t dpi)
    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 @@ Font::CachedGlyphInfo *Font::cacheGlyph(uint32_t glyph)
    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 @@ FontState::FontState()
    mMaxNumberOfQuads = 1024;
    mCurrentQuadIndex = 0;
    mRSC = NULL;
    mLibrary = NULL;
}

FontState::~FontState()
@@ -281,13 +279,12 @@ FT_Library FontState::getLib()
            return NULL;
        }
    }

    return mLibrary;
}

void FontState::init(Context *rsc)
{
    //getLib();

    mRSC = rsc;
}

@@ -350,8 +347,6 @@ bool FontState::cacheBitmap(FT_Bitmap *bitmap, uint32_t *retOriginX, uint32_t *r
    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 @@ void FontState::checkInit()

    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 @@ void FontState::renderText(const char *text, uint32_t len, uint32_t startIndex,
        }
        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 @@ void FontState::deinit(Context *rsc)

    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;
    }
}

+0 −1
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ void IStream::loadString(String8 *s)
{
    uint32_t len = loadU32();
    s->setTo((const char *)&mData[mPos], len);
    LOGE("loadString %s", s->string());
    mPos += len;
}