os/textandloc/fontservices/fontstore/inc/linkedfonts.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#ifndef __LINKEDFONTS_H__
sl@0
    20
#define __LINKEDFONTS_H__
sl@0
    21
sl@0
    22
_LIT(KFNTSTORELinkedFontsPanicCategory,"LINKED_FONTS");
sl@0
    23
sl@0
    24
class CLinkedTypefaceBody;
sl@0
    25
class CLinkedTypefaceSpecificationBody;
sl@0
    26
class CLinkedTypefaceElementSpec;
sl@0
    27
class CLinkedTypefaceGroup;
sl@0
    28
class CFbsTypefaceStore;
sl@0
    29
class TLinkedTypefaceSpecificationArgs;
sl@0
    30
sl@0
    31
/**
sl@0
    32
This class contains the specification of a linked typeface. It is made up of groups and typefaces.
sl@0
    33
sl@0
    34
Groups (CLinkedTypefaceGroup) must contain one or more typeface; the attributes of the group control how the rasterizer
sl@0
    35
draws the typefaces within the group.
sl@0
    36
sl@0
    37
Typefaces (CLinkedTypefaceElementSpec) specify which individual typefaces make up the linked typeface. These are
sl@0
    38
referred to as "elements" of the linked typeface.
sl@0
    39
sl@0
    40
Once the linked typeface has been created users can use it as if it were any other typeface assuming there
sl@0
    41
is a rasteriser that supports this feature available. When selecting a character the rasterize searches
sl@0
    42
each typeface in turn from the lowest index to the highest. When drawing text, the first typeface to contain
sl@0
    43
the required character is used.
sl@0
    44
sl@0
    45
KMaxLinkedTypefaces and KMaxLinkedTypefaceGroups define the maximum number of typefaces and groups that can be
sl@0
    46
added to the specification.
sl@0
    47
sl@0
    48
This class is not thread safe.
sl@0
    49
sl@0
    50
WARNING: Class for internal and partner use ONLY.  Compatibility is not guaranteed in future releases.
sl@0
    51
sl@0
    52
@publishedAll
sl@0
    53
@released
sl@0
    54
@see CLinkedTypefaceElementSpec
sl@0
    55
@see CLinkedTypefaceGroup
sl@0
    56
@see KLinkedMaxTypefaces
sl@0
    57
@see KMaxLinkedTypefaceGroups
sl@0
    58
*/
sl@0
    59
