os/graphics/fbs/fontandbitmapserver/sfbs/TFSTORE.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <e32hal.h>
sl@0
    17
#include <fbs.h>
sl@0
    18
#include "UTILS.H"
sl@0
    19
#include <linkedfonts.h>
sl@0
    20
#include "FbsMessage.H"
sl@0
    21
sl@0
    22
GLREF_C void Panic(TFbsPanic aPanic);
sl@0
    23
sl@0
    24
CFbsTypefaceStore::CFbsTypefaceStore(CGraphicsDevice* aDevice):
sl@0
    25
	CTypefaceStore(),
sl@0
    26
	iDevice(aDevice),
sl@0
    27
	iTwipsCache(NULL)
sl@0
    28
	{
sl@0
    29
	}
sl@0
    30
sl@0
    31
/** 
sl@0
    32
@publishedAll 
sl@0
    33
@released
sl@0
    34
*/
sl@0
    35
EXPORT_C CFbsTypefaceStore::~CFbsTypefaceStore()
sl@0
    36
	{
sl@0
    37
	if(iTwipsCache)
sl@0
    38
		{
sl@0
    39
		ReleaseTwipsCache();
sl@0
    40
		delete iTwipsCache;
sl@0
    41
		}
sl@0
    42
	}
sl@0
    43
sl@0
    44
/** Allocates and constructs a CFbsTypefaceStore, specifying a graphics device.
sl@0
    45
@param aDevice A pointer to a graphics device.
sl@0
    46
@return A pointer to the newly created typeface store. 
sl@0
    47
@publishedAll 
sl@0
    48
@released
sl@0
    49
*/
sl@0
    50
EXPORT_C CFbsTypefaceStore* CFbsTypefaceStore::NewL(CGraphicsDevice* aDevice)
sl@0
    51
	{
sl@0
    52
	CFbsTypefaceStore* thisptr=new(ELeave) CFbsTypefaceStore(aDevice);
sl@0
    53
	CleanupStack::PushL(thisptr);
sl@0
    54
	thisptr->ConstructL();
sl@0
    55
	CleanupStack::Pop();
sl@0
    56
	return(thisptr);
sl@0
    57
	}
sl@0
    58
sl@0
    59
sl@0
    60
void CFbsTypefaceStore::ConstructL()
sl@0
    61
	{
sl@0
    62
	// get the session info from the Tls
sl@0
    63
	iFbs = RFbsSession::GetSession();
sl@0
    64
	if (!iFbs)
sl@0
    65
		{
sl@0
    66
		User::Leave(KErrCouldNotConnect);
sl@0
    67
		}
sl@0
    68
	CTypefaceStore::ConstructL();
sl@0
    69
	iTwipsCache = new(ELeave) CFontCache;
sl@0
    70
	}
sl@0
    71
sl@0
    72
sl@0
    73
/** Installs a font store file into the typeface store.
sl@0
    74
All the fonts in added and installed font files are available to the
sl@0
    75
GetNearestFont...() family of functions.
sl@0
    76
Additionally Bitmap Fonts are also available to GetFontById().
sl@0
    77
sl@0
    78
Installed files remain in the typeface store even after the client which added 
sl@0
    79
them is destroyed. They can be removed using RemoveFile().
sl@0
    80
@param aName The name of the file to be installed.
sl@0
    81
@param aId On return, contains the id of the installed file.
sl@0
    82
@return KErrNone if successful, otherwise another of the system-wide error 
sl@0
    83
codes.
sl@0
    84
@see AddFile()
sl@0
    85
@see RemoveFile()
sl@0
    86
@see GetFontById()
sl@0
    87
@see GetNearestFontToDesignHeightInTwips()
sl@0
    88
@see GetNearestFontToDesignHeightInPixels()
sl@0
    89
@see GetNearestFontToMaxHeightInTwips()
sl@0
    90
@see GetNearestFontToMaxHeightInPixels()
sl@0
    91
@publishedAll 
sl@0
    92
@released
sl@0
    93
*/
sl@0
    94
EXPORT_C TInt CFbsTypefaceStore::InstallFile(const TDesC& aName,TInt& aId)
sl@0
    95
	{
sl@0
    96
	TPckgBuf<TIntParcel> ip;
sl@0
    97
	aId=0;
sl@0
    98
	TIpcArgs args(&aName,aName.Length(),&ip);
sl@0
    99
	TInt ret=iFbs->SendCommand(EFbsMessInstallFontStoreFile,args);
sl@0
   100
	if(ret==KErrNone)
sl@0
   101
		aId=ip().iInt;
sl@0
   102
	return(ret);
sl@0
   103
	}
sl@0
   104
sl@0
   105
/** Adds a font store file to the typeface store.
sl@0
   106
All the fonts in added and installed font files are available to the
sl@0
   107
GetNearestFont...() family of functions.
sl@0
   108
Additionally Bitmap Fonts are also available to GetFontById().
sl@0
   109
sl@0
   110
This function adds the typeface to a reference counted list of fonts. Each 
sl@0
   111
client that adds the typeface to the store increases the reference count. 
sl@0
   112
The count is decremented when a client using the typeface is destroyed or 
sl@0
   113
calls the RemoveFile() function. The typeface is removed from the store only 
sl@0
   114
when the the reference count is zero (it is not being used by any clients).
sl@0
   115
The InstallFile() function is similar, except that the typeface is not reference 
sl@0
   116
counted, and is hence not removed when all the clients using it are destroyed.
sl@0
   117
@param aName A descriptor containing the filename of the typeface store
sl@0
   118
@param aId On return, contains the id of the typeface.
sl@0
   119
@return KErrNone if successful, otherwise another of the system-wide error 
sl@0
   120
codes.
sl@0
   121
@see InstallFile()
sl@0
   122
@see RemoveFile()
sl@0
   123
@see GetFontById()
sl@0
   124
@see GetNearestFontToDesignHeightInTwips()
sl@0
   125
@see GetNearestFontToDesignHeightInPixels()
sl@0
   126
@see GetNearestFontToMaxHeightInTwips()
sl@0
   127
@see GetNearestFontToMaxHeightInPixels()
sl@0
   128
@publishedAll 
sl@0
   129
@released
sl@0
   130
*/
sl@0
   131
