fontservices/fontstore/src/FNTBODY.CPP
author Pat Downey <patd@symbian.org>
Fri, 04 Jun 2010 10:37:54 +0100
changeset 32 8b9155204a54
child 44 601ab138ba0b
permissions -rw-r--r--
Revert last code drop.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
/*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
* Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
* All rights reserved.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
* Initial Contributors:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
* Contributors:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
* Description: 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
#include <s32file.h>
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
#include <fntstore.h>
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
#include "FNTBODY.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
#include <graphics/openfontconstants.h>
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
CFontStoreFile::CFontStoreFile()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
 :	iCollectionUid(KNullUid),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
	iUsageCount(1),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
	iFileStore(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
	iFileAddress(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
	iDataStreamId(KNullStreamId)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
void CFontStoreFile::ConstructL(const TParse& aParse,RFs& aFs)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
	TInt drive;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
	User::LeaveIfError(RFs::CharToDrive(aParse.Drive()[0], drive));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
	TDriveInfo driveinfo;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
	User::LeaveIfError(aFs.Drive(driveinfo, drive));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
	RFile file;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
	// store the filename
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
	iFullName = aParse.FullName().AllocL();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
	User::LeaveIfError(file.Open(aFs, *iFullName, EFileStream | EFileRead | EFileShareReadersOnly));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    45
	// check to see if the fonts are stored on ROM.  Note that NAND != rom so font files in NAND devices
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    46
	// must be handled as if they were in RAM.  A NULL pointer returned by IsFileInRom means its RAM
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
	if (aFs.IsFileInRom(*iFullName)!=NULL)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
		// fonts are stored on a XIP (execute in place) device
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
		TInt ret = file.Seek(ESeekAddress, iFileAddress);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    53
		if (ret != KErrNone)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
			file.Close();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
			User::Leave(ret);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
	// convert RFile into a CDirectFileStore
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    61
	CDirectFileStore* fileStore = CDirectFileStore::FromLC(file);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    62
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    63
	if (fileStore->Type()[1] != TUid::Uid(KFontStoreFileUidVal))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
		User::Leave(KErrNotSupported);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
	TStreamId headerid = fileStore->Root();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    66
	RStoreReadStream stream;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
	stream.OpenLC(*fileStore, headerid);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
	TInt fnttranversion = stream.ReadInt32L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
	// This works for version 42 (with new metrics) and for earlier versions 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
	// which will synthesize the required metrics. It may have to be changed 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
	// if the version number is incremented again.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
	if (fnttranversion < (KFnttranVersion - 1)  && fnttranversion != KFnttran7650Version) 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    73
		User::Leave(KErrNotSupported);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    74
	iFontVersion = fnttranversion;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    75
	stream >> iCollectionUid;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    76
	iKPixelAspectRatio = stream.ReadInt32L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
	stream >> iDataStreamId;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
	CleanupStack::PopAndDestroy(&stream);	// close root stream
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
	// ensure font data stream can be opened
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
	stream.OpenLC(*fileStore, iDataStreamId);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
	CleanupStack::PopAndDestroy(&stream);	// close font stream
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
	// transfer ownership of fileStore
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
	CleanupStack::Pop(fileStore);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
	iFileStore = fileStore;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
CFontStoreFile* CFontStoreFile::NewL(const TParse& aParse, RFs& aFs)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    89
	CFontStoreFile* fontstorefile = new(ELeave) CFontStoreFile;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
	CleanupStack::PushL(fontstorefile);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    91
	fontstorefile->ConstructL(aParse, aFs);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    92
	CleanupStack::Pop();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
	return fontstorefile;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    94
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    95
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
CFontStoreFile::~CFontStoreFile()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    97
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    98
	delete iFullName;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
	iFullName = NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
	delete iFileStore;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
	iFileStore = NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
TBitmapCodeSection::TBitmapCodeSection()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
 :	TCodeSection(),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   106
	iCharacterData(),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   107
	iBitmapData()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   108
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   109
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   111
//This method is called  from CFontBitmap::InternalizeL.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   112
//We have to read stream IDs from the stream, not offsets.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
//Obviously the method is called once per life time of 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   114
//CFontBitmap instance.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
void TBitmapCodeSection::InternalizeL(RReadStream &aStream)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   116
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   117
	iStart = aStream.ReadUint16L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   118
	iEnd = aStream.ReadUint16L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   119
	aStream >> iCharacterData.iOffsetsId;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
	aStream >> iBitmapData.iBitmapId; 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   121
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   122
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
//This method is called  from CFontBitmap::RestoreComponentsL - 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   124
//if the CFontBitmap instance is in RAM and CFontBitmap::iComponentsRestored is EFalse.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   125
//We use here stream IDs, not offsets.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   126
//If the memory allocation for the offsets doesn't fail - aAllocMemCounter is incremented
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   127
//After calling of TBitmapCodeSection::InternalizeOffsetsL character metrics streamID is no more valid - 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
//we have valid character metrics offset into RAM memory.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
void TBitmapCodeSection::InternalizeOffsetsL(const CStreamStore& aStreamStore, RHeap* aHeap, TInt& aAllocMemCounter)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   131
	RStoreReadStream stream;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   132
	stream.OpenLC(aStreamStore, iCharacterData.iOffsetsId);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   133
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   134
	TInt size = stream.ReadInt32L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   135
	TBitmapFontCharacterOffset* characterOffsetsList = (TBitmapFontCharacterOffset*)aHeap->AllocL(sizeof(TBitmapFontCharacterOffset) * size);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   136
	aAllocMemCounter++;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   137
	iCharacterData.iCharacterOffsetsListOffset = TInt(characterOffsetsList) - TInt(this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   138
	TBitmapFontCharacterOffset* pEnd = characterOffsetsList + size;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   139
	for (TBitmapFontCharacterOffset* p = characterOffsetsList; p < pEnd; p++)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   140
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   141
		p->InternalizeL(stream);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   142
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   143
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   144
	CleanupStack::PopAndDestroy();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   145
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   146
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   147
//This method is called  from CFontBitmap::RestoreComponentsL - 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   148
//if the CFontBitmap instance is in RAM and CFontBitmap::iComponentsRestored is EFalse.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   149
//We use here stream IDs, not offsets.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   150
//If the memory allocation for the bitmap doesn't fail - aAllocMemCounter is incremented
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   151
//After calling of TBitmapCodeSection::InternalizeBitmapL bitmap streamID is no more valid - 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   152
//we have valid bitmap offset into RAM memory.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   153
void TBitmapCodeSection::InternalizeBitmapL(const CStreamStore& aStreamStore, RHeap* aHeap, TInt& aAllocMemCounter)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   154
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   155
	RStoreReadStream stream;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   156
	stream.OpenLC(aStreamStore, iBitmapData.iBitmapId);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   157
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   158
	TInt size = stream.ReadInt32L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   159
	TUint8* bitmap = (TUint8*)aHeap->AllocL(size);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   160
	aAllocMemCounter++;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   161
	iBitmapData.iBitmapOffset = TInt(bitmap) - TInt(this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   162
	stream.ReadL(bitmap, size);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   163
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   164
	CleanupStack::PopAndDestroy();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   165
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   166
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   167
//This method is called from CFontBitmap::InternalizeL if the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   168
//CFontBitmap instance is in ROM.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   169
//We use here stream IDs to calculate offsets.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   170
//After calling of TBitmapCodeSection::FixUpComponents streamIDs are no more valid - 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   171
//we have valid offsets into ROM memory.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   172
//Obviously the method is called once per life time of 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   173
//CFontBitmap instance.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   174
void TBitmapCodeSection::FixUpComponents(TInt aFileAddress)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   175
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   176
	TBitmapFontCharacterOffset* characterOffsetsList = (TBitmapFontCharacterOffset*) (aFileAddress + sizeof(TInt) + iCharacterData.iOffsetsId);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   177
	iCharacterData.iCharacterOffsetsListOffset = TInt(characterOffsetsList);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   178
	TUint8* bitmap = (TUint8*) (aFileAddress + sizeof(TInt) + iBitmapData.iBitmapId);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   179
	iBitmapData.iBitmapOffset = TInt(bitmap);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   180
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   181
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   182
//This method is caled from CFontBitmap::DeleteComponents(),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   183
//only if the CFontBitmap instance is in RAM.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   184
void TBitmapCodeSection::DeleteOffsets(RHeap* aHeap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   185
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   186
	TBitmapFontCharacterOffset*  charactersOffsetsList = CharacterOffsetsList(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   187
	if(TUint32(this) != TUint32(charactersOffsetsList))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   188
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   189
		aHeap->Free(charactersOffsetsList);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   190
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   191
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   192
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   193
//This method is caled from CFontBitmap::DeleteComponents(),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   194
//only if the CFontBitmap instance is in RAM.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   195
void TBitmapCodeSection::DeleteBitmap(RHeap* aHeap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   196
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   197
	TUint8* bitmap = Bitmap(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   198
	if(TUint32(this) != TUint32(bitmap))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   199
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   200
		aHeap->Free(bitmap);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   201
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   202
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   203
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   204
TBitmapFontCharacterOffset* TBitmapCodeSection::CharacterOffsetsList(TBool aIsInRAM) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   205
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   206
	return reinterpret_cast <TBitmapFontCharacterOffset*> 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   207
		(iCharacterData.iCharacterOffsetsListOffset + (aIsInRAM ? TInt(this) : 0));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   208
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   209
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   210
TUint8* TBitmapCodeSection::Bitmap(TBool aIsInRAM) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   211
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   212
	return reinterpret_cast <TUint8*> 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   213
		(iBitmapData.iBitmapOffset + (aIsInRAM ? TInt(this) : 0));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   214
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   215
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   216
TCharacterMetricsTable::TCharacterMetricsTable(RHeap* aHeap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   217
 :	iHeap(aHeap),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   218
	iMetricsStartId(KNullStreamId),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   219
	iCharacterMetricsStartPtr(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   220
	iNumberOfMetrics(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   221
	iMetricsOnHeap(EFalse)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   222
	{}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   223
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   224
void TCharacterMetricsTable::InternalizeL(RReadStream& aStream)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   225
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   226
	iMetricsStartId = aStream.ReadInt32L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   227
	iNumberOfMetrics = aStream.ReadInt32L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   228
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   229
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   230
void TCharacterMetricsTable::InternalizeMetricsL(RReadStream& aStream)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   231
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   232
	aStream.ReadInt32L(); // size
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   233
	TBitmapFontCharacterMetrics* charactermetricslist = static_cast<TBitmapFontCharacterMetrics*>(iHeap->AllocL(sizeof(TBitmapFontCharacterMetrics) * iNumberOfMetrics));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   234
	iMetricsOnHeap = ETrue;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   235
	// Offset from this to location on the heap ('cos the file is not in ROM)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   236
	iCharacterMetricsStartPtr = reinterpret_cast<TInt>(charactermetricslist) - reinterpret_cast<TInt>(this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   237
	TBitmapFontCharacterMetrics* pEnd = charactermetricslist + iNumberOfMetrics;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   238
	for (TBitmapFontCharacterMetrics* p = charactermetricslist; p < pEnd; p++)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   239
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   240
		p->InternalizeL(aStream);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   241
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   242
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   243
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   244
void TCharacterMetricsTable::RestoreL(const CStreamStore& aStreamStore)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   245
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   246
	if (iCharacterMetricsStartPtr == 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   247
		{	// We haven't already read it in from RAM file
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   248
		RStoreReadStream stream;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   249
		stream.OpenLC(aStreamStore, iMetricsStartId);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   250
		InternalizeMetricsL(stream);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   251
		CleanupStack::PopAndDestroy();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   252
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   253
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   254
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   255
void TCharacterMetricsTable::FixUp(TInt aFileAddress)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   256
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   257
	TBitmapFontCharacterMetrics* charactermetricslist = reinterpret_cast<TBitmapFontCharacterMetrics*>(aFileAddress + sizeof(TInt) + iMetricsStartId.Value());
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   258
	iCharacterMetricsStartPtr = TInt(charactermetricslist);	// Ptr to location in a ROM file
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   259
	iMetricsStartId = KNullStreamId;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   260
	iMetricsOnHeap = EFalse;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   261
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   262
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   263
void TCharacterMetricsTable::Delete()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   264
	{	// This routine is only called if the font file is in RAM, not ROM, and therefore the metrics have been stashed on the heap
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   265
    if (iMetricsOnHeap && iCharacterMetricsStartPtr)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   266
        {
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   267
        iHeap->Free(reinterpret_cast<TAny*>(MetricsFromOffset(0)));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   268
        iCharacterMetricsStartPtr = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   269
        iMetricsOnHeap = EFalse;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   270
        }
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   271
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   272
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   273
const TBitmapFontCharacterMetrics* TCharacterMetricsTable::Metric(TInt aIndex) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   274
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   275
	__ASSERT_DEBUG((aIndex >= 0) && (aIndex <= iNumberOfMetrics), Panic(EFntMetricsIndexOutOfBounds));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   276
    // Sometimes the start ptr is to a metrics heap item and sometimes it points into a ROM file
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   277
    if (iMetricsOnHeap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   278
        {
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   279
        // Start ptr is to metrics heap item
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   280
        return MetricsFromOffset(aIndex);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   281
        }
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   282
    else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   283
        {
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   284
        // Start ptr is to a file in ROM
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   285
        return reinterpret_cast<const TBitmapFontCharacterMetrics*> (iCharacterMetricsStartPtr + (aIndex * sizeof(TBitmapFontCharacterMetrics)));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   286
        }
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   287
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   288
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   289
TInt TCharacterMetricsTable::NumberOfMetrics() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   290
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   291
	return iNumberOfMetrics;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   292
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   293
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   294
TBitmapFontCharacterMetrics* TCharacterMetricsTable::MetricsFromOffset(TInt aIndex) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   295
    {
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   296
    __ASSERT_DEBUG(iMetricsOnHeap,Panic(EFntMetricsNotOnHeap));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   297
    return reinterpret_cast<TBitmapFontCharacterMetrics*>(reinterpret_cast<TInt>(this) + iCharacterMetricsStartPtr+ (aIndex * sizeof(TBitmapFontCharacterMetrics)));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   298
    }
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   299
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   300
CFontBitmap::CFontBitmap(RHeap* aHeap, CFontStoreFile* aFontStoreFile)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   301
 :	iHeap(aHeap),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   302
	iFontStoreFileOffset(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   303
	iUid(KNullUid),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   304
	iPosture(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   305
	iStrokeWeight(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   306
	iIsProportional(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   307
	iIsInRAM(!aFontStoreFile->iFileAddress),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   308
	iUsageCount(1),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   309
	iCellHeightInPixels(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   310
	iAscentInPixels(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   311
	iMaxCharWidthInPixels(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   312
	iMaxNormalCharWidthInPixels(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   313
	iBitmapEncoding(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   314
	iNumCodeSections(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   315
	iCodeSectionListOffset(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   316
	iCharacterMetricsTable(aHeap),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   317
	iComponentsRestored(EFalse),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   318
	iAllocMemCounter_Offsets(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   319
	iAllocMemCounter_Bitmaps(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   320
	iFontCapitalAscent(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   321
	iFontMaxAscent(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   322
	iFontStandardDescent(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   323
	iFontMaxDescent(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   324
	iFontLineGap(0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   325
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   326
	iFontStoreFileOffset = TInt(aFontStoreFile) - TInt(this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   327
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   328
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   329
void CFontBitmap::InternalizeL(RReadStream &aStream, TInt aFontVersion)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   330
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   331
	aStream >> iUid;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   332
	iPosture = aStream.ReadInt8L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   333
	iStrokeWeight = aStream.ReadInt8L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   334
	iIsProportional = aStream.ReadInt8L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   335
	iCellHeightInPixels = aStream.ReadInt8L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   336
	iAscentInPixels = aStream.ReadInt8L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   337
	iMaxCharWidthInPixels = aStream.ReadInt8L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   338
	iMaxNormalCharWidthInPixels = aStream.ReadInt8L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   339
	if ( aFontVersion  >= KFnttranVersion )
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   340
		{ // read the new metrics in
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   341
		iFontCapitalAscent = aStream.ReadInt8L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   342
		iFontMaxAscent = aStream.ReadInt8L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   343
		iFontStandardDescent = aStream.ReadInt8L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   344
		iFontMaxDescent = aStream.ReadInt8L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   345
		iFontLineGap = aStream.ReadInt8L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   346
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   347
	else // synthesize the extra metrics (data compatibility with third party bitmap fonts for old phones)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   348
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   349
		iFontMaxAscent = iFontCapitalAscent = iAscentInPixels;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   350
		iFontMaxDescent = iFontStandardDescent = iCellHeightInPixels - iAscentInPixels;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   351
		iFontLineGap = ( ( iCellHeightInPixels * 12 ) + 5) / 10;  // 1.2 times design height
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   352
		}	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   353
	iBitmapEncoding = aStream.ReadInt32L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   354
	iCharacterMetricsTable.InternalizeL(aStream);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   355
	const TBool fixup = FontStoreFile()->iFileAddress;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   356
	if (fixup)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   357
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   358
		iCharacterMetricsTable.FixUp(FontStoreFile()->iFileAddress);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   359
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   360
	iNumCodeSections = aStream.ReadInt32L();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   361
	TBitmapCodeSection* codesectionlist = (TBitmapCodeSection*)User::LeaveIfNull(iHeap->AllocL(iNumCodeSections * sizeof(TBitmapCodeSection)));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   362
	iCodeSectionListOffset = TInt(codesectionlist) - TInt(this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   363
	for (TInt i = 0; i < iNumCodeSections; i++)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   364
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   365
		new(codesectionlist + i) TBitmapCodeSection;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   366
		codesectionlist[i].InternalizeL(aStream);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   367
		if (fixup)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   368
			codesectionlist[i].FixUpComponents(FontStoreFile()->iFileAddress);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   369
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   370
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   371
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   372
void CFontBitmap::UseL()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   373
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   374
	// Note object is created with a Usage Count of 1.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   375
	// So incrementing to 2 normally indicates the first external reference.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   376
	iUsageCount++;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   377
	if (iUsageCount == 2)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   378
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   379
		RestoreComponentsL();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   380
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   381
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   382
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   383
void CFontBitmap::Release()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   384
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   385
	iUsageCount--;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   386
	if (!iUsageCount)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   387
		{ // object and all its users have closed
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   388
		delete this;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   389
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   390
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   391
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   392
/*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   393
Get the metrics for a given character.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   394
Return aBytes as null if the character aCode doesn't exist in the font.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   395
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   396
TBitmapFontCharacterMetrics CFontBitmap::CharacterMetrics(TInt aCode, const TUint8*& aBytes) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   397
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   398
 	const TBitmapCodeSection* matchSection = NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   399
	const TBitmapCodeSection* const lastSection = CodeSectionList() + iNumCodeSections - 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   400
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   401
	TBitmapFontCharacterOffset offset;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   402
	aBytes = NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   403
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   404
	TBitmapFontCharacterMetrics metrics;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   405
	const TBitmapCodeSection* startSearchBand = CodeSectionList();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   406
	TInt numCodeSectionsRemaining = iNumCodeSections;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   407
	while (numCodeSectionsRemaining >= 1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   408
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   409
		TInt halfNumCodeSectionsRemaining = numCodeSectionsRemaining/2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   410
		const TBitmapCodeSection* centralSearchBand = startSearchBand+halfNumCodeSectionsRemaining;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   411
		if ((aCode >= centralSearchBand->iStart) && (aCode <= centralSearchBand->iEnd))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   412
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   413
			matchSection = centralSearchBand;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   414
			break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   415
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   416
		else if ((aCode < centralSearchBand->iStart) || (centralSearchBand == lastSection))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   417
			numCodeSectionsRemaining = halfNumCodeSectionsRemaining;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   418
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   419
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   420
			startSearchBand = centralSearchBand + 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   421
			numCodeSectionsRemaining -= halfNumCodeSectionsRemaining + 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   422
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   423
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   424
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   425
	if (matchSection)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   426
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   427
		offset =* ((matchSection->CharacterOffsetsList(iIsInRAM)) + (aCode-matchSection->iStart));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   428
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   429
		// Fill characters within code section.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   430
		// Recursive call ensures that a valid metric is always returned.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   431
		if (offset.iBitmapOffset == KFillCharacterOffset)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   432
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   433
			return CharacterMetrics(KReplacementCharacter, aBytes);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   434
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   435
		
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   436
		aBytes = matchSection->Bitmap(iIsInRAM) + offset.iBitmapOffset;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   437
		
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   438
		// retrieve metric index from encoded 1 or 2 bytes
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   439
		TInt index = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   440
		TUint8 byte1 = (TUint8)*aBytes;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   441
		const TInt switchMask = 0x1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   442
		const TBool oneByteIndex =! (byte1 & switchMask);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   443
		byte1 = TUint8(byte1 >> 1);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   444
		if (oneByteIndex)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   445
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   446
			index = byte1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   447
			aBytes += 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   448
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   449
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   450
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   451
			const TUint8 byte2 = (TUint8)(*(aBytes + 1));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   452
			index = byte1 + (byte2 * 128);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   453
			aBytes += 2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   454
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   455
		// Copy metric from table
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   456
		metrics =* iCharacterMetricsTable.Metric(index);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   457
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   458
	return metrics;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   459
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   460
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   461
void CFontBitmap::operator delete(TAny *aThis)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   462
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   463
	if (((CFontBitmap *)aThis)->iHeap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   464
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   465
		((CFontBitmap *)aThis)->iHeap->Free(aThis);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   466
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   467
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   468
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   469
void CFontBitmap::SetPosture(TFontPosture aPosture)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   470
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   471
	iPosture = (TInt8)aPosture;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   472
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   473
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   474
TFontPosture CFontBitmap::Posture() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   475
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   476
	return (TFontPosture)iPosture;	 // iPosture is always smaller than TFontPosture
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   477
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   478
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   479
void CFontBitmap::SetStrokeWeight(TFontStrokeWeight aStrokeWeight)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   480
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   481
	iStrokeWeight = (TInt8)aStrokeWeight;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   482
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   483
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   484
TFontStrokeWeight CFontBitmap::StrokeWeight() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   485
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   486
	return (TFontStrokeWeight)iStrokeWeight;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   487
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   488
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   489
void CFontBitmap::SetIsProportional(TBool aIsProportional)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   490
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   491
	iIsProportional = (TInt8)aIsProportional;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   492
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   493
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   494
TBool CFontBitmap::IsProportional() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   495
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   496
	return iIsProportional;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   497
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   498
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   499
CFontStoreFile* CFontBitmap::FontStoreFile() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   500
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   501
	TInt fsf = TInt(this) + iFontStoreFileOffset;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   502
	return (CFontStoreFile*)fsf;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   503
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   504
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   505
CFontBitmap::~CFontBitmap()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   506
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   507
	DeleteComponents();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   508
	TBitmapCodeSection* codeSectionList = CodeSectionList();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   509
	if(TUint32(this) != TUint32(codeSectionList))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   510
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   511
		iHeap->Free(codeSectionList);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   512
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   513
	iCodeSectionListOffset = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   514
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   515
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   516
//We have to count how many offsets and bitmaps are allocated successfully because if
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   517
//some of codesection's Internalize..L fails we have to deallocate the right amount of 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   518
//data.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   519
void CFontBitmap::RestoreComponentsL()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   520
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   521
	if (iIsInRAM)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   522
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   523
		if(!iComponentsRestored)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   524
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   525
			iAllocMemCounter_Offsets = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   526
			iAllocMemCounter_Bitmaps = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   527
			CStreamStore& store =* FontStoreFile()->iFileStore;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   528
			for (TInt i = 0; i < iNumCodeSections; i++)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   529
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   530
				CodeSectionList()[i].InternalizeOffsetsL(store, iHeap, iAllocMemCounter_Offsets);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   531
				CodeSectionList()[i].InternalizeBitmapL(store, iHeap, iAllocMemCounter_Bitmaps);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   532
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   533
			iCharacterMetricsTable.RestoreL(store);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   534
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   535
		iComponentsRestored = ETrue;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   536
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   537
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   538
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   539
void CFontBitmap::DeleteComponents()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   540
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   541
	if (iIsInRAM)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   542
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   543
		TInt i;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   544
		for (i = 0; i < iAllocMemCounter_Offsets; i++)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   545
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   546
			CodeSectionList()[i].DeleteOffsets(iHeap);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   547
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   548
		for (i = 0; i < iAllocMemCounter_Bitmaps; i++)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   549
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   550
			CodeSectionList()[i].DeleteBitmap(iHeap);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   551
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   552
		iCharacterMetricsTable.Delete();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   553
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   554
	iAllocMemCounter_Offsets = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   555
	iAllocMemCounter_Bitmaps = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   556
	iComponentsRestored = EFalse;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   557
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   558
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   559
TBitmapCodeSection* CFontBitmap::CodeSectionList() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   560
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   561
	TInt bcs = TInt(this) + iCodeSectionListOffset;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   562
	return (TBitmapCodeSection*)bcs;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   563
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   564
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   565
TTypefaceFontBitmap::TTypefaceFontBitmap()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   566
 :	iTypeface(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   567
	iFontBitmap(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   568
	iHeightFactor(1),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   569
	iWidthFactor(1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   570
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   571
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   572
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   573
TTypefaceFontBitmap::TTypefaceFontBitmap(TTypeface* aTypeface,CFontBitmap* aFontBitmap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   574
 :	iTypeface(aTypeface),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   575
	iFontBitmap(aFontBitmap),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   576
	iHeightFactor(1),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   577
	iWidthFactor(1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   578
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   579
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   580
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   581
TInt TTypefaceFontBitmap::HeightInPixels() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   582
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   583
	return iFontBitmap->iCellHeightInPixels * iHeightFactor;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   584
	}