NONSHARABLE_CLASS(CLinkedTypefaceSpecification) : public CBase
sl@0
    60
{
sl@0
    61
public:
sl@0
    62
	/**
sl@0
    63
	This function constructs the linked typeface specification and places it on the CleanupStack.
sl@0
    64
	
sl@0
    65
	The specification must contain at least one group and one typeface in order for registration to be successful.
sl@0
    66
	
sl@0
    67
	@param aName The name of the linked typeface. This name should not be the same as an existing typeface.
sl@0
    68
	
sl@0
    69
	@return A linked typeface specification object
sl@0
    70
	*/
sl@0
    71
	IMPORT_C static CLinkedTypefaceSpecification* NewLC(const TDesC& aTypefaceName);
sl@0
    72
sl@0
    73
	/**
sl@0
    74
	The name of this linked typeface
sl@0
    75
	@return The name of this linked typeface
sl@0
    76
	*/
sl@0
    77
	IMPORT_C TPtrC Name() const;
sl@0
    78
sl@0
    79
	/**
sl@0
    80
	The number of typeface that have been added to this object
sl@0
    81
	@return TInt The number of typeface that have been added to this object
sl@0
    82
	*/
sl@0
    83
	IMPORT_C TInt TypefaceCount() const;
sl@0
    84
sl@0
    85
	/**
sl@0
    86
	Returns the linked typeface at the specified index. 
sl@0
    87
	The first typeface is at index 0, the last at TypefaceCount()-1.
sl@0
    88
	@return The linked typeface.  Null is returned on error.
sl@0
    89
	@see CLinkedTypefaceSpecification::NumberOfTypefaces()
sl@0
    90
	*/
sl@0
    91
	IMPORT_C CLinkedTypefaceElementSpec* Typeface(TInt aIndex) const;
sl@0
    92
sl@0
    93
	/**
sl@0
    94
	Function to return the index of the canonical (metrics) typeface. The typeface can be
sl@0
    95
	retrieved by passing the index to Typeface().
sl@0
    96
	
sl@0
    97
	@return TInt The index to the canonical typeface
sl@0
    98
	@return KErrNotFound No canonical typeface exists
sl@0
    99
	@return KErrOverFlow There is more than one canonical typeface
sl@0
   100
	@see CLinkedTypefaceSpecification::Typeface()
sl@0
   101
	*/
sl@0
   102
	IMPORT_C TInt CanonicalIndex();
sl@0
   103
	
sl@0
   104
	/**
sl@0
   105
	Adds the supplied CLinkedTypefaceElementSpec to the Linked Typeface specification.
sl@0
   106
	The element is placed at the specified index. Adding a canonical element will only be successful
sl@0
   107
	if one has not already been added. The specification takes ownership of the element specification
sl@0
   108
	if adding is successful.
sl@0
   109
	
sl@0
   110
	@param aElementSpec The specification to be added.
sl@0
   111
	@param aIndex The position at which the element spec will be added.
sl@0
   112
sl@0
   113
	@see CLinkedTypefaceSpecification::AddTypefaceAtBackL()
sl@0
   114
	@see CLinkedTypefaceSpecification::RemoveTypeface()
sl@0
   115
	@see KMaxLinkedTypefaces
sl@0
   116
	
sl@0
   117
	@leave KErrArgument If the element is canonical and a canonical element already exists or if the group ID doesn't exist
sl@0
   118
	@leave KErrNoMemory There was not enough memory available to perform this operation
sl@0
   119
	@leave KErrOverflow The typeface specification is full; adding would exceed KMaxLinkedTypefaces
sl@0
   120
	*/
sl@0
   121
	IMPORT_C void AddTypefaceAtIndexL(CLinkedTypefaceElementSpec& aElementSpec, TInt aIndex);
sl@0
   122
sl@0
   123
	/**
sl@0
   124
	Adds the supplied CLinkedTypefaceElementSpec to the Linked Typeface specification.
sl@0
   125
	The element is placed at the back of the specification. Adding a canonical element will only be 
sl@0
   126
	successful if one has not already been added. The specification takes ownership of the element 
sl@0
   127
	specification if adding is successful.
sl@0
   128
	
sl@0
   129
	@param aElementSpec
sl@0
   130
sl@0
   131
	@see CLinkedTypefaceSpecification::AddTypefaceAtIndexL()
sl@0
   132
	@see CLinkedTypefaceSpecification::RemoveTypeface()
sl@0
   133
	@see KMaxLinkedTypefaces
sl@0
   134
	
sl@0
   135
	@leave KErrArgument If the element is canonical and a canonical element already exists or if the group ID doesn't exist
sl@0
   136
	@leave KErrNoMemory There was not enough memory available to perform this operation
sl@0
   137
	@leave KErrOverflow The typeface specification is full; adding would exceed KMaxLinkedTypefaces
sl@0
   138
	*/
sl@0
   139
	IMPORT_C void AddTypefaceAtBackL(CLinkedTypefaceElementSpec& aElementSpec);
sl@0
   140
sl@0
   141
	/**
sl@0
   142
	Removes the element spec at the specified index from this specification.
sl@0
   143
	This function deletes the element spec. If the element is the only one within its group
sl@0
   144
	the group is also removed and deleted from the specification.
sl@0
   145
sl@0
   146
	@param aIndex the index of the element spec to be removed
sl@0
   147
sl@0
   148
	@return TInt KErrNone if Removal was successful; KErrNotFound If the index is negative or larger than the number of typeface elements or the element doesn't exist
sl@0
   149
	*/
sl@0
   150
	IMPORT_C TInt RemoveTypeface(TInt aIndex);
sl@0
   151
sl@0
   152
	/**
sl@0
   153
	Creates the linked typeface so that it is available to use a normal typeface.
sl@0
   154
sl@0
   155
	@param aStore The Typeface Store the linked typeface should be registered with
sl@0
   156
sl@0
   157
	@panic EFbsPanicNoConnection There is no connection to the Font & Bitmap Server
sl@0
   158
sl@0
   159
	@leave KErrNotFound One or more of the typeface elements do not exist
sl@0
   160
	@leave KErrOverflow The linked typeface contains too many or 0 elements
sl@0
   161
	@leave KErrArgument The typeface has no or more than one canonical element
sl@0
   162
	@leave KErrAlreadyExists A typeface with the same name already exists
sl@0
   163
	@leave KErrNotSupported There is not a rasterizer available that supports linked typefaces
sl@0
   164
	*/
sl@0
   165
	IMPORT_C void RegisterLinkedTypefaceL(CFbsTypefaceStore& aStore);
sl@0
   166
	
sl@0
   167
	/**
sl@0
   168
	Retrieves the linked typeface specification from the server; the name of the typeface to
sl@0
   169
	retrieve should be specified at construction. All typefaces and groups contained in the
sl@0
   170
	specification are removed before retrieval of the new data. 
sl@0
   171
	
sl@0
   172
	@see CLinkedTypefaceSpecification::NewLC()
sl@0
   173
	
sl@0
   174
	@param aStore A pointer to the FontStore
sl@0
   175
sl@0
   176
	@leave KErrNotSupported There is not a rasterizer available that supports linked typefaces
sl@0
   177
	@leave KErrArgument The font specified does not exist or is not a linked typeface
sl@0
   178
	*/
sl@0
   179
	IMPORT_C void FetchLinkedTypefaceSpecificationL(CFbsTypefaceStore& aStore);
sl@0
   180
	
sl@0
   181
	/**
sl@0
   182
	 Adds the group specified to this specification.
sl@0
   183
	 The specification takes ownership of the group if addition is successful.
sl@0
   184
	 
sl@0
   185
	 @param aGroup The group to be added
sl@0
   186
	 
sl@0
   187
	 @see CLinkedTypefaceSpecification::RemoveLinkedTypefaceGroup()
sl@0
   188
	 
sl@0
   189
	 @leave KErrAlreadyExists A group with the same ID is already present in the specification
sl@0
   190
	 */
sl@0
   191
	IMPORT_C void AddLinkedTypefaceGroupL(CLinkedTypefaceGroup& aGroup);
sl@0
   192
	
sl@0
   193
	/**
sl@0
   194
	This will remove the group and all the elements associated with it.
sl@0
   195
	
sl@0
   196
	@param aGroupId The Id of the group to be removed
sl@0
   197
	*/
sl@0
   198
	IMPORT_C TInt RemoveLinkedTypefaceGroup(TInt aGroupId);
sl@0
   199
	
sl@0
   200
	/**
sl@0
   201
	Returns the linked typeface group with the specified group ID.
sl@0
   202
	
sl@0
   203
	@param aGroupId The linked typeface group ID
sl@0
   204
	@return The linked typeface group specified or NULL if it doesn't exist
sl@0
   205
	*/
sl@0
   206
	IMPORT_C CLinkedTypefaceGroup* GroupById(TInt aGroupId) const; 
sl@0
   207
	
sl@0
   208
	/**
sl@0
   209
	Returns the linked typeface group at the specified index within the specification.
sl@0
   210
	The Index ranges from 0 to the value returned by NumberOfGroups()-1.
sl@0
   211
	
sl@0
   212
	@param aGroupIndex The linked typeface groups index within the specification
sl@0
   213
	@return The linked typeface group specified or NULL if it doesn't exist
sl@0
   214
	*/
sl@0
   215
	IMPORT_C CLinkedTypefaceGroup* Group(TInt aGroupIndex) const;
sl@0
   216
	
sl@0
   217
	/**
sl@0
   218
	Returns the number of groups that this linked typeface specification contains.
sl@0
   219
	
sl@0
   220
	@see CLinkedTypefaceSpecification::Group()
sl@0
   221
	
sl@0
   222
	@return TInt Number of groups
sl@0
   223
	*/
sl@0
   224
	IMPORT_C TInt GroupCount() const;
sl@0
   225
	
sl@0
   226
	/**
sl@0
   227
	Default destructor
sl@0
   228
	*/
sl@0
   229
	IMPORT_C ~CLinkedTypefaceSpecification();
sl@0
   230
	
sl@0
   231
	/**
sl@0
   232
	 Removes and destroys all groups and elements from the specification.
sl@0
   233
	 
sl@0
   234
	 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
sl@0
   235
	 */
sl@0
   236
	IMPORT_C void Clear();
sl@0
   237
	
sl@0
   238
	/**
sl@0
   239
	 Update the specification of an existing linked typeface.
sl@0
   240
	 
sl@0
   241
	 @param aStore A typeface store
sl@0
   242
	 
sl@0
   243
	 @publishedPartner
sl@0
   244
	 */
sl@0
   245
	IMPORT_C void UpdateLinkedTypefaceL(CFbsTypefaceStore& aStore);
sl@0
   246
	
sl@0
   247
private:
sl@0
   248
	CLinkedTypefaceSpecification();
sl@0
   249
	void ConstructL(const TDesC& aTypefaceName);
sl@0
   250
	void DoAddTypefaceL(CLinkedTypefaceElementSpec& aElementSpec, TInt aPos);
sl@0
   251
	
sl@0
   252
private:
sl@0
   253
	CLinkedTypefaceSpecificationBody *iBody;
sl@0
   254
	};