EXPORT_C TInt CFbsTypefaceStore::AddFile(const TDesC& aName,TInt& aId)
sl@0
   132
	{
sl@0
   133
	TPckgBuf<TIntParcel> ip;
sl@0
   134
	aId=0;
sl@0
   135
	TIpcArgs args(&aName,aName.Length(),&ip);
sl@0
   136
	TInt ret=iFbs->SendCommand(EFbsMessAddFontStoreFile,args);
sl@0
   137
	if(ret==KErrNone)
sl@0
   138
		aId=ip().iInt;
sl@0
   139
	return(ret);
sl@0
   140
	}
sl@0
   141
sl@0
   142
/** Decrements the reference count of a file which was added using 
sl@0
   143
AddFile(), and removes it from the store if the reference count reaches zero. 
sl@0
   144
If the font was not found in the list of reference-counted files (see AddFile()) 
sl@0
   145
it is assumed to be an installed file (see InstallFile()) and an attempt is 
sl@0
   146
made to remove it anyway.
sl@0
   147
sl@0
   148
If the id given is 0, an attempt is made to remove all font objects from the 
sl@0
   149
font store provided none of the fonts in the store are currently accessed,
sl@0
   150
otherwise it has no effect.
sl@0
   151
sl@0
   152
Note:
sl@0
   153
The id passed to this function has a different meaning depending on whether 
sl@0
   154
or not the file is a Symbian-format bitmap file. If it is a Symbian-format 
sl@0
   155
bitmap file the id is a UID, and is the same from one session to the next. 
sl@0
   156
If it is an Open Font System file (e.g., a TrueType file) the id is an arbitrary 
sl@0
   157
number. Consequently the id may vary from one session to the next, and should 
sl@0
   158
not be saved in a file: however it may be kept and used by a client as 
sl@0
   159
long as the client is running.
sl@0
   160
sl@0
   161
@param aId The id of the file to be removed/decremented, set by AddFile() 
sl@0
   162
or InstallFile().
sl@0
   163
@see AddFile()
sl@0
   164
@see InstallFile()
sl@0
   165
@publishedAll 
sl@0
   166
@released
sl@0
   167
*/
sl@0
   168
EXPORT_C void CFbsTypefaceStore::RemoveFile(TInt aId)
sl@0
   169
	{
sl@0
   170
	iFbs->SendCommand(EFbsMessRemoveFontStoreFile,aId);
sl@0
   171
	}
sl@0
   172
sl@0
   173
/** Gets the number of typefaces supported by this store.
sl@0
   174
@return The number of supported typefaces. 
sl@0
   175
@see CTypefaceStore::NumTypefaces()
sl@0
   176
@publishedAll 
sl@0
   177
@released
sl@0
   178
*/
sl@0
   179
EXPORT_C TInt CFbsTypefaceStore::NumTypefaces() const
sl@0
   180
	{
sl@0
   181
	return(iFbs->SendCommand(EFbsMessNumTypefaces));
sl@0
   182
	}
sl@0
   183
sl@0
   184
/**
sl@0
   185
Gets the font which is the nearest to the given font specification.
sl@0
   186
sl@0
   187
When the font is no longer needed, call @c ReleaseFont().
sl@0
   188
sl@0
   189
Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInTwips() 
sl@0
   190
yielding (virtually) the same result. However clients are strongly encouraged to use the new
sl@0
   191
@c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every 
sl@0
   192
character within any given text string will fit within the given amount of twips, whereas the design 
sl@0
   193
height is an aesthetic unit decided by the font designer without strict physical meaning, which 
sl@0
   194
may result in cropped characters.
sl@0
   195
sl@0
   196
Chooses from the fonts loaded at system startup or through the AddFile()
sl@0
   197
or InstallFile() APIs.
sl@0
   198
sl@0
   199
@param aFont On return, contains a pointer to the nearest font.
sl@0
   200
@param aFontSpec The specification of the font to be matched.
sl@0
   201
@return KErrNone if successful; a system-wide error code otherwise.
sl@0
   202
@publishedAll
sl@0
   203
@see GetNearestFontToDesignHeightInTwips()
sl@0
   204
@see GetNearestFontToMaxHeightInTwips()
sl@0
   205
@see AddFile()
sl@0
   206
@see InstallFile()
sl@0
   207
*/
sl@0
   208
EXPORT_C TInt CFbsTypefaceStore::GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec)
sl@0
   209
	{
sl@0
   210
	return GetNearestFontToDesignHeightInTwips(aFont, aFontSpec);
sl@0
   211
	}
sl@0
   212
sl@0
   213
/**
sl@0
   214
Gets the font which is the nearest to the given font specification.
sl@0
   215
sl@0
   216
When the font is no longer needed, call @c ReleaseFont().
sl@0
   217
sl@0
   218
Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInPixels() 
sl@0
   219
yielding (virtually) the same result. However clients are strongly encouraged to use the new
sl@0
   220
@c GetNearestFontToMaxHeightInPixels() function instead. This will guarantee that every 
sl@0
   221
character within any given text string will fit within the given amount of pixels, whereas the design 
sl@0
   222
height is an aesthetic unit decided by the font designer without strict physical meaning, which 
sl@0
   223
may result in cropped characters.
sl@0
   224
sl@0
   225
Chooses from the fonts loaded at system startup or through the AddFile()
sl@0
   226
or InstallFile() APIs.
sl@0
   227
sl@0
   228
@param aFont On return, contains a pointer to the nearest font.
sl@0
   229
@param aFontSpec The specification of the font to be matched.
sl@0
   230
@return KErrNone if successful; a system-wide error code otherwise.
sl@0
   231
@publishedAll
sl@0
   232
@deprecated Use GetNearestFontToDesignHeightInPixels
sl@0
   233
@see GetNearestFontToDesignHeightInPixels()
sl@0
   234
@see GetNearestFontToMaxHeightInPixels()
sl@0
   235
@see AddFile()
sl@0
   236
@see InstallFile()
sl@0
   237
*/
sl@0
   238
EXPORT_C TInt CFbsTypefaceStore::GetNearestFontInPixels(CFont*& aFont,const TFontSpec& aFontSpec)
sl@0
   239
	{
sl@0
   240
	return GetNearestFontToDesignHeightInPixels(aFont, aFontSpec);
sl@0
   241
	}
sl@0
   242
sl@0
   243
TInt CFbsTypefaceStore::GetNearestFontInTwipsAndCreateFont(
sl@0
   244
	CFont*&				aFont,
sl@0
   245
	TInt				aFbsMessage, // a TFbsMessage
sl@0
   246
	const TFontSpec&	aFontSpec,
sl@0
   247
	TInt				aMaxHeight)
