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