sl@0
   255
sl@0
   256
sl@0
   257
/**
sl@0
   258
Class to specify an individual typeface within a linked typeface.
sl@0
   259
sl@0
   260
WARNING: Class for internal and partner use ONLY.  Compatibility is not guaranteed in future releases.
sl@0
   261
sl@0
   262
@see CLinkedTypefaceSpecification
sl@0
   263
@see CLinkedTypefaceGroup
sl@0
   264
sl@0
   265
@publishedAll
sl@0
   266
@released
sl@0
   267
*/
sl@0
   268
NONSHARABLE_CLASS(CLinkedTypefaceElementSpec) : public CBase
sl@0
   269
	{
sl@0
   270
public:
sl@0
   271
	/**
sl@0
   272
	Create a new linked typeface element specification. The name specified must be an existing typeface
sl@0
   273
	that should be added to the linked typeface. The group ID links this typeface to a linked typeface
sl@0
   274
	group.
sl@0
   275
	
sl@0
   276
	@see CLinkedTypefaceGroup
sl@0
   277
	
sl@0
   278
	@param aTypefaceName The typeface name for this element
sl@0
   279
	@param aGroupId The ID of the linked font group this element should belong to
sl@0
   280
	
sl@0
   281
	@return The newly created element spec
sl@0
   282
	*/
sl@0
   283
	IMPORT_C static CLinkedTypefaceElementSpec* NewLC(const TDesC& aTypefaceName, TInt aGroupId);
sl@0
   284
sl@0
   285
	/**
sl@0
   286
	Returns the typeface that this element represents within the linked typeface.
sl@0
   287
	
sl@0
   288
	@return	The element typeface name
sl@0
   289
	*/
sl@0
   290
	IMPORT_C TPtrC ElementName() const;
sl@0
   291
	
sl@0
   292
	/**
sl@0
   293
	Set whether the element is the canonical (metrics) font. 
sl@0
   294
	This is the font that provides all the metrics for the linked typeface.
sl@0
   295
	
sl@0
   296
	@param aIsCanonical ETrue if the element is canonical, EFalse otherwise
sl@0
   297
	*/
sl@0
   298
	IMPORT_C void SetCanonical(TBool aIsCanonical);
sl@0
   299
	/**
sl@0
   300
	@return	ETrue if the lement is canonical, EFalse otherwise
sl@0
   301
	*/
sl@0
   302
	IMPORT_C TBool Canonical() const;
sl@0
   303
	
sl@0
   304
	/**
sl@0
   305
	@return The group ID specified at construction.
sl@0
   306
	 */
sl@0
   307
	IMPORT_C TInt GroupId() const;
sl@0
   308
	
sl@0
   309
	/**
sl@0
   310
	Default Destructor
sl@0
   311
	*/
sl@0
   312
	IMPORT_C ~CLinkedTypefaceElementSpec();
sl@0
   313
sl@0
   314
private:
sl@0
   315
	/**
sl@0
   316
	Constructor
sl@0
   317
	*/
sl@0
   318
	CLinkedTypefaceElementSpec(TInt aGroupId);
sl@0
   319
	void ConstructL(const TDesC& aName);
sl@0
   320
	
sl@0
   321
private:
sl@0
   322
	HBufC*	iElementName;
sl@0
   323
	TBool	iIsCanonical;
sl@0
   324
	TInt	iGroupId;
sl@0
   325
	};