sl@0
   248
	{
sl@0
   249
	aFont = iTwipsCache->Search(aFontSpec);
sl@0
   250
	if (aFont)
sl@0
   251
		{
sl@0
   252
		if (IncrementFontCount(aFont))
sl@0
   253
			{
sl@0
   254
			return KErrNone;
sl@0
   255
			}
sl@0
   256
		Panic(EFbsTypefaceStoreError);
sl@0
   257
		}
sl@0
   258
sl@0
   259
	TInt ret = SendGetNearestFontCommandNCreateFont(
sl@0
   260
		aFont, aFbsMessage, aFontSpec, aMaxHeight);
sl@0
   261
	if (KErrNone != ret)
sl@0
   262
		{
sl@0
   263
		return ret;
sl@0
   264
		}
sl@0
   265
sl@0
   266
	CFont* discard = NULL;
sl@0
   267
	/* We are deliberately storing in the cache the TFontSpec requested by the client 
sl@0
   268
	 * and not the REAL TFontSpec of the font returned by the font matcher.
sl@0
   269
	 * We are doing this for performance reasons: to use the Font Cache as much as possible. 
sl@0
   270
	 * Unless the requested font spec is really complete, including all the different flags 
sl@0
   271
	 * and sub fields, there is only a very small chance that the TFontSpec requested 
sl@0
   272
	 * by the client would be exactly the same as the best match returned by the server.
sl@0
   273
	 * Since some flags (iFontStyle.iFlags and iTypeFace.iFlags) are quite complex and 
sl@0
   274
	 * in general the client don't set up all of them perfectly.
sl@0
   275
	 * So in order to decrease the number of entries in the cache AND also the requests
sl@0
   276
	 * to the server, it's better to associate the TFontSpec asked for by the client 
sl@0
   277
	 * with the CFont found so that next time we ask for it, it will be in the cache.
sl@0
   278
	 * 
sl@0
   279
	 * If we request 2 different font specs that both have the same real font as their 
sl@0
   280
	 * best match then each will appear in the cache but the CFont pointer in both entries
sl@0
   281
	 * will point to the same real CFont (no copies)
sl@0
   282
	 * 
sl@0
   283
	 * PS: a problem is known because of doing this:
sl@0
   284
	 * if we try to get a Font which is not in the system, we obtain the best match
sl@0
   285
	 * then if we add this Font in the system (AddFile) and ask again for this Font,
sl@0
   286
	 * we will still have the previous one which is in the Cache and not the one added.
sl@0
   287
	 * This problem is the result of "bad" programming/testing, in general when we use a Font,
sl@0
   288
	 * we know it's here...
sl@0
   289
	 */
sl@0
   290
	TRAP(ret, discard = iTwipsCache->AddEntryL(aFont,aFontSpec));
sl@0
   291
	if (KErrNone == ret)
sl@0
   292
		{ 
sl@0
   293
		// Font has been added to cache. Increment reference count, so that this font
sl@0
   294
		// will only be destroyed once all client handles to it are released, AND it can 
sl@0
   295
		// not fit in the cache. Even if no clients have a handle to this font, the object
sl@0
   296
		// will still persist until other fonts force it out of the cache.
sl@0
   297
		IncrementFontCount(aFont);
sl@0
   298
		}
sl@0
   299
	if (discard)
sl@0
   300
		{ // a font was bumped out of the cache
sl@0
   301
		ReleaseFont(discard);
sl@0
   302
		}
sl@0
   303
	return KErrNone;
sl@0
   304
	}
sl@0
   305
sl@0
   306
sl@0
   307
/**
sl@0
   308
 get pixel size in Twips * 1000
sl@0
   309
 @internalComponent
sl@0
   310
 */
sl@0
   311
void CFbsTypefaceStore::GetPixelSizeInTwips(TSize& aSize) const
sl@0
   312
	{
sl@0
   313
	if(iDevice)
sl@0
   314
		{
sl@0
   315
		aSize.iWidth = iDevice->HorizontalPixelsToTwips(1000);
sl@0
   316
		aSize.iHeight = iDevice->VerticalPixelsToTwips(1000);
sl@0
   317
		}
sl@0
   318
	if(aSize.iWidth==0 || aSize.iHeight==0)
sl@0
   319
		{
sl@0
   320
		TMachineInfoV1Buf mibuf;
sl@0
   321
		UserHal::MachineInfo(mibuf);
sl@0
   322
		TSize twipsize = mibuf().iPhysicalScreenSize;
sl@0
   323
		TSize pixelsize = mibuf().iDisplaySizeInPixels;
sl@0
   324
		aSize.iWidth = twipsize.iWidth*1000 / pixelsize.iWidth;
sl@0
   325
		aSize.iHeight = twipsize.iHeight*1000 / pixelsize.iHeight;
sl@0
   326
		}
sl@0
   327
	}
sl@0
   328
sl@0
   329
sl@0
   330
TInt CFbsTypefaceStore::SendGetNearestFontCommandNCreateFont(
sl@0
   331
	CFont*&				aFont,
sl@0
   332
	TInt				aFbsMessage, // a TFbsMessage
sl@0
   333
	const TFontSpec&	aFontSpec,
sl@0
   334
	TInt				aMaxHeight)
sl@0
   335
	{
sl@0
   336
	TPckgBuf<TFontSpec> pckgFontSpec(aFontSpec);
sl@0
   337
	TSize pixelSize;
sl@0
   338
	GetPixelSizeInTwips(pixelSize);
sl@0
   339
	TSizeInfo info(aMaxHeight, pixelSize);
sl@0
   340
	TPckgBuf<TSizeInfo>		pckgMaxHeight(info);
sl@0
   341
	TPckgBuf<TFontInfo> pckgFontInfo;
sl@0
   342
	TIpcArgs args(&pckgFontSpec, &pckgFontInfo, &pckgMaxHeight);
sl@0
   343
	const TInt ret = iFbs->SendCommand(aFbsMessage, args);
sl@0
   344
	if (KErrNone != ret)
sl@0
   345
		{
sl@0
   346
		return ret;
sl@0
   347
		}
sl@0
   348
	return CreateFont(aFont, pckgFontInfo());
sl@0
   349
	}
sl@0
   350
sl@0
   351
