1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/fontstore/inc/linkedfonts.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,455 @@
1.4 +/*
1.5 +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#ifndef __LINKEDFONTS_H__
1.23 +#define __LINKEDFONTS_H__
1.24 +
1.25 +_LIT(KFNTSTORELinkedFontsPanicCategory,"LINKED_FONTS");
1.26 +
1.27 +class CLinkedTypefaceBody;
1.28 +class CLinkedTypefaceSpecificationBody;
1.29 +class CLinkedTypefaceElementSpec;
1.30 +class CLinkedTypefaceGroup;
1.31 +class CFbsTypefaceStore;
1.32 +class TLinkedTypefaceSpecificationArgs;
1.33 +
1.34 +/**
1.35 +This class contains the specification of a linked typeface. It is made up of groups and typefaces.
1.36 +
1.37 +Groups (CLinkedTypefaceGroup) must contain one or more typeface; the attributes of the group control how the rasterizer
1.38 +draws the typefaces within the group.
1.39 +
1.40 +Typefaces (CLinkedTypefaceElementSpec) specify which individual typefaces make up the linked typeface. These are
1.41 +referred to as "elements" of the linked typeface.
1.42 +
1.43 +Once the linked typeface has been created users can use it as if it were any other typeface assuming there
1.44 +is a rasteriser that supports this feature available. When selecting a character the rasterize searches
1.45 +each typeface in turn from the lowest index to the highest. When drawing text, the first typeface to contain
1.46 +the required character is used.
1.47 +
1.48 +KMaxLinkedTypefaces and KMaxLinkedTypefaceGroups define the maximum number of typefaces and groups that can be
1.49 +added to the specification.
1.50 +
1.51 +This class is not thread safe.
1.52 +
1.53 +WARNING: Class for internal and partner use ONLY. Compatibility is not guaranteed in future releases.
1.54 +
1.55 +@publishedAll
1.56 +@released
1.57 +@see CLinkedTypefaceElementSpec
1.58 +@see CLinkedTypefaceGroup
1.59 +@see KLinkedMaxTypefaces
1.60 +@see KMaxLinkedTypefaceGroups
1.61 +*/
1.62 +NONSHARABLE_CLASS(CLinkedTypefaceSpecification) : public CBase
1.63 +{
1.64 +public:
1.65 + /**
1.66 + This function constructs the linked typeface specification and places it on the CleanupStack.
1.67 +
1.68 + The specification must contain at least one group and one typeface in order for registration to be successful.
1.69 +
1.70 + @param aName The name of the linked typeface. This name should not be the same as an existing typeface.
1.71 +
1.72 + @return A linked typeface specification object
1.73 + */
1.74 + IMPORT_C static CLinkedTypefaceSpecification* NewLC(const TDesC& aTypefaceName);
1.75 +
1.76 + /**
1.77 + The name of this linked typeface
1.78 + @return The name of this linked typeface
1.79 + */
1.80 + IMPORT_C TPtrC Name() const;
1.81 +
1.82 + /**
1.83 + The number of typeface that have been added to this object
1.84 + @return TInt The number of typeface that have been added to this object
1.85 + */
1.86 + IMPORT_C TInt TypefaceCount() const;
1.87 +
1.88 + /**
1.89 + Returns the linked typeface at the specified index.
1.90 + The first typeface is at index 0, the last at TypefaceCount()-1.
1.91 + @return The linked typeface. Null is returned on error.
1.92 + @see CLinkedTypefaceSpecification::NumberOfTypefaces()
1.93 + */
1.94 + IMPORT_C CLinkedTypefaceElementSpec* Typeface(TInt aIndex) const;
1.95 +
1.96 + /**
1.97 + Function to return the index of the canonical (metrics) typeface. The typeface can be
1.98 + retrieved by passing the index to Typeface().
1.99 +
1.100 + @return TInt The index to the canonical typeface
1.101 + @return KErrNotFound No canonical typeface exists
1.102 + @return KErrOverFlow There is more than one canonical typeface
1.103 + @see CLinkedTypefaceSpecification::Typeface()
1.104 + */
1.105 + IMPORT_C TInt CanonicalIndex();
1.106 +
1.107 + /**
1.108 + Adds the supplied CLinkedTypefaceElementSpec to the Linked Typeface specification.
1.109 + The element is placed at the specified index. Adding a canonical element will only be successful
1.110 + if one has not already been added. The specification takes ownership of the element specification
1.111 + if adding is successful.
1.112 +
1.113 + @param aElementSpec The specification to be added.
1.114 + @param aIndex The position at which the element spec will be added.
1.115 +
1.116 + @see CLinkedTypefaceSpecification::AddTypefaceAtBackL()
1.117 + @see CLinkedTypefaceSpecification::RemoveTypeface()
1.118 + @see KMaxLinkedTypefaces
1.119 +
1.120 + @leave KErrArgument If the element is canonical and a canonical element already exists or if the group ID doesn't exist
1.121 + @leave KErrNoMemory There was not enough memory available to perform this operation
1.122 + @leave KErrOverflow The typeface specification is full; adding would exceed KMaxLinkedTypefaces
1.123 + */
1.124 + IMPORT_C void AddTypefaceAtIndexL(CLinkedTypefaceElementSpec& aElementSpec, TInt aIndex);
1.125 +
1.126 + /**
1.127 + Adds the supplied CLinkedTypefaceElementSpec to the Linked Typeface specification.
1.128 + The element is placed at the back of the specification. Adding a canonical element will only be
1.129 + successful if one has not already been added. The specification takes ownership of the element
1.130 + specification if adding is successful.
1.131 +
1.132 + @param aElementSpec
1.133 +
1.134 + @see CLinkedTypefaceSpecification::AddTypefaceAtIndexL()
1.135 + @see CLinkedTypefaceSpecification::RemoveTypeface()
1.136 + @see KMaxLinkedTypefaces
1.137 +
1.138 + @leave KErrArgument If the element is canonical and a canonical element already exists or if the group ID doesn't exist
1.139 + @leave KErrNoMemory There was not enough memory available to perform this operation
1.140 + @leave KErrOverflow The typeface specification is full; adding would exceed KMaxLinkedTypefaces
1.141 + */
1.142 + IMPORT_C void AddTypefaceAtBackL(CLinkedTypefaceElementSpec& aElementSpec);
1.143 +
1.144 + /**
1.145 + Removes the element spec at the specified index from this specification.
1.146 + This function deletes the element spec. If the element is the only one within its group
1.147 + the group is also removed and deleted from the specification.
1.148 +
1.149 + @param aIndex the index of the element spec to be removed
1.150 +
1.151 + @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
1.152 + */
1.153 + IMPORT_C TInt RemoveTypeface(TInt aIndex);
1.154 +
1.155 + /**
1.156 + Creates the linked typeface so that it is available to use a normal typeface.
1.157 +
1.158 + @param aStore The Typeface Store the linked typeface should be registered with
1.159 +
1.160 + @panic EFbsPanicNoConnection There is no connection to the Font & Bitmap Server
1.161 +
1.162 + @leave KErrNotFound One or more of the typeface elements do not exist
1.163 + @leave KErrOverflow The linked typeface contains too many or 0 elements
1.164 + @leave KErrArgument The typeface has no or more than one canonical element
1.165 + @leave KErrAlreadyExists A typeface with the same name already exists
1.166 + @leave KErrNotSupported There is not a rasterizer available that supports linked typefaces
1.167 + */
1.168 + IMPORT_C void RegisterLinkedTypefaceL(CFbsTypefaceStore& aStore);
1.169 +
1.170 + /**
1.171 + Retrieves the linked typeface specification from the server; the name of the typeface to
1.172 + retrieve should be specified at construction. All typefaces and groups contained in the
1.173 + specification are removed before retrieval of the new data.
1.174 +
1.175 + @see CLinkedTypefaceSpecification::NewLC()
1.176 +
1.177 + @param aStore A pointer to the FontStore
1.178 +
1.179 + @leave KErrNotSupported There is not a rasterizer available that supports linked typefaces
1.180 + @leave KErrArgument The font specified does not exist or is not a linked typeface
1.181 + */
1.182 + IMPORT_C void FetchLinkedTypefaceSpecificationL(CFbsTypefaceStore& aStore);
1.183 +
1.184 + /**
1.185 + Adds the group specified to this specification.
1.186 + The specification takes ownership of the group if addition is successful.
1.187 +
1.188 + @param aGroup The group to be added
1.189 +
1.190 + @see CLinkedTypefaceSpecification::RemoveLinkedTypefaceGroup()
1.191 +
1.192 + @leave KErrAlreadyExists A group with the same ID is already present in the specification
1.193 + */
1.194 + IMPORT_C void AddLinkedTypefaceGroupL(CLinkedTypefaceGroup& aGroup);
1.195 +
1.196 + /**
1.197 + This will remove the group and all the elements associated with it.
1.198 +
1.199 + @param aGroupId The Id of the group to be removed
1.200 + */
1.201 + IMPORT_C TInt RemoveLinkedTypefaceGroup(TInt aGroupId);
1.202 +
1.203 + /**
1.204 + Returns the linked typeface group with the specified group ID.
1.205 +
1.206 + @param aGroupId The linked typeface group ID
1.207 + @return The linked typeface group specified or NULL if it doesn't exist
1.208 + */
1.209 + IMPORT_C CLinkedTypefaceGroup* GroupById(TInt aGroupId) const;
1.210 +
1.211 + /**
1.212 + Returns the linked typeface group at the specified index within the specification.
1.213 + The Index ranges from 0 to the value returned by NumberOfGroups()-1.
1.214 +
1.215 + @param aGroupIndex The linked typeface groups index within the specification
1.216 + @return The linked typeface group specified or NULL if it doesn't exist
1.217 + */
1.218 + IMPORT_C CLinkedTypefaceGroup* Group(TInt aGroupIndex) const;
1.219 +
1.220 + /**
1.221 + Returns the number of groups that this linked typeface specification contains.
1.222 +
1.223 + @see CLinkedTypefaceSpecification::Group()
1.224 +
1.225 + @return TInt Number of groups
1.226 + */
1.227 + IMPORT_C TInt GroupCount() const;
1.228 +
1.229 + /**
1.230 + Default destructor
1.231 + */
1.232 + IMPORT_C ~CLinkedTypefaceSpecification();
1.233 +
1.234 + /**
1.235 + Removes and destroys all groups and elements from the specification.
1.236 +
1.237 + WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
1.238 + */
1.239 + IMPORT_C void Clear();
1.240 +
1.241 + /**
1.242 + Update the specification of an existing linked typeface.
1.243 +
1.244 + @param aStore A typeface store
1.245 +
1.246 + @publishedPartner
1.247 + */
1.248 + IMPORT_C void UpdateLinkedTypefaceL(CFbsTypefaceStore& aStore);
1.249 +
1.250 +private:
1.251 + CLinkedTypefaceSpecification();
1.252 + void ConstructL(const TDesC& aTypefaceName);
1.253 + void DoAddTypefaceL(CLinkedTypefaceElementSpec& aElementSpec, TInt aPos);
1.254 +
1.255 +private:
1.256 + CLinkedTypefaceSpecificationBody *iBody;
1.257 + };
1.258 +
1.259 +
1.260 +/**
1.261 +Class to specify an individual typeface within a linked typeface.
1.262 +
1.263 +WARNING: Class for internal and partner use ONLY. Compatibility is not guaranteed in future releases.
1.264 +
1.265 +@see CLinkedTypefaceSpecification
1.266 +@see CLinkedTypefaceGroup
1.267 +
1.268 +@publishedAll
1.269 +@released
1.270 +*/
1.271 +NONSHARABLE_CLASS(CLinkedTypefaceElementSpec) : public CBase
1.272 + {
1.273 +public:
1.274 + /**
1.275 + Create a new linked typeface element specification. The name specified must be an existing typeface
1.276 + that should be added to the linked typeface. The group ID links this typeface to a linked typeface
1.277 + group.
1.278 +
1.279 + @see CLinkedTypefaceGroup
1.280 +
1.281 + @param aTypefaceName The typeface name for this element
1.282 + @param aGroupId The ID of the linked font group this element should belong to
1.283 +
1.284 + @return The newly created element spec
1.285 + */
1.286 + IMPORT_C static CLinkedTypefaceElementSpec* NewLC(const TDesC& aTypefaceName, TInt aGroupId);
1.287 +
1.288 + /**
1.289 + Returns the typeface that this element represents within the linked typeface.
1.290 +
1.291 + @return The element typeface name
1.292 + */
1.293 + IMPORT_C TPtrC ElementName() const;
1.294 +
1.295 + /**
1.296 + Set whether the element is the canonical (metrics) font.
1.297 + This is the font that provides all the metrics for the linked typeface.
1.298 +
1.299 + @param aIsCanonical ETrue if the element is canonical, EFalse otherwise
1.300 + */
1.301 + IMPORT_C void SetCanonical(TBool aIsCanonical);
1.302 + /**
1.303 + @return ETrue if the lement is canonical, EFalse otherwise
1.304 + */
1.305 + IMPORT_C TBool Canonical() const;
1.306 +
1.307 + /**
1.308 + @return The group ID specified at construction.
1.309 + */
1.310 + IMPORT_C TInt GroupId() const;
1.311 +
1.312 + /**
1.313 + Default Destructor
1.314 + */
1.315 + IMPORT_C ~CLinkedTypefaceElementSpec();
1.316 +
1.317 +private:
1.318 + /**
1.319 + Constructor
1.320 + */
1.321 + CLinkedTypefaceElementSpec(TInt aGroupId);
1.322 + void ConstructL(const TDesC& aName);
1.323 +
1.324 +private:
1.325 + HBufC* iElementName;
1.326 + TBool iIsCanonical;
1.327 + TInt iGroupId;
1.328 + };
1.329 +
1.330 +/**
1.331 +This class contains parameters used to describe the groups that linked typeface elements are associated to.
1.332 +These "metrics" apply to all fonts that are specified to be within the group.
1.333 +
1.334 +WARNING: Class for internal and partner use ONLY. Compatibility is not guaranteed in future releases.
1.335 +
1.336 +@publishedAll
1.337 +@released
1.338 +*/
1.339 +NONSHARABLE_CLASS(CLinkedTypefaceGroup) : public CBase
1.340 + {
1.341 +public:
1.342 + /**
1.343 + Specifies the different ways in which a typeface belonging to this group can be scaled.
1.344 + */
1.345 + enum TScalingOption
1.346 + {
1.347 + EScalingNone,
1.348 + EScalingUp,
1.349 + EScalingDown,
1.350 + EScalingUpOrDown,
1.351 + };
1.352 + /**
1.353 + Specifies whether the font baseline of fonts belonging to this group should be shifted or not.
1.354 + */
1.355 + enum TBaselineShift
1.356 + {
1.357 + EBaselineShift,
1.358 + ENoBaselineShift,
1.359 + };
1.360 + /**
1.361 + Constructs a new linked typeface group with the specified ID and places it on the CleanupStack.
1.362 +
1.363 + By default the Antialiasing Threshold, Boldness Percentage and Italic Angle are set to -1.
1.364 + The rasterizer will apply its "best-guess" as to the value in this case.
1.365 + The default scaling option is EScalingNone; the default baseline shift is ENoBaselineShift.
1.366 +
1.367 + @param TInt The group ID of this group
1.368 + @return CLinkedTypefaceGroup* A newly constructed group
1.369 + */
1.370 + IMPORT_C static CLinkedTypefaceGroup* NewLC(TInt aGroupId);
1.371 +
1.372 + /**
1.373 + The group ID specified at construction.
1.374 +
1.375 + @return TInt The group ID of this group
1.376 + */
1.377 + IMPORT_C TInt GroupId() const;
1.378 +
1.379 + /**
1.380 + Sets the scaling option associated with the typefaces within this group.
1.381 +
1.382 + @param TScalingOption The enumeration value corresponding to the required scaling.
1.383 +
1.384 + @see CLinkedTypefaceGroup::TScalingOption
1.385 + */
1.386 + IMPORT_C void SetScalingOption(TScalingOption aOption);
1.387 +
1.388 + /**
1.389 + The scaling option associated with the typefaces within this group.
1.390 +
1.391 + @see CLinkedTypefaceGroup::TScalingOption
1.392 +
1.393 + @return TScalingOption Scaling options
1.394 + */
1.395 + IMPORT_C TScalingOption ScalingOption() const;
1.396 +
1.397 + /**
1.398 + Sets whether the baseline of typefaces within this group is shifted.
1.399 +
1.400 + @param TBaselineShift The enumeration value corresponding to the required shifting.
1.401 +
1.402 + @see CLinkedTypefaceGroup::TBaselineShift
1.403 + */
1.404 + IMPORT_C void SetBaselineShift(TBaselineShift aShift);
1.405 +
1.406 + /**
1.407 + The baseline shift associated with the typefaces within this group.
1.408 +
1.409 + @return TBaselineShift The baseline shift
1.410 + */
1.411 + IMPORT_C TBaselineShift BaselineShift() const;
1.412 +
1.413 + /**
1.414 + Sets the boldness percentage used by typefaces belonging to this group.
1.415 +
1.416 + The percentage is relative to the font size specified. For example if a
1.417 + font with an em height of 18 has a boldness percentage of 5% the resulting
1.418 + emboldened text will be emboldened by 18 x (5 / 100) = 0.9 pixels.
1.419 +
1.420 + @param aPercentage The boldness percentage to be used by this group.
1.421 + */
1.422 + IMPORT_C void SetBoldnessPercentage(TInt aPercentage);
1.423 + /**
1.424 + Returns the current boldness percentage for this typeface group.
1.425 + @return The current boldness percentage for this typeface group
1.426 + */
1.427 + IMPORT_C TInt BoldnessPercentage() const;
1.428 +
1.429 + /**
1.430 + Sets the angle (slant) of italic text
1.431 +
1.432 + @param aAngle The angle (slant) of italic text
1.433 + */
1.434 + IMPORT_C void SetItalicAngle(TInt aAngle);
1.435 +
1.436 + /**
1.437 + The angle (slant) of italic text
1.438 +
1.439 + @return The angle (slant) of italic text
1.440 + */
1.441 + IMPORT_C TInt ItalicAngle() const;
1.442 +
1.443 + /**
1.444 + Default constructor
1.445 + */
1.446 + ~CLinkedTypefaceGroup();
1.447 +
1.448 +private:
1.449 + CLinkedTypefaceGroup(TInt aGroupId);
1.450 +
1.451 +private:
1.452 + TInt iGroupId;
1.453 + TScalingOption iScalingOption;
1.454 + TBaselineShift iBaselineShift;
1.455 + TInt iBoldnessPercentage;
1.456 + TInt iItalicAngle;
1.457 + };
1.458 +#endif