williamr@2: /* williamr@2: * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * Access to Series 60 font system williamr@2: * williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef __AKNFONTACCESS_H__ williamr@2: #define __AKNFONTACCESS_H__ williamr@2: williamr@2: class CAknLayoutFont; williamr@2: class CFbsFont; williamr@2: williamr@2: #include williamr@2: williamr@2: class AknFontAccess williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Generic font family enumeration. These can be used in place of the family name descriptors williamr@2: */ williamr@2: enum TAknFontFamily williamr@2: { williamr@2: EAknFontFamilyNotSpecified = 0, williamr@2: EAknFontFamilySansSerif, williamr@2: EAknFontFamilySerif, williamr@2: EAknFontFamilyMonospace williamr@2: }; williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Returns a font that matches the metrics supplied. The provider can return a scaled williamr@2: * or bitmap font as long as it meets the provided criteria. If an exact match isn't williamr@2: * found then a null is returned. williamr@2: * williamr@2: * @since Series 60 release 2.8 williamr@2: * williamr@2: * @param aBitmapDevice Device for which the font will be requested williamr@2: * @param aFontStyle of type TFontStyle. Use to set weight and posture of the font williamr@2: * @param aFontSize Font size in twips. williamr@2: * @param aFontFamily Font is one of the enumerations in TAknFontFamily williamr@2: * Note that serif and sansSerif are proportional fonts williamr@2: * williamr@2: * @return A font pointer. CBitmapDevice::ReleaseFont must be called to release the font resource on the williamr@2: * device context when the font is no longer required. If an exact match isn't found NULL is returned williamr@2: */ williamr@2: IMPORT_C static CFbsFont* GetFont( williamr@2: CBitmapDevice& aBitmapDevice, williamr@2: const TFontStyle aFontStyle, williamr@2: TInt aFontSizeInTwips, williamr@2: TAknFontFamily aFontFamily); williamr@2: /** williamr@2: * Returns a font that matches the metrics supplied. The provider can return a scaled williamr@2: * or bitmap font as long as it meets the provided criteria. If an exact match isn't williamr@2: * found than a null is returned. williamr@2: * williamr@2: * @since Series 60 release 2.8 williamr@2: * williamr@2: * @param aBitmapDevice Device for which the font will be requested williamr@2: * @param aFontStyle of type TFontStyle. Use to set weight and posture of the font williamr@2: * @param aFontSize Font size in twips. williamr@2: * @param aFontFamilyname Font family is the text name of the font family and may be, for example: williamr@2: * "courier", "helvetica", "times roman" etc. Font names are not case-sensitive. williamr@2: * williamr@2: * @return A font pointer. CBitmapDevice::ReleaseFont must be called to release the font resource on the williamr@2: * device context when the font is no longer required. If an exact match isn't found NULL is returned williamr@2: */ williamr@2: IMPORT_C static CFbsFont* GetFont( williamr@2: CBitmapDevice& aBitmapDevice, williamr@2: const TFontStyle aFontStyle, williamr@2: TInt aFontSizeInTwips, williamr@2: const TDesC& aFontFamilyName); williamr@2: /** williamr@2: * Returns a font that matches the metrics supplied. The provider can return a scaled williamr@2: * or bitmap font as long as it meets the provided criteria. A best fit is used that williamr@2: * is prioritized as follows: fontSize, fontStyle, fontFamily williamr@2: * This will succeed as long as there is at least one font on the phone. williamr@2: * @since Series 60 release 2.8 williamr@2: * williamr@2: * @param aBitmapDevice Device for which the font will be requested williamr@2: * @param aFontStyle of type TFontStyle. Use to set weight and posture of the font williamr@2: * @param aFontSize Font size in twips. williamr@2: * @param aFontFamily Font is one of the following emumerations values: williamr@2: * monospace, sansSerif, serif williamr@2: * Note that serif and sansSerif are proportional fonts williamr@2: * williamr@2: * @return A font pointer. CBitmapDevice::ReleaseFont must be called to release the font resource on the williamr@2: * device context when the font is no longer required. A font is always returned. williamr@2: */ williamr@2: IMPORT_C static CFbsFont* GetClosestFont( williamr@2: CBitmapDevice& aBitmapDevice, williamr@2: const TFontStyle aFontStyle, williamr@2: TInt aFontSizeInTwips, williamr@2: TAknFontFamily aFontFamily); williamr@2: /** williamr@2: * Returns a font that matches the metrics supplied. The provider can return a scaled williamr@2: * or bitmap font as long as it meets the provided criteria. A best fit is used that williamr@2: * is prioritized as follows: fontSize, fontStyle, fontFamily williamr@2: * This will succeed as long as there is at least one font on the phone. williamr@2: * @since Series 60 release 2.8 williamr@2: * williamr@2: * @param aBitmapDevice Device for which the font will be requested williamr@2: * @param aFontStyle of type TFontStyle. Use to set weight and posture of the font williamr@2: * @param aFontSize Font size in twips. williamr@2: * @param aFontFamilyname Font family is the text name of the font family and may be, for example: williamr@2: * "courier", "helvetica", "times roman" etc. Font names are not case-sensitive. williamr@2: * williamr@2: * @return A font pointer. CBitmapDevice::ReleaseFont must be called to release the font resource on the williamr@2: * device context when the font is no longer required. A font is always returned. williamr@2: */ williamr@2: IMPORT_C static CFbsFont* GetClosestFont( williamr@2: CBitmapDevice& aBitmapDevice, williamr@2: const TFontStyle aFontStyle, williamr@2: TInt aFontSizeInTwips, williamr@2: const TDesC& aFontFamilyName); williamr@2: williamr@2: /** williamr@2: * Return a fully constructed CAknLayoutFont object based upon the specification passed in. williamr@2: * The Avkon font specifiation object uses TAknFontCategory to determine the font. williamr@2: * williamr@2: * The font object is returned as non-const, since it is owned and will eventually be deleted by the client. williamr@2: * williamr@2: * This method can only be used for TAknFontSpecification objects that are stored in Pixels. williamr@2: * (See TAknFontSpecification::Units() ) williamr@2: * williamr@2: * @since Series 60 release 2.8 williamr@2: * @param aBitmapDevice Device for which the font is required (not used in 2.8; CEikonEnv::ScreenDevice() is used) williamr@2: * @param aSpec Series 60 font specification object williamr@2: * @return pointer to a CAknLayoutFont object, owned by the caller williamr@2: */ williamr@2: IMPORT_C static CAknLayoutFont* CreateLayoutFontFromSpecificationL( williamr@2: CBitmapDevice& aBitmapDevice, williamr@2: const TAknFontSpecification& aSpec ); williamr@2: williamr@2: /** williamr@2: * Return a fully constructed CAknLayoutFont object based upon the typeface and specification passed in. williamr@2: * The TTypeface object contains a typeface name that is used as the primary key to select a font. williamr@2: * The Series 60 font specifiation object is also used, but any value of TAknFontCategory passed in is reset to williamr@2: * EAknFontCategoryUndefined, and is not used to select the font. williamr@2: * williamr@2: * The font object is returned as non-const, since it is owned and will eventually be deleted by the client. williamr@2: * williamr@2: * This method can only be used for TAknFontSpecification objects that are stored in Pixels williamr@2: * (See TAknFontSpecification::Units() ) williamr@2: * williamr@2: * @since Series 60 release 2.8 williamr@2: * @param aBitmapDevice Device for which the font is required (not used in 2.8; CEikonEnv::ScreenDevice() is used) williamr@2: * @param aTypeface Symbian Typface object williamr@2: * @param aSpec Series 60 font specification object williamr@2: * @return pointer to a CAknLayoutFont object, owned by the caller williamr@2: */ williamr@2: IMPORT_C static CAknLayoutFont* CreateLayoutFontFromSpecificationL( williamr@2: CBitmapDevice& aBitmapDevice, williamr@2: const TTypeface& aTypeface, williamr@2: const TAknFontSpecification& aSpec); williamr@2: williamr@2: williamr@2: private: williamr@2: /** williamr@2: * Method containing all the real implementation for the GetFontXXX APIs williamr@2: */ williamr@2: static CFbsFont* DoGetFont( williamr@2: CBitmapDevice& aBitmapDevice, williamr@2: const TFontStyle aFontStyle, williamr@2: TInt aFontSizeInTwips, williamr@2: const TTypeface& aFontFamilyTypeface, williamr@2: TBool aExactMatchRequired); williamr@2: }; williamr@2: williamr@2: #endif // __AKNFONTACCESS_H__ williamr@2: williamr@2: // End of file williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: