// EIKFONT.CPP
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//

#include <barsread.h>
#include <eikfont.hrh>
#include <eikfont.h>
#include <eikrutil.h>

// CEikCleanupStackableFont

CEikCleanupStackableFont::CEikCleanupStackableFont(CWsScreenDevice& aScreenDevice)
	:iScreenDevice(aScreenDevice)
	{
	__DECLARE_NAME(_S("CEikCleanupStackableFont"));
	}

EXPORT_C CEikCleanupStackableFont* CEikCleanupStackableFont::NewL(TResourceReader& aResourceReader, CWsScreenDevice& aScreenDevice)
	{
	CEikCleanupStackableFont* font=NewLC(aResourceReader, aScreenDevice); // also pushes on to CleanupStack
	CleanupStack::Pop();
	return font;
	}

EXPORT_C CEikCleanupStackableFont* CEikCleanupStackableFont::NewLC(TResourceReader& aResourceReader, CWsScreenDevice& aScreenDevice)
	{
	CEikCleanupStackableFont* font=new(ELeave) CEikCleanupStackableFont(aScreenDevice);
	CleanupStack::PushL(font);
	font->iFont=EikResourceUtils::CreateScreenFontL(aResourceReader,aScreenDevice);
	return font;
	}

EXPORT_C CEikCleanupStackableFont::~CEikCleanupStackableFont()
	{
	iScreenDevice.ReleaseFont(iFont); // N.B. do not do "delete iFont"
	}

EXPORT_C CFbsFont& CEikCleanupStackableFont::Font() const
	{
	return *iFont;
	}

EXPORT_C CFbsFont* CEikCleanupStackableFont::TakeOwnershipOfFont()
	{
	CFbsFont* font=iFont;
	iFont=NULL;
	return font;
	}