sl@0
   326
sl@0
   327
/**
sl@0
   328
This class contains parameters used to describe the groups that linked typeface elements are associated to.
sl@0
   329
These "metrics" apply to all fonts that are specified to be within the group.
sl@0
   330
sl@0
   331
WARNING: Class for internal and partner use ONLY.  Compatibility is not guaranteed in future releases.
sl@0
   332
sl@0
   333
@publishedAll
sl@0
   334
@released
sl@0
   335
*/
sl@0
   336
NONSHARABLE_CLASS(CLinkedTypefaceGroup) : public CBase
sl@0
   337
	{
sl@0
   338
public:
sl@0
   339
	/**
sl@0
   340
	Specifies the different ways in which a typeface belonging to this group can be scaled.
sl@0
   341
	 */
sl@0
   342
	enum TScalingOption
sl@0
   343
		{
sl@0
   344
		EScalingNone,
sl@0
   345
		EScalingUp,
sl@0
   346
		EScalingDown,
sl@0
   347
		EScalingUpOrDown,
sl@0
   348
		};
sl@0
   349
	/**
sl@0
   350
	Specifies whether the font baseline of fonts belonging to this group should be shifted or not.
sl@0
   351
	 */
sl@0
   352
	enum TBaselineShift
sl@0
   353
		{
sl@0
   354
		EBaselineShift,
sl@0
   355
		ENoBaselineShift,
sl@0
   356
		};
sl@0
   357
	/**
sl@0
   358
	Constructs a new linked typeface group with the specified ID and places it on the CleanupStack.
sl@0
   359
	
sl@0
   360
	By default the Antialiasing Threshold, Boldness Percentage and Italic Angle are set to -1.
sl@0
   361
	The rasterizer will apply its "best-guess" as to the value in this case.
sl@0
   362
	The default scaling option is EScalingNone; the default baseline shift is ENoBaselineShift.
sl@0
   363
	
sl@0
   364
	@param TInt The group ID of this group
sl@0
   365
	@return CLinkedTypefaceGroup* A newly constructed group
sl@0
   366
	*/
sl@0
   367
	IMPORT_C static CLinkedTypefaceGroup* NewLC(TInt aGroupId);
sl@0
   368
	
sl@0
   369
	/**
sl@0
   370
	The group ID specified at construction.
sl@0
   371
	
sl@0
   372
	@return TInt The group ID of this group
sl@0
   373
	 */
sl@0
   374
	IMPORT_C TInt GroupId() const;
sl@0
   375
sl@0
   376
	/**
sl@0
   377
	Sets the scaling option associated with the typefaces within this group.
sl@0
   378
	
sl@0
   379
	@param TScalingOption The enumeration value corresponding to the required scaling.
sl@0
   380
	
sl@0
   381
	@see CLinkedTypefaceGroup::TScalingOption
sl@0
   382
	*/
sl@0
   383
	IMPORT_C void SetScalingOption(TScalingOption aOption);
sl@0
   384
	
sl@0
   385
	/**
sl@0
   386
	The scaling option associated with the typefaces within this group.
sl@0
   387
	
sl@0
   388
	@see CLinkedTypefaceGroup::TScalingOption
sl@0
   389
	
sl@0
   390
	@return TScalingOption Scaling options
sl@0
   391
	 */
sl@0
   392
	IMPORT_C TScalingOption ScalingOption() const;
sl@0
   393
	
sl@0
   394
	/**
sl@0
   395
	Sets whether the baseline of typefaces within this group is shifted.
sl@0
   396
	
sl@0
   397
	@param TBaselineShift The enumeration value corresponding to the required shifting.
sl@0
   398
	
sl@0
   399
	@see CLinkedTypefaceGroup::TBaselineShift
sl@0
   400
	*/
sl@0
   401
	IMPORT_C void SetBaselineShift(TBaselineShift aShift);
sl@0
   402
	
sl@0
   403
	/**
sl@0
   404
	The baseline shift associated with the typefaces within this group.
sl@0
   405
	
sl@0
   406
	@return TBaselineShift The baseline shift
sl@0
   407
	*/
sl@0
   408
	IMPORT_C TBaselineShift BaselineShift() const;
sl@0
   409
	
sl@0
   410
	/**
sl@0
   411
	Sets the boldness percentage used by typefaces belonging to this group.
sl@0
   412
	
sl@0
   413
	The percentage is relative to the font size specified. For example if a
sl@0
   414
	font with an em height of 18 has a boldness percentage of 5% the resulting
sl@0
   415
	emboldened text	will be emboldened by 18 x (5 / 100) = 0.9 pixels.
sl@0
   416
	
sl@0
   417
	@param aPercentage The boldness percentage to be used by this group.
sl@0
   418
	 */
sl@0
   419
	IMPORT_C void SetBoldnessPercentage(TInt aPercentage);
sl@0
   420
	/**
sl@0
   421
	Returns the current boldness percentage for this typeface group.
sl@0
   422
	@return The current boldness percentage for this typeface group
sl@0
   423
	*/
sl@0
   424
	IMPORT_C TInt BoldnessPercentage() const;
sl@0
   425
sl@0
   426
	/**
sl@0
   427
	Sets the angle (slant) of italic text
sl@0
   428
	
sl@0
   429
	@param aAngle The angle (slant) of italic text
sl@0
   430
	 */
sl@0
   431
	IMPORT_C void SetItalicAngle(TInt aAngle);
sl@0
   432
	
sl@0
   433
	/**
sl@0
   434
	The angle (slant) of italic text
sl@0
   435
	
sl@0
   436
	@return The angle (slant) of italic text
sl@0
   437
	 */
sl@0
   438
	IMPORT_C TInt ItalicAngle() const;
sl@0
   439
	
sl@0
   440
	/**
sl@0
   441
	Default constructor
sl@0
   442
	*/
sl@0
   443
	~CLinkedTypefaceGroup();
sl@0
   444
	
sl@0
   445
private:
sl@0
   446
	CLinkedTypefaceGroup(TInt aGroupId);
sl@0
   447
	
sl@0
   448
private:
sl@0
   449
	TInt iGroupId;
sl@0
   450
	TScalingOption iScalingOption;
sl@0
   451
	TBaselineShift iBaselineShift;
sl@0
   452
	TInt iBoldnessPercentage;
sl@0
   453
	TInt iItalicAngle;
sl@0
   454
	};
sl@0
   455
#endif