williamr@4: /* williamr@4: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@4: * All rights reserved. williamr@4: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@4: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: * williamr@4: * Initial Contributors: williamr@4: * Nokia Corporation - initial contribution. williamr@4: * williamr@4: * Contributors: williamr@4: * williamr@4: * Description: williamr@4: * williamr@4: */ williamr@4: williamr@4: williamr@4: #ifndef __LINKEDFONTS_H__ williamr@4: #define __LINKEDFONTS_H__ williamr@4: williamr@4: _LIT(KFNTSTORELinkedFontsPanicCategory,"LINKED_FONTS"); williamr@4: williamr@4: class CLinkedTypefaceBody; williamr@4: class CLinkedTypefaceSpecificationBody; williamr@4: class CLinkedTypefaceElementSpec; williamr@4: class CLinkedTypefaceGroup; williamr@4: class CFbsTypefaceStore; williamr@4: class TLinkedTypefaceSpecificationArgs; williamr@4: williamr@4: /** williamr@4: This class contains the specification of a linked typeface. It is made up of groups and typefaces. williamr@4: williamr@4: Groups (CLinkedTypefaceGroup) must contain one or more typeface; the attributes of the group control how the rasterizer williamr@4: draws the typefaces within the group. williamr@4: williamr@4: Typefaces (CLinkedTypefaceElementSpec) specify which individual typefaces make up the linked typeface. These are williamr@4: referred to as "elements" of the linked typeface. williamr@4: williamr@4: Once the linked typeface has been created users can use it as if it were any other typeface assuming there williamr@4: is a rasteriser that supports this feature available. When selecting a character the rasterize searches williamr@4: each typeface in turn from the lowest index to the highest. When drawing text, the first typeface to contain williamr@4: the required character is used. williamr@4: williamr@4: KMaxLinkedTypefaces and KMaxLinkedTypefaceGroups define the maximum number of typefaces and groups that can be williamr@4: added to the specification. williamr@4: williamr@4: This class is not thread safe. williamr@4: williamr@4: WARNING: Class for internal and partner use ONLY. Compatibility is not guaranteed in future releases. williamr@4: williamr@4: @publishedAll williamr@4: @released williamr@4: @see CLinkedTypefaceElementSpec williamr@4: @see CLinkedTypefaceGroup williamr@4: @see KLinkedMaxTypefaces williamr@4: @see KMaxLinkedTypefaceGroups williamr@4: */ williamr@4: NONSHARABLE_CLASS(CLinkedTypefaceSpecification) : public CBase williamr@4: { williamr@4: public: williamr@4: /** williamr@4: This function constructs the linked typeface specification and places it on the CleanupStack. williamr@4: williamr@4: The specification must contain at least one group and one typeface in order for registration to be successful. williamr@4: williamr@4: @param aName The name of the linked typeface. This name should not be the same as an existing typeface. williamr@4: williamr@4: @return A linked typeface specification object williamr@4: */ williamr@4: IMPORT_C static CLinkedTypefaceSpecification* NewLC(const TDesC& aTypefaceName); williamr@4: williamr@4: /** williamr@4: The name of this linked typeface williamr@4: @return The name of this linked typeface williamr@4: */ williamr@4: IMPORT_C TPtrC Name() const; williamr@4: williamr@4: /** williamr@4: The number of typeface that have been added to this object williamr@4: @return TInt The number of typeface that have been added to this object williamr@4: */ williamr@4: IMPORT_C TInt TypefaceCount() const; williamr@4: williamr@4: /** williamr@4: Returns the linked typeface at the specified index. williamr@4: The first typeface is at index 0, the last at TypefaceCount()-1. williamr@4: @return The linked typeface. Null is returned on error. williamr@4: @see CLinkedTypefaceSpecification::NumberOfTypefaces() williamr@4: */ williamr@4: IMPORT_C CLinkedTypefaceElementSpec* Typeface(TInt aIndex) const; williamr@4: williamr@4: /** williamr@4: Function to return the index of the canonical (metrics) typeface. The typeface can be williamr@4: retrieved by passing the index to Typeface(). williamr@4: williamr@4: @return TInt The index to the canonical typeface williamr@4: @return KErrNotFound No canonical typeface exists williamr@4: @return KErrOverFlow There is more than one canonical typeface williamr@4: @see CLinkedTypefaceSpecification::Typeface() williamr@4: */ williamr@4: IMPORT_C TInt CanonicalIndex(); williamr@4: williamr@4: /** williamr@4: Adds the supplied CLinkedTypefaceElementSpec to the Linked Typeface specification. williamr@4: The element is placed at the specified index. Adding a canonical element will only be successful williamr@4: if one has not already been added. The specification takes ownership of the element specification williamr@4: if adding is successful. williamr@4: williamr@4: @param aElementSpec The specification to be added. williamr@4: @param aIndex The position at which the element spec will be added. williamr@4: williamr@4: @see CLinkedTypefaceSpecification::AddTypefaceAtBackL() williamr@4: @see CLinkedTypefaceSpecification::RemoveTypeface() williamr@4: @see KMaxLinkedTypefaces williamr@4: williamr@4: @leave KErrArgument If the element is canonical and a canonical element already exists or if the group ID doesn't exist williamr@4: @leave KErrNoMemory There was not enough memory available to perform this operation williamr@4: @leave KErrOverflow The typeface specification is full; adding would exceed KMaxLinkedTypefaces williamr@4: */ williamr@4: IMPORT_C void AddTypefaceAtIndexL(CLinkedTypefaceElementSpec& aElementSpec, TInt aIndex); williamr@4: williamr@4: /** williamr@4: Adds the supplied CLinkedTypefaceElementSpec to the Linked Typeface specification. williamr@4: The element is placed at the back of the specification. Adding a canonical element will only be williamr@4: successful if one has not already been added. The specification takes ownership of the element williamr@4: specification if adding is successful. williamr@4: williamr@4: @param aElementSpec williamr@4: williamr@4: @see CLinkedTypefaceSpecification::AddTypefaceAtIndexL() williamr@4: @see CLinkedTypefaceSpecification::RemoveTypeface() williamr@4: @see KMaxLinkedTypefaces williamr@4: williamr@4: @leave KErrArgument If the element is canonical and a canonical element already exists or if the group ID doesn't exist williamr@4: @leave KErrNoMemory There was not enough memory available to perform this operation williamr@4: @leave KErrOverflow The typeface specification is full; adding would exceed KMaxLinkedTypefaces williamr@4: */ williamr@4: IMPORT_C void AddTypefaceAtBackL(CLinkedTypefaceElementSpec& aElementSpec); williamr@4: williamr@4: /** williamr@4: Removes the element spec at the specified index from this specification. williamr@4: This function deletes the element spec. If the element is the only one within its group williamr@4: the group is also removed and deleted from the specification. williamr@4: williamr@4: @param aIndex the index of the element spec to be removed williamr@4: williamr@4: @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 williamr@4: */ williamr@4: IMPORT_C TInt RemoveTypeface(TInt aIndex); williamr@4: williamr@4: /** williamr@4: Creates the linked typeface so that it is available to use a normal typeface. williamr@4: williamr@4: @param aStore The Typeface Store the linked typeface should be registered with williamr@4: williamr@4: @panic EFbsPanicNoConnection There is no connection to the Font & Bitmap Server williamr@4: williamr@4: @leave KErrNotFound One or more of the typeface elements do not exist williamr@4: @leave KErrOverflow The linked typeface contains too many or 0 elements williamr@4: @leave KErrArgument The typeface has no or more than one canonical element williamr@4: @leave KErrAlreadyExists A typeface with the same name already exists williamr@4: @leave KErrNotSupported There is not a rasterizer available that supports linked typefaces williamr@4: */ williamr@4: IMPORT_C void RegisterLinkedTypefaceL(CFbsTypefaceStore& aStore); williamr@4: williamr@4: /** williamr@4: Retrieves the linked typeface specification from the server; the name of the typeface to williamr@4: retrieve should be specified at construction. All typefaces and groups contained in the williamr@4: specification are removed before retrieval of the new data. williamr@4: williamr@4: @see CLinkedTypefaceSpecification::NewLC() williamr@4: williamr@4: @param aStore A pointer to the FontStore williamr@4: williamr@4: @leave KErrNotSupported There is not a rasterizer available that supports linked typefaces williamr@4: @leave KErrArgument The font specified does not exist or is not a linked typeface williamr@4: */ williamr@4: IMPORT_C void FetchLinkedTypefaceSpecificationL(CFbsTypefaceStore& aStore); williamr@4: williamr@4: /** williamr@4: Adds the group specified to this specification. williamr@4: The specification takes ownership of the group if addition is successful. williamr@4: williamr@4: @param aGroup The group to be added williamr@4: williamr@4: @see CLinkedTypefaceSpecification::RemoveLinkedTypefaceGroup() williamr@4: williamr@4: @leave KErrAlreadyExists A group with the same ID is already present in the specification williamr@4: */ williamr@4: IMPORT_C void AddLinkedTypefaceGroupL(CLinkedTypefaceGroup& aGroup); williamr@4: williamr@4: /** williamr@4: This will remove the group and all the elements associated with it. williamr@4: williamr@4: @param aGroupId The Id of the group to be removed williamr@4: */ williamr@4: IMPORT_C TInt RemoveLinkedTypefaceGroup(TInt aGroupId); williamr@4: williamr@4: /** williamr@4: Returns the linked typeface group with the specified group ID. williamr@4: williamr@4: @param aGroupId The linked typeface group ID williamr@4: @return The linked typeface group specified or NULL if it doesn't exist williamr@4: */ williamr@4: IMPORT_C CLinkedTypefaceGroup* GroupById(TInt aGroupId) const; williamr@4: williamr@4: /** williamr@4: Returns the linked typeface group at the specified index within the specification. williamr@4: The Index ranges from 0 to the value returned by NumberOfGroups()-1. williamr@4: williamr@4: @param aGroupIndex The linked typeface groups index within the specification williamr@4: @return The linked typeface group specified or NULL if it doesn't exist williamr@4: */ williamr@4: IMPORT_C CLinkedTypefaceGroup* Group(TInt aGroupIndex) const; williamr@4: williamr@4: /** williamr@4: Returns the number of groups that this linked typeface specification contains. williamr@4: williamr@4: @see CLinkedTypefaceSpecification::Group() williamr@4: williamr@4: @return TInt Number of groups williamr@4: */ williamr@4: IMPORT_C TInt GroupCount() const; williamr@4: williamr@4: /** williamr@4: Default destructor williamr@4: */ williamr@4: IMPORT_C ~CLinkedTypefaceSpecification(); williamr@4: williamr@4: /** williamr@4: Removes and destroys all groups and elements from the specification. williamr@4: williamr@4: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. williamr@4: */ williamr@4: IMPORT_C void Clear(); williamr@4: williamr@4: /** williamr@4: Update the specification of an existing linked typeface. williamr@4: williamr@4: @param aStore A typeface store williamr@4: williamr@4: @publishedPartner williamr@4: */ williamr@4: IMPORT_C void UpdateLinkedTypefaceL(CFbsTypefaceStore& aStore); williamr@4: williamr@4: private: williamr@4: CLinkedTypefaceSpecification(); williamr@4: void ConstructL(const TDesC& aTypefaceName); williamr@4: void DoAddTypefaceL(CLinkedTypefaceElementSpec& aElementSpec, TInt aPos); williamr@4: williamr@4: private: williamr@4: CLinkedTypefaceSpecificationBody *iBody; williamr@4: }; williamr@4: williamr@4: williamr@4: /** williamr@4: Class to specify an individual typeface within a linked typeface. williamr@4: williamr@4: WARNING: Class for internal and partner use ONLY. Compatibility is not guaranteed in future releases. williamr@4: williamr@4: @see CLinkedTypefaceSpecification williamr@4: @see CLinkedTypefaceGroup williamr@4: williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: NONSHARABLE_CLASS(CLinkedTypefaceElementSpec) : public CBase williamr@4: { williamr@4: public: williamr@4: /** williamr@4: Create a new linked typeface element specification. The name specified must be an existing typeface williamr@4: that should be added to the linked typeface. The group ID links this typeface to a linked typeface williamr@4: group. williamr@4: williamr@4: @see CLinkedTypefaceGroup williamr@4: williamr@4: @param aTypefaceName The typeface name for this element williamr@4: @param aGroupId The ID of the linked font group this element should belong to williamr@4: williamr@4: @return The newly created element spec williamr@4: */ williamr@4: IMPORT_C static CLinkedTypefaceElementSpec* NewLC(const TDesC& aTypefaceName, TInt aGroupId); williamr@4: williamr@4: /** williamr@4: Returns the typeface that this element represents within the linked typeface. williamr@4: williamr@4: @return The element typeface name williamr@4: */ williamr@4: IMPORT_C TPtrC ElementName() const; williamr@4: williamr@4: /** williamr@4: Set whether the element is the canonical (metrics) font. williamr@4: This is the font that provides all the metrics for the linked typeface. williamr@4: williamr@4: @param aIsCanonical ETrue if the element is canonical, EFalse otherwise williamr@4: */ williamr@4: IMPORT_C void SetCanonical(TBool aIsCanonical); williamr@4: /** williamr@4: @return ETrue if the lement is canonical, EFalse otherwise williamr@4: */ williamr@4: IMPORT_C TBool Canonical() const; williamr@4: williamr@4: /** williamr@4: @return The group ID specified at construction. williamr@4: */ williamr@4: IMPORT_C TInt GroupId() const; williamr@4: williamr@4: /** williamr@4: Default Destructor williamr@4: */ williamr@4: IMPORT_C ~CLinkedTypefaceElementSpec(); williamr@4: williamr@4: private: williamr@4: /** williamr@4: Constructor williamr@4: */ williamr@4: CLinkedTypefaceElementSpec(TInt aGroupId); williamr@4: void ConstructL(const TDesC& aName); williamr@4: williamr@4: private: williamr@4: HBufC* iElementName; williamr@4: TBool iIsCanonical; williamr@4: TInt iGroupId; williamr@4: }; williamr@4: williamr@4: /** williamr@4: This class contains parameters used to describe the groups that linked typeface elements are associated to. williamr@4: These "metrics" apply to all fonts that are specified to be within the group. williamr@4: williamr@4: WARNING: Class for internal and partner use ONLY. Compatibility is not guaranteed in future releases. williamr@4: williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: NONSHARABLE_CLASS(CLinkedTypefaceGroup) : public CBase williamr@4: { williamr@4: public: williamr@4: /** williamr@4: Specifies the different ways in which a typeface belonging to this group can be scaled. williamr@4: */ williamr@4: enum TScalingOption williamr@4: { williamr@4: EScalingNone, williamr@4: EScalingUp, williamr@4: EScalingDown, williamr@4: EScalingUpOrDown, williamr@4: }; williamr@4: /** williamr@4: Specifies whether the font baseline of fonts belonging to this group should be shifted or not. williamr@4: */ williamr@4: enum TBaselineShift williamr@4: { williamr@4: EBaselineShift, williamr@4: ENoBaselineShift, williamr@4: }; williamr@4: /** williamr@4: Constructs a new linked typeface group with the specified ID and places it on the CleanupStack. williamr@4: williamr@4: By default the Antialiasing Threshold, Boldness Percentage and Italic Angle are set to -1. williamr@4: The rasterizer will apply its "best-guess" as to the value in this case. williamr@4: The default scaling option is EScalingNone; the default baseline shift is ENoBaselineShift. williamr@4: williamr@4: @param TInt The group ID of this group williamr@4: @return CLinkedTypefaceGroup* A newly constructed group williamr@4: */ williamr@4: IMPORT_C static CLinkedTypefaceGroup* NewLC(TInt aGroupId); williamr@4: williamr@4: /** williamr@4: The group ID specified at construction. williamr@4: williamr@4: @return TInt The group ID of this group williamr@4: */ williamr@4: IMPORT_C TInt GroupId() const; williamr@4: williamr@4: /** williamr@4: Sets the scaling option associated with the typefaces within this group. williamr@4: williamr@4: @param TScalingOption The enumeration value corresponding to the required scaling. williamr@4: williamr@4: @see CLinkedTypefaceGroup::TScalingOption williamr@4: */ williamr@4: IMPORT_C void SetScalingOption(TScalingOption aOption); williamr@4: williamr@4: /** williamr@4: The scaling option associated with the typefaces within this group. williamr@4: williamr@4: @see CLinkedTypefaceGroup::TScalingOption williamr@4: williamr@4: @return TScalingOption Scaling options williamr@4: */ williamr@4: IMPORT_C TScalingOption ScalingOption() const; williamr@4: williamr@4: /** williamr@4: Sets whether the baseline of typefaces within this group is shifted. williamr@4: williamr@4: @param TBaselineShift The enumeration value corresponding to the required shifting. williamr@4: williamr@4: @see CLinkedTypefaceGroup::TBaselineShift williamr@4: */ williamr@4: IMPORT_C void SetBaselineShift(TBaselineShift aShift); williamr@4: williamr@4: /** williamr@4: The baseline shift associated with the typefaces within this group. williamr@4: williamr@4: @return TBaselineShift The baseline shift williamr@4: */ williamr@4: IMPORT_C TBaselineShift BaselineShift() const; williamr@4: williamr@4: /** williamr@4: Sets the boldness percentage used by typefaces belonging to this group. williamr@4: williamr@4: The percentage is relative to the font size specified. For example if a williamr@4: font with an em height of 18 has a boldness percentage of 5% the resulting williamr@4: emboldened text will be emboldened by 18 x (5 / 100) = 0.9 pixels. williamr@4: williamr@4: @param aPercentage The boldness percentage to be used by this group. williamr@4: */ williamr@4: IMPORT_C void SetBoldnessPercentage(TInt aPercentage); williamr@4: /** williamr@4: Returns the current boldness percentage for this typeface group. williamr@4: @return The current boldness percentage for this typeface group williamr@4: */ williamr@4: IMPORT_C TInt BoldnessPercentage() const; williamr@4: williamr@4: /** williamr@4: Sets the angle (slant) of italic text williamr@4: williamr@4: @param aAngle The angle (slant) of italic text williamr@4: */ williamr@4: IMPORT_C void SetItalicAngle(TInt aAngle); williamr@4: williamr@4: /** williamr@4: The angle (slant) of italic text williamr@4: williamr@4: @return The angle (slant) of italic text williamr@4: */ williamr@4: IMPORT_C TInt ItalicAngle() const; williamr@4: williamr@4: /** williamr@4: Default constructor williamr@4: */ williamr@4: ~CLinkedTypefaceGroup(); williamr@4: williamr@4: private: williamr@4: CLinkedTypefaceGroup(TInt aGroupId); williamr@4: williamr@4: private: williamr@4: TInt iGroupId; williamr@4: TScalingOption iScalingOption; williamr@4: TBaselineShift iBaselineShift; williamr@4: TInt iBoldnessPercentage; williamr@4: TInt iItalicAngle; williamr@4: }; williamr@4: #endif