/**
sl@0
   352
Gets the font which is the nearest to the given font specification.
sl@0
   353
sl@0
   354
When the font is no longer needed, call @c ReleaseFont().
sl@0
   355
sl@0
   356
This new function replaces the deprecated @c GetNearestFontInTwips() yielding (virtually) the 
sl@0
   357
same result. However clients are strongly encouraged to use the new
sl@0
   358
@c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every 
sl@0
   359
character within any given text string will fit within the given amount of twips, whereas the design 
sl@0
   360
height is an aesthetic unit decided by the font designer without strict physical meaning, which 
sl@0
   361
may result in cropped characters.
sl@0
   362
sl@0
   363
Chooses from the fonts loaded at system startup or through the AddFile()
sl@0
   364
or InstallFile() APIs.
sl@0
   365
sl@0
   366
@param aFont On return, contains a pointer to the nearest font.
sl@0
   367
@param aFontSpec The specification of the font to be matched.
sl@0
   368
@return KErrNone if successful; a system-wide error code otherwise.
sl@0
   369
@publishedAll
sl@0
   370
@released
sl@0
   371
@see GetNearestFontToMaxHeightInTwips()
sl@0
   372
@see AddFile()
sl@0
   373
@see InstallFile()
sl@0
   374
*/
sl@0
   375
EXPORT_C TInt CFbsTypefaceStore::GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec)
sl@0
   376
	{
sl@0
   377
	return GetNearestFontInTwipsAndCreateFont(aFont, EFbsMessGetNearestFontToDesignHeightInTwips, aFontSpec);
sl@0
   378
	}
sl@0
   379
sl@0
   380
/**
sl@0
   381
Gets the font which is the nearest to the given font specification.
sl@0
   382
sl@0
   383
When the font is no longer needed, call @c ReleaseFont().
sl@0
   384
sl@0
   385
This new function replaces the deprecated @c GetNearestFontInPixels() yielding (virtually) the 
sl@0
   386
same result. However clients are strongly encouraged to use the new
sl@0
   387
@c GetNearestFontToMaxHeightInPixels() function instead. This will guarantee that every 
sl@0
   388
character within any given text string will fit within the given amount of pixels, whereas the design 
sl@0
   389
height is an aesthetic unit decided by the font designer without strict physical meaning, which 
sl@0
   390
may result in cropped characters.
sl@0
   391
sl@0
   392
Chooses from the fonts loaded at system startup or through the AddFile()
sl@0
   393
or InstallFile() APIs.
sl@0
   394
sl@0
   395
@param aFont On return, contains a pointer to the nearest font.
sl@0
   396
@param aFontSpec The specification of the font to be matched.
sl@0
   397
@return KErrNone if successful; a system-wide error code otherwise.
sl@0
   398
@publishedAll
sl@0
   399
@released
sl@0
   400
@see GetNearestFontToMaxHeightInPixels()
sl@0
   401
@see AddFile()
sl@0
   402
@see InstallFile()
sl@0
   403
*/
sl@0
   404
EXPORT_C TInt CFbsTypefaceStore::GetNearestFontToDesignHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec)
sl@0
   405
	{
sl@0
   406
	return SendGetNearestFontCommandNCreateFont(aFont, EFbsMessGetNearestFontToDesignHeightInPixels, aFontSpec);
sl@0
   407
	}
sl@0
   408
sl@0
   409
/**
sl@0
   410
Gets the font which is the nearest to the given font specification.
sl@0
   411
sl@0
   412
When the font is no longer needed, call @c ReleaseFont().
sl@0
   413
sl@0
   414
The font and bitmap server returns a pointer to the nearest matching font 
sl@0
   415
from those available. Matches to max height of font - this does its best 
sl@0
   416
to return a font that will fit within the maximum height specified (but 
sl@0
   417
note that variations due to hinting algorithms may rarely result in this 
sl@0
   418
height being exceeded by up to one pixel). Problems can also be 
sl@0
   419
encountered with bitmap fonts where the typeface exists but doesn't have 
sl@0
   420
a font small enough.
sl@0
   421
sl@0
   422
Chooses from the fonts loaded at system startup or through the AddFile()
sl@0
   423
or InstallFile() APIs.
sl@0
   424
sl@0
   425
@param aFont On return, contains a pointer to the nearest font.
sl@0
   426
@param aFontSpec The specification of the font to be matched.
sl@0
   427
@param aMaxHeight The maximum height within which the font must fit.
sl@0
   428
This overrides the height specified in aFontSpec.
sl@0
   429
@return KErrNone if successful; a system-wide error code otherwise.
sl@0
   430
@publishedAll
sl@0
   431
@released
sl@0
   432
@see GetNearestFontToDesignHeightInTwips()
sl@0
   433
@see AddFile()
sl@0
   434
@see InstallFile()
sl@0
   435
*/
sl@0
   436
EXPORT_C TInt CFbsTypefaceStore::GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight)
sl@0
   437
	{
sl@0
   438
	return GetNearestFontInTwipsAndCreateFont(aFont, EFbsMessGetNearestFontToMaxHeightInTwips, aFontSpec, aMaxHeight);
sl@0
   439
	}
sl@0
   440
sl@0
   441
/**
sl@0
   442
Gets the font which is the nearest to the given font specification.
sl@0
   443
sl@0
   444
When the font is no longer needed, call @c ReleaseFont().
sl@0
   445
sl@0
   446
The font and bitmap server returns a pointer to the nearest matching font 
sl@0
   447
from those available. Matches to max height of font - this does its best 
sl@0
   448
to return a font that will fit within the maximum height specified (but 
sl@0
   449
note that variations due to hinting algorithms may rarely result in this 
sl@0
   450
height being exceeded by up to one pixel). Problems can also be 
sl@0
   451
encountered with bitmap fonts where the typeface exists but doesn't have 
sl@0
   452
a font small enough.
sl@0
   453
sl@0
   454
Chooses from the fonts loaded at system startup or through the AddFile()
sl@0
   455
or InstallFile() APIs.
sl@0
   456
sl@0
   457
@param aFont On return, contains a pointer to the nearest font.
sl@0
   458
@param aFontSpec The specification of the font to be matched.
sl@0
   459
@param aMaxHeight The maximum height within which the font must fit.
sl@0
   460
This overrides the height specified in aFontSpec.
sl@0
   461
@return KErrNone if successful; a system-wide error code otherwise.
sl@0
   462
@publishedAll
sl@0
   463
@released
sl@0
   464
@see GetNearestFontToDesignHeightInPixels()
sl@0
   465
@see AddFile()
sl@0
   466
@see InstallFile()
sl@0
   467
*/
sl@0
   468
