Thanks Colin for the reply. I thought similar as well but it looks like is there is a another connection as well. below stack trace shows how Typeface destructor could be called which was created in
FontFamily_addFont .
-------------------------------------------------
~SkTypeface_AndroidStream
SkRefCntBase::unref() const
~SkScalerContext_FreeType
~SkGlyphCache
SkGlyphCache_Globals::internalPurge(unsigned long)
SkGlyphCache_Globals::attachCacheToHead(SkGlyphCache*)
SkFunctionWrapper<void, SkGlyphCache, &SkGlyphCache::AttachCache>::operator()(SkGlyphCache*)
SkCanvas::onDrawPosText(void const*, unsigned long, SkPoint const*, SkPaint const&)
android::SkiaCanvas::drawGlyphs(unsigned short const*, float const*, int, SkPaint const&, float, float, float, float, float, float, float)
void android::MinikinUtils::forFontRun<android::DrawTextFunctor>(android::Layout const&, android::Paint*, android::DrawTextFunctor&)
android::Canvas::drawText(unsigned short const*, int, int, int, float, float, int, android::Paint const&, android::Typeface*)
drawTextString - android_graphics_Canvas.cpp
--------------------------------------------------------
clearly SkScalerContext also contains the same typeface and typeface destructor could be invoke from destructor of SkScalerContext as we have not increased it's ref count when assigning to Minikinfontskia
------------------------------
callstack for SkScalerContext creation which contains the same typeface
SkScalerContext
SkScalerContext_FreeType_Base
SkTypeface_FreeType::onCreateScalerContext(SkDescriptor const*) const
SkTypeface::createScalerContext(SkDescriptor const*, bool) const
SkGlyphCache::VisitCache(SkTypeface*, SkDescriptor const*, bool (*)(SkGlyphCache const*, void*), void*)
SkGlyphCache::DetachCache(SkTypeface*, SkDescriptor const*)
SkPaint::descriptorProc(SkSurfaceProps const*, SkPaint::FakeGamma, SkMatrix const*, void (*)(SkTypeface*, SkDescriptor const*, void*), void*) const
SkPaint::detachCache(SkSurfaceProps const*, SkPaint::FakeGamma, SkMatrix const*) const
android::MinikinFontSkia::GetHorizontalAdvance(unsigned int, android::MinikinPaint const&) const
---------------------------