Update contrib.
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #ifndef __LINKEDFONTS_H__
20 #define __LINKEDFONTS_H__
22 _LIT(KFNTSTORELinkedFontsPanicCategory,"LINKED_FONTS");
24 class CLinkedTypefaceBody;
25 class CLinkedTypefaceSpecificationBody;
26 class CLinkedTypefaceElementSpec;
27 class CLinkedTypefaceGroup;
28 class CFbsTypefaceStore;
29 class TLinkedTypefaceSpecificationArgs;
32 This class contains the specification of a linked typeface. It is made up of groups and typefaces.
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.
37 Typefaces (CLinkedTypefaceElementSpec) specify which individual typefaces make up the linked typeface. These are
38 referred to as "elements" of the linked typeface.
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.
45 KMaxLinkedTypefaces and KMaxLinkedTypefaceGroups define the maximum number of typefaces and groups that can be
46 added to the specification.
48 This class is not thread safe.
50 WARNING: Class for internal and partner use ONLY. Compatibility is not guaranteed in future releases.
54 @see CLinkedTypefaceElementSpec
55 @see CLinkedTypefaceGroup
56 @see KLinkedMaxTypefaces
57 @see KMaxLinkedTypefaceGroups
59 NONSHARABLE_CLASS(CLinkedTypefaceSpecification) : public CBase
63 This function constructs the linked typeface specification and places it on the CleanupStack.
65 The specification must contain at least one group and one typeface in order for registration to be successful.
67 @param aName The name of the linked typeface. This name should not be the same as an existing typeface.
69 @return A linked typeface specification object
71 IMPORT_C static CLinkedTypefaceSpecification* NewLC(const TDesC& aTypefaceName);
74 The name of this linked typeface
75 @return The name of this linked typeface
77 IMPORT_C TPtrC Name() const;
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
83 IMPORT_C TInt TypefaceCount() const;
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()
91 IMPORT_C CLinkedTypefaceElementSpec* Typeface(TInt aIndex) const;
94 Function to return the index of the canonical (metrics) typeface. The typeface can be
95 retrieved by passing the index to Typeface().
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()
102 IMPORT_C TInt CanonicalIndex();
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.
110 @param aElementSpec The specification to be added.
111 @param aIndex The position at which the element spec will be added.
113 @see CLinkedTypefaceSpecification::AddTypefaceAtBackL()
114 @see CLinkedTypefaceSpecification::RemoveTypeface()
115 @see KMaxLinkedTypefaces
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
121 IMPORT_C void AddTypefaceAtIndexL(CLinkedTypefaceElementSpec& aElementSpec, TInt aIndex);
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.
131 @see CLinkedTypefaceSpecification::AddTypefaceAtIndexL()
132 @see CLinkedTypefaceSpecification::RemoveTypeface()
133 @see KMaxLinkedTypefaces
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
139 IMPORT_C void AddTypefaceAtBackL(CLinkedTypefaceElementSpec& aElementSpec);
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.
146 @param aIndex the index of the element spec to be removed
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
150 IMPORT_C TInt RemoveTypeface(TInt aIndex);
153 Creates the linked typeface so that it is available to use a normal typeface.
155 @param aStore The Typeface Store the linked typeface should be registered with
157 @panic EFbsPanicNoConnection There is no connection to the Font & Bitmap Server
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
165 IMPORT_C void RegisterLinkedTypefaceL(CFbsTypefaceStore& aStore);
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.
172 @see CLinkedTypefaceSpecification::NewLC()
174 @param aStore A pointer to the FontStore
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
179 IMPORT_C void FetchLinkedTypefaceSpecificationL(CFbsTypefaceStore& aStore);
182 Adds the group specified to this specification.
183 The specification takes ownership of the group if addition is successful.
185 @param aGroup The group to be added
187 @see CLinkedTypefaceSpecification::RemoveLinkedTypefaceGroup()
189 @leave KErrAlreadyExists A group with the same ID is already present in the specification
191 IMPORT_C void AddLinkedTypefaceGroupL(CLinkedTypefaceGroup& aGroup);
194 This will remove the group and all the elements associated with it.
196 @param aGroupId The Id of the group to be removed
198 IMPORT_C TInt RemoveLinkedTypefaceGroup(TInt aGroupId);
201 Returns the linked typeface group with the specified group ID.
203 @param aGroupId The linked typeface group ID
204 @return The linked typeface group specified or NULL if it doesn't exist
206 IMPORT_C CLinkedTypefaceGroup* GroupById(TInt aGroupId) const;
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.
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
215 IMPORT_C CLinkedTypefaceGroup* Group(TInt aGroupIndex) const;
218 Returns the number of groups that this linked typeface specification contains.
220 @see CLinkedTypefaceSpecification::Group()
222 @return TInt Number of groups
224 IMPORT_C TInt GroupCount() const;
229 IMPORT_C ~CLinkedTypefaceSpecification();
232 Removes and destroys all groups and elements from the specification.
234 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
236 IMPORT_C void Clear();
239 Update the specification of an existing linked typeface.
241 @param aStore A typeface store
245 IMPORT_C void UpdateLinkedTypefaceL(CFbsTypefaceStore& aStore);
248 CLinkedTypefaceSpecification();
249 void ConstructL(const TDesC& aTypefaceName);
250 void DoAddTypefaceL(CLinkedTypefaceElementSpec& aElementSpec, TInt aPos);
253 CLinkedTypefaceSpecificationBody *iBody;
258 Class to specify an individual typeface within a linked typeface.
260 WARNING: Class for internal and partner use ONLY. Compatibility is not guaranteed in future releases.
262 @see CLinkedTypefaceSpecification
263 @see CLinkedTypefaceGroup
268 NONSHARABLE_CLASS(CLinkedTypefaceElementSpec) : public CBase
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
276 @see CLinkedTypefaceGroup
278 @param aTypefaceName The typeface name for this element
279 @param aGroupId The ID of the linked font group this element should belong to
281 @return The newly created element spec
283 IMPORT_C static CLinkedTypefaceElementSpec* NewLC(const TDesC& aTypefaceName, TInt aGroupId);
286 Returns the typeface that this element represents within the linked typeface.
288 @return The element typeface name
290 IMPORT_C TPtrC ElementName() const;
293 Set whether the element is the canonical (metrics) font.
294 This is the font that provides all the metrics for the linked typeface.
296 @param aIsCanonical ETrue if the element is canonical, EFalse otherwise
298 IMPORT_C void SetCanonical(TBool aIsCanonical);
300 @return ETrue if the lement is canonical, EFalse otherwise
302 IMPORT_C TBool Canonical() const;
305 @return The group ID specified at construction.
307 IMPORT_C TInt GroupId() const;
312 IMPORT_C ~CLinkedTypefaceElementSpec();
318 CLinkedTypefaceElementSpec(TInt aGroupId);
319 void ConstructL(const TDesC& aName);
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.
331 WARNING: Class for internal and partner use ONLY. Compatibility is not guaranteed in future releases.
336 NONSHARABLE_CLASS(CLinkedTypefaceGroup) : public CBase
340 Specifies the different ways in which a typeface belonging to this group can be scaled.
350 Specifies whether the font baseline of fonts belonging to this group should be shifted or not.
358 Constructs a new linked typeface group with the specified ID and places it on the CleanupStack.
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.
364 @param TInt The group ID of this group
365 @return CLinkedTypefaceGroup* A newly constructed group
367 IMPORT_C static CLinkedTypefaceGroup* NewLC(TInt aGroupId);
370 The group ID specified at construction.
372 @return TInt The group ID of this group
374 IMPORT_C TInt GroupId() const;
377 Sets the scaling option associated with the typefaces within this group.
379 @param TScalingOption The enumeration value corresponding to the required scaling.
381 @see CLinkedTypefaceGroup::TScalingOption
383 IMPORT_C void SetScalingOption(TScalingOption aOption);
386 The scaling option associated with the typefaces within this group.
388 @see CLinkedTypefaceGroup::TScalingOption
390 @return TScalingOption Scaling options
392 IMPORT_C TScalingOption ScalingOption() const;
395 Sets whether the baseline of typefaces within this group is shifted.
397 @param TBaselineShift The enumeration value corresponding to the required shifting.
399 @see CLinkedTypefaceGroup::TBaselineShift
401 IMPORT_C void SetBaselineShift(TBaselineShift aShift);
404 The baseline shift associated with the typefaces within this group.
406 @return TBaselineShift The baseline shift
408 IMPORT_C TBaselineShift BaselineShift() const;
411 Sets the boldness percentage used by typefaces belonging to this group.
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.
417 @param aPercentage The boldness percentage to be used by this group.
419 IMPORT_C void SetBoldnessPercentage(TInt aPercentage);
421 Returns the current boldness percentage for this typeface group.
422 @return The current boldness percentage for this typeface group
424 IMPORT_C TInt BoldnessPercentage() const;
427 Sets the angle (slant) of italic text
429 @param aAngle The angle (slant) of italic text
431 IMPORT_C void SetItalicAngle(TInt aAngle);
434 The angle (slant) of italic text
436 @return The angle (slant) of italic text
438 IMPORT_C TInt ItalicAngle() const;
443 ~CLinkedTypefaceGroup();
446 CLinkedTypefaceGroup(TInt aGroupId);
450 TScalingOption iScalingOption;
451 TBaselineShift iBaselineShift;
452 TInt iBoldnessPercentage;