EXPORT_C TInt CFbsTypefaceStore::GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight)
sl@0
   469
	{
sl@0
   470
	return SendGetNearestFontCommandNCreateFont(aFont, EFbsMessGetNearestFontToMaxHeightInPixels, aFontSpec, aMaxHeight);
sl@0
   471
	}
sl@0
   472
sl@0
   473
/** Gets a Bitmap Font by unique identifier and algorithmic drawing style.
sl@0
   474
Chooses from the Bitmap fonts loaded at system startup or through the AddFile()
sl@0
   475
or InstallFile() APIs.
sl@0
   476
sl@0
   477
@param aFont On return, contains a pointer to the retrieved font.
sl@0
   478
@param aUid The unique identifier of the font to be retrieved.
sl@0
   479
@param aAlgStyle Algorithmic style to be applied. e.g. Sets things like algorithmic 
sl@0
   480
bolding, or slant for pseudo-italics.
sl@0
   481
@return KErrNone if successful, otherwise another of the system-wide error 
sl@0
   482
codes.
sl@0
   483
@publishedAll 
sl@0
   484
@released
sl@0
   485
@see GetNearestFontToMaxHeightInTwips()
sl@0
   486
@see GetNearestFontToDesignHeightInTwips()
sl@0
   487
@see GetNearestFontToMaxHeightInPixels()
sl@0
   488
@see GetNearestFontToDesignHeightInPixels()
sl@0
   489
@see AddFile()
sl@0
   490
@see InstallFile()
sl@0
   491
*/
sl@0
   492
EXPORT_C TInt CFbsTypefaceStore::GetFontById(CFont*& aFont,TUid aUid,const TAlgStyle& aAlgStyle)
sl@0
   493
	{
sl@0
   494
	TPckgBuf<TFontInfo> tfpckg;
sl@0
   495
	TSize pixelSize;
sl@0
   496
	GetPixelSizeInTwips(pixelSize);
sl@0
   497
	TPckgBuf<TSize> sizePkg(pixelSize);
sl@0
   498
	TPckgBuf<TAlgStyle> stylepckg(aAlgStyle);
sl@0
   499
	TIpcArgs args(&tfpckg,&stylepckg,aUid.iUid, &sizePkg);
sl@0
   500
	TInt ret=iFbs->SendCommand(EFbsMessGetFontById,args);
sl@0
   501
	if(ret!=KErrNone) return(ret);
sl@0
   502
	return(CreateFont(aFont,tfpckg()));
sl@0
   503
	}
sl@0
   504
sl@0
   505
TInt CFbsTypefaceStore::CreateFont(CFont*& aFont, const TFontInfo& aFontInfo)
sl@0
   506
	{
sl@0
   507
	if (!aFontInfo.iHandle)
sl@0
   508
		{
sl@0
   509
		Panic(EFbsFontCreateFailed);
sl@0
   510
		}
sl@0
   511
	if (IsFontLoaded(aFont, aFontInfo))
sl@0
   512
		{
sl@0
   513
		// By now, a new server-side font object has been created for the requested 
sl@0
   514
		// TFontSpec. However IsFontLoaded() is true, meaning the client already has a 
sl@0
   515
		// font at this address. This can happen if a closely matching (but not exact, 
sl@0
   516
		// otherwise it would be found in the twipscache already) TFontSpec is sent to 
sl@0
   517
		// the server. 
sl@0
   518
		// This means the new server-side font is a duplicate another server-side font. 
sl@0
   519
		// Therefore tell the server to destroy the one just created, and return the 
sl@0
   520
		// font that was already created.
sl@0
   521
		iFbs->SendCommand(EFbsMessClose, aFontInfo.iHandle);
sl@0
   522
		return KErrNone;
sl@0
   523
		}
sl@0
   524
sl@0
   525
	CFbsFont* font = new CFbsFont;
sl@0
   526
	if (!font)
sl@0
   527
		{
sl@0
   528
		iFbs->SendCommand(EFbsMessClose, aFontInfo.iHandle);
sl@0
   529
		return KErrNoMemory;
sl@0
   530
		}
sl@0
   531
	font->iHandle = aFontInfo.iHandle;
sl@0
   532
	font->iServerHandle = aFontInfo.iServerHandle;
sl@0
   533
	font->iAddressPointer = (CBitmapFont*)(iFbs->HeapBase() + aFontInfo.iAddressOffset);
sl@0
   534
	TRAPD(ret, AddFontL(font));
sl@0
   535
	if (KErrNone == ret)
sl@0
   536
		{
sl@0
   537
		aFont = font;
sl@0
   538
		}
sl@0
   539
	else
sl@0
   540
		{
sl@0
   541
		delete font;
sl@0
   542
		}
sl@0
   543
	return ret;
sl@0
   544
	}
sl@0
   545
sl@0
   546
TBool CFbsTypefaceStore::IsFontLoaded(CFont*& aFont, const TFontInfo& aFontInfo) const
sl@0
   547
/**
sl@0
   548
@see CFontStore::IsFontLoaded
sl@0
   549
@see CPdrTypefaceStore::IsFontLoaded
sl@0
   550
*/
sl@0
   551
	{
sl@0
   552
	const TInt count = iFontAccess->Count();
sl@0
   553
	for (TInt i = 0; i < count; i++)
sl@0
   554
		{
sl@0
   555
		CFont* font = (*iFontAccess)[i].iFont;
sl@0
   556
		if (((CFbsFont*)font)->iAddressPointer ==
sl@0
   557
			(CBitmapFont*)(iFbs->HeapBase() + aFontInfo.iAddressOffset))
sl@0
   558
			{
sl@0
   559
			(*iFontAccess)[i].iAccessCount++;
sl@0
   560
			aFont = font;
sl@0
   561
			return ETrue;
sl@0
   562
			}
sl@0
   563
		}
sl@0
   564
	return EFalse;
sl@0
   565
	}
sl@0
   566
sl@0
   567
/** Gets typeface information for a specified typeface index.
sl@0
   568
This information is returned in aTypefaceSupport, and includes the typeface 
sl@0
   569
name and typeface attributes, the number of font heights, the maximum and 
sl@0
   570
minimum font heights, and whether it is a scaleable typeface.
sl@0
   571
sl@0
   572
Returns benignly with an empty TTypefaceSupport if the index is too high; 
sl@0
   573
this can happen if another process removes a typeface after the first process 
sl@0
   574
has already got the number of typefaces. However, if the aTypefaceIndex<0 
sl@0
   575
the function panics with EFbsTypefaceIndexOutOfRange.
sl@0
   576
sl@0
   577
@param aTypefaceSupport On return, if the function executed successfully, 
sl@0
   578
this object contains the typeface information. 
sl@0
   579
@param aTypefaceIndex A typeface index number, in the range: zero to (NumTypefaces() - 1). 
sl@0
   580
@see CTypefaceStore::TypefaceSupport() 
sl@0
   581
@publishedAll 
sl@0
   582
@released
sl@0
   583
*/
sl@0
   584
EXPORT_C void CFbsTypefaceStore::TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const
sl@0
   585
	{
sl@0
   586
	__ASSERT_ALWAYS( aTypefaceIndex >= 0, Panic(EFbsTypefaceIndexOutOfRange) );
sl@0
   587
	TSize pixelSize;
sl@0
   588
	GetPixelSizeInTwips(pixelSize);
sl@0
   589
	TPckgBuf<TSize> sizePkg(pixelSize);
sl@0
   590
	TPckgBuf<TTypefaceSupport> tfi;
sl@0
   591
	TIpcArgs args(aTypefaceIndex,&tfi, &sizePkg);
sl@0
   592
	iFbs->SendCommand(EFbsMessTypefaceSupport,args);
sl@0
   593
	aTypefaceSupport=tfi();
sl@0
   594
	}
sl@0
   595
sl@0
   596
/** Gets the height of the font with specified height and typeface indices, in 
sl@0
   597
twips.
sl@0
   598
The value returned is rounded up or down to the nearest font height in twips.
sl@0
   599
sl@0
   600
If aTypefaceIndex<0 the function panics with EFbsTypefaceIndexOutOfRange. 
sl@0
   601
If aTypefaceIndex is greater than the number of typefaces or aHeightIndex<0 
sl@0
   602
then the function returns 0. If aHeightIndex is greater than the number of 
sl@0
   603
heights then the function returns the biggest height. 
sl@0
   604
sl@0
   605
@param aTypefaceIndex A typeface index number, in the range: 0 to (NumTypefaces() - 1). 
sl@0
   606
@param aHeightIndex A font height index number, in the range: 0 to (TTypefaceSupport::iNumHeights - 1). 
sl@0
   607
Note: TTypefaceSupport::iNumHeights is returned by TypefaceSupport(). 
sl@0
   608
@return The height of the font, in twips.
sl@0
   609
@see CTypefaceStore::FontHeightInTwips()
sl@0
   610
@publishedAll 
sl@0
   611
@released
sl@0
   612
*/
sl@0
   613
EXPORT_C TInt CFbsTypefaceStore::FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const
sl@0
   614
	{
sl@0
   615
	return FontHeight(aTypefaceIndex,aHeightIndex,EFbsMessFontHeightInTwips);
sl@0
   616
	}
sl@0
   617
sl@0
   618
/** Gets the height of the font with specified height and typeface indices, in 
sl@0
   619
pixels.
sl@0
   620
The value returned is rounded up or down to the nearest font height in pixels.
sl@0
   621
sl@0
   622
If aTypefaceIndex<0 the function panics with EFbsTypefaceIndexOutOfRange. 
sl@0
   623
If aTypefaceIndex is greater than the number of typefaces or aHeightIndex<0 
sl@0
   624
then the function returns 0. If aHeightIndex is greater than the number of 
sl@0
   625
heights then the function returns the biggest height. 
sl@0
   626
sl@0
   627
@param aTypefaceIndex A typeface index number, in the range: 0 to (NumTypefaces() - 1). 
sl@0
   628
@param aHeightIndex A font height index number, in the range: 0 to (TTypefaceSupport::iNumHeights - 1). 
sl@0
   629
Note: TTypefaceSupport::iNumHeights is returned by TypefaceSupport(). 
sl@0
   630
@return The height of the font, in pixels.
sl@0
   631
@publishedAll 
sl@0
   632
@released
sl@0
   633
*/
sl@0
   634
EXPORT_C TInt CFbsTypefaceStore::FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const
sl@0
   635
	{
sl@0
   636
	return FontHeight(aTypefaceIndex,aHeightIndex,EFbsMessFontHeightInPixels);
sl@0
   637
	}
sl@0
   638
sl@0
   639
TInt CFbsTypefaceStore::FontHeight(TInt aTypefaceIndex,TInt aHeightIndex,TInt aMessage) const
sl@0
   640
	{
sl@0
   641
	__ASSERT_ALWAYS( aTypefaceIndex >= 0, Panic(EFbsTypefaceIndexOutOfRange) );
sl@0
   642
	TSize pixelSize;
sl@0
   643
	GetPixelSizeInTwips(pixelSize);
sl@0
   644
	TPckgBuf<TSize> sizePkg(pixelSize);
sl@0
   645
	TIpcArgs args(aTypefaceIndex, aHeightIndex, &sizePkg);
sl@0
   646
	return iFbs->SendCommand(aMessage, args);
sl@0
   647
	}
sl@0
   648
sl@0
   649
/** Gets the default anti-aliasing setting for scalable fonts.
sl@0
   650
@return Indicates whether or not scalable fonts should be drawn using 
sl@0
   651
anti-aliasing.
sl@0
   652
@publishedAll 
sl@0
   653
@released
sl@0
   654
*/
sl@0
   655
EXPORT_C TGlyphBitmapType CFbsTypefaceStore::DefaultBitmapType() const
sl@0
   656
	{
sl@0
   657
	return (TGlyphBitmapType)iFbs->SendCommand(EFbsMessGetDefaultGlyphBitmapType);
sl@0
   658
	}
sl@0
   659
sl@0
   660
/** Sets the default anti-aliasing setting for scalable fonts. Unless this 
sl@0
   661
default setting is overridden so that a font is explicitly requested with 
sl@0
   662
anti-aliasing turned on or off, (see TOpenFontSpec::SetBitmapType() or 
sl@0
   663
TFontStyle::SetBitmapType()), fonts will use the default setting. The default 
sl@0
   664
setting would typically only be changed via the Control Panel. The new setting 
sl@0
   665
affects fonts requested after the change has been made.
sl@0
   666
There is currently no anti-aliasing support for bitmapped fonts.
sl@0
   667
@param aType Indicates whether or not scalable fonts should be drawn using 
sl@0
   668
anti-aliasing.
sl@0
   669
@see TOpenFontSpec::SetBitmapType()
sl@0
   670
@see TFontStyle::SetBitmapType()
sl@0
   671
@publishedAll 
sl@0
   672
@released
sl@0
   673
*/
sl@0
   674
EXPORT_C void CFbsTypefaceStore::SetDefaultBitmapType(TGlyphBitmapType aType) const
sl@0
   675
	{
sl@0
   676
	iFbs->SendCommand(EFbsMessSetDefaultGlyphBitmapType,aType);
sl@0
   677
	}
sl@0
   678
sl@0
   679
/** Sets an alias for a font name.
sl@0
   680
sl@0
   681
If a requested font cannot be found and its name occurs in the alias list
sl@0
   682
then it will be searched for again using the font name corresponding to
sl@0
   683
that alias. If an empty font name is passed then the alias will be removed
sl@0
   684
the list.
sl@0
   685
@param  TDesC& The font name alias to set.
sl@0
   686
@param TDesC&  The actual font name to use for this alias. May be empty.
sl@0
   687
@publishedAll 
sl@0
   688
@released
sl@0
   689
*/
sl@0
   690
EXPORT_C void CFbsTypefaceStore::SetFontNameAliasL(const TDesC& aFontAlias,const TDesC& aFontName) const
sl@0
   691
	{
sl@0
   692
	TIpcArgs args(&aFontAlias,aFontAlias.Length(),&aFontName,aFontName.Length());
sl@0
   693
	User::LeaveIfError(iFbs->SendCommand(EFbsMessFontNameAlias,args));
sl@0
   694
	}
sl@0
   695
sl@0
   696
/** Specifies the default language with which font metrics calculation will be based on.
sl@0
   697
The default language will be used if none is set on the font specification.
sl@0
   698
@publishedAll 
sl@0
   699
@released
sl@0
   700
@see TFontSpec::SetScriptTypeForMetrics
sl@0
   701
*/
sl@0
   702
EXPORT_C void CFbsTypefaceStore::SetDefaultLanguageForMetrics(TLanguage aLanguage) const
sl@0
   703
	{
sl@0
   704
	iFbs->SendCommand(EFbsMessDefaultLanguageForMetrics, aLanguage);
sl@0
   705
	}
sl@0
   706
sl@0
   707
/**
sl@0
   708
Unload all fonts loaded from RAM or removable media
sl@0
   709
@internalTechnology
sl@0
   710
@deprecated
sl@0
   711
*/
sl@0
   712
EXPORT_C void CFbsTypefaceStore::RemoveFontFileLocksL()
sl@0
   713
	{
sl@0
   714
	User::Leave(KErrNotSupported);
sl@0
   715
	}
sl@0
   716
sl@0
   717
/**
sl@0
   718
Unload all fonts (of specified type) loaded from named drive
sl@0
   719
@internalTechnology
sl@0
   720
*/
sl@0
   721
EXPORT_C void CFbsTypefaceStore::RemoveFontFileLocksL(const TDesC& /*aDrive*/, TBool /*aAllFonts*/)
sl@0
   722
	{
sl@0
   723
	User::Leave(KErrNotSupported);
sl@0
   724
	}
sl@0
   725
sl@0
   726
/**
sl@0
   727
Unload the named font file
sl@0
   728
@internalTechnology
sl@0
   729
*/
sl@0
   730
EXPORT_C void CFbsTypefaceStore::RemoveFontFileLocksL(const TDesC& /*aFileName*/)
sl@0
   731
	{
sl@0
   732
	User::Leave(KErrNotSupported);
sl@0
   733
	}
sl@0
   734
sl@0
   735
/** Reset the twips cache.
sl@0
   736
sl@0
   737
The Typeface Store remembers font matches found through GetNearestFont...InTwips() family 
sl@0
   738
of functions in a cache for quicker matching.  This function empties the cache, and should be
sl@0
   739
called after the screen mode is changed as the Twips to pixels relationship may have changed.
sl@0
   740
@publishedAll
sl@0
   741
*/
sl@0
   742
EXPORT_C void CFbsTypefaceStore::ReleaseTwipsCache()
sl@0
   743
	{
sl@0
   744
	if(iTwipsCache)
sl@0
   745
		{
sl@0
   746
		CFont* font=iTwipsCache->RemoveFirstEntry();
sl@0
   747
		while(font!=NULL)
sl@0
   748
			{
sl@0
   749
			ReleaseFont(font);
sl@0
   750
			font=iTwipsCache->RemoveFirstEntry();
sl@0
   751
			}
sl@0
   752
		}
sl@0
   753
	}
sl@0
   754
sl@0
   755
/**
sl@0
   756
Sets the system default font typeface. This font will be used when finding the nearest font and the font specified is
sl@0
   757
an empty descriptor.
sl@0
   758
If the system default font is not set, then the default behaviour is to find the nearest match.
sl@0
   759
sl@0
   760
@capability WriteDeviceData
sl@0
   761
@param aFontTypefacename is the font typeface to use as the system default. A font alias cannot be used.
sl@0
   762
*/
sl@0
   763
EXPORT_C void CFbsTypefaceStore::SetSystemDefaultTypefaceNameL(const TDesC& aFontTypefaceName)
sl@0
   764
	{
sl@0
   765
	if (aFontTypefaceName.Length() <= KMaxTypefaceNameLength)
sl@0
   766
		{
sl@0
   767
		TIpcArgs args(&aFontTypefaceName);
sl@0
   768
		User::LeaveIfError(iFbs->SendCommand(EFbsSetSystemDefaultTypefaceName, args));		
sl@0
   769
		}
sl@0
   770
	else
sl@0
   771
		User::Leave(KErrTooBig);	// Typeface name is too large
sl@0
   772
	}
sl@0
   773
sl@0
   774
/**
sl@0
   775
Function to add a CLinkedTypefaceSpecification to the font and bitmap server typeface store.
sl@0
   776
@capability ECapabilityWriteDeviceData
sl@0
   777
@publishedPartner
sl@0
   778
@released
sl@0
   779
@param aLinkedTypefaceSpec  The typeface specification to be added.  Ownership is not transferred.
sl@0
   780
@param aId A unique identifier
sl@0
   781
@return A global error code
sl@0
   782
@see CLinkedTypefaceSpecification
sl@0
   783
@deprecated
sl@0
   784
*/
sl@0
   785
EXPORT_C TInt CFbsTypefaceStore::RegisterLinkedTypeface(const CLinkedTypefaceSpecification& /*aLinkedTypefaceSpec*/, TInt& /*aId*/)
sl@0
   786
	{
sl@0
   787
	return KErrNotSupported;
sl@0
   788
	}
sl@0
   789
sl@0
   790
/**
sl@0
   791
	Function to add a CLinkedTypefaceSpecification to the font and bitmap server typeface store.
sl@0
   792
	@capability ECapabilityWriteDeviceData
sl@0
   793
	@publishedPartner
sl@0
   794
	@released
sl@0
   795
	@param aLinkedTypefaceSpec.  The typeface specification to be added.  Ownership is not transferred.
sl@0
   796
	@return a global error code
sl@0
   797
	@see CLinkedTypefaceSpecification
sl@0
   798
	*/
sl@0
   799
EXPORT_C TInt CFbsTypefaceStore::RegisterLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec)
sl@0
   800
	{
sl@0
   801
	__ASSERT_ALWAYS(iFbs,Panic(EFbsPanicNoConnection));
sl@0
   802
	
sl@0
   803
	// send the name
sl@0
   804
	TPckgBuf <TLinkedTypefaceSpecificationArgs> pckgbuf;
sl@0
   805
	TLinkedTypefaceSpecificationArgs &typefaceArgs=pckgbuf();
sl@0
   806
	
sl@0
   807
	typefaceArgs = aLinkedTypefaceSpec;
sl@0
   808
sl@0
   809
	TIpcArgs args(&pckgbuf,sizeof(TPckgBuf <TLinkedTypefaceSpecificationArgs>));
sl@0
   810
	
sl@0
   811
	return iFbs->SendCommand(EFbsMessRegisterLinkedTypeface,args);
sl@0
   812
	}
sl@0
   813
/**
sl@0
   814
Function to retrieve a linked typeface specification from the installed rasterizer.
sl@0
   815
If there is not a rasterizer present supporting font linking then KErrNotSupported will be returned.
sl@0
   816
The rasterizer is name specified within the passed specification and fills in the elements and
sl@0
   817
groups if the typeface exists.
sl@0
   818
sl@0
   819
	@param CLinkedTypefaceSpecificaion& The typeface Specification with the name set to be the typeface to be retrieved.
sl@0
   820
	
sl@0
   821
	@leave KErrNoMemory if there is insufficient memory available
sl@0
   822
	@leave KErrServerTerminated if the server no longer present 
sl@0
   823
	@leave KErrServerBusy if there are no message slots available  
sl@0
   824
 */
sl@0
   825
EXPORT_C void CFbsTypefaceStore::GetLinkedTypefaceL(CLinkedTypefaceSpecification& aLinkedTypefaceSpec)
sl@0
   826
	{
sl@0
   827
	TBuf<KMaxTypefaceNameLength> linkedName = aLinkedTypefaceSpec.Name();
sl@0
   828
	
sl@0
   829
	TLinkedTypefaceSpecificationArgs returnSpec;
sl@0
   830
	TPckgBuf<TLinkedTypefaceSpecificationArgs> specPkg;
sl@0
   831
	
sl@0
   832
	TIpcArgs args;
sl@0
   833
	args.Set(0,&linkedName);
sl@0
   834
	args.Set(2,&specPkg);
sl@0
   835
sl@0
   836
	User::LeaveIfError(iFbs->SendCommand(EFbsMessFetchLinkedTypeface, args));
sl@0
   837
	
sl@0
   838
	aLinkedTypefaceSpec.Clear();
sl@0
   839
	returnSpec = specPkg();
sl@0
   840
	
sl@0
   841
	TInt i;
sl@0
   842
	for (i = 0 ; i < returnSpec.iGroupSize ; i++)
sl@0
   843
		{
sl@0
   844
		CLinkedTypefaceGroup* grp = CLinkedTypefaceGroup::NewLC(returnSpec.iGroups[i].iGroupId);
sl@0
   845
		grp->SetBaselineShift(returnSpec.iGroups[i].iBaselineShift);
sl@0
   846
		grp->SetScalingOption(returnSpec.iGroups[i].iScalingOption);
sl@0
   847
		grp->SetBoldnessPercentage(returnSpec.iGroups[i].iBoldnessPercentage);
sl@0
   848
		grp->SetItalicAngle(returnSpec.iGroups[i].iItalicAngle);
sl@0
   849
		aLinkedTypefaceSpec.AddLinkedTypefaceGroupL(*grp);
sl@0
   850
		CleanupStack::Pop(grp);
sl@0
   851
		}
sl@0
   852
	for (i = 0 ; i < returnSpec.iSize ; i++)
sl@0
   853
		{
sl@0
   854
		CLinkedTypefaceElementSpec* ele = CLinkedTypefaceElementSpec::NewLC(returnSpec.iTypefaces[i].iName, returnSpec.iTypefaces[i].iGroupId);
sl@0
   855
		ele->SetCanonical(returnSpec.iTypefaces[i].iIsCanonical);
sl@0
   856
		aLinkedTypefaceSpec.AddTypefaceAtBackL(*ele);
sl@0
   857
		CleanupStack::Pop(ele);
sl@0
   858
		}
sl@0
   859
	}
sl@0
   860
sl@0
   861
/**
sl@0
   862
Function to update an existing linked typeface with a new specification. If successful a temporary file is generated and this will replace the
sl@0
   863
linked font after a reboot. Calls to FetchLinkedTypefaceSpecificationL will return the currently loaded linked font spec and not the
sl@0
   864
updated specification. 
sl@0
   865
sl@0
   866
@param aLinkedTypefaceSpec A new linked font specification to replace an existing file
sl@0
   867
sl@0
   868
@panic EFbsPanicNoConnection There is no connection to FontBitmap Server
sl@0
   869
sl@0
   870
@return TInt One of the system wide error codes
sl@0
   871
*/
sl@0
   872
EXPORT_C TInt CFbsTypefaceStore::UpdateLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec)
sl@0
   873
	{
sl@0
   874
	__ASSERT_ALWAYS(iFbs,Panic(EFbsPanicNoConnection));
sl@0
   875
sl@0
   876
	TPckgBuf <TLinkedTypefaceSpecificationArgs> pckgbuf;
sl@0
   877
	TLinkedTypefaceSpecificationArgs &typefaceArgs=pckgbuf();
sl@0
   878
	
sl@0
   879
	typefaceArgs = aLinkedTypefaceSpec;
sl@0
   880
sl@0
   881
	TIpcArgs args(&pckgbuf,sizeof(TPckgBuf <TLinkedTypefaceSpecificationArgs>));
sl@0
   882
	
sl@0
   883
	return iFbs->SendCommand(EFbsMessUpdateLinkedTypeface,args);
sl@0
   884
	}
sl@0
   885