classicui_pub/fonts_api/inc/aknfontaccess.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2005 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 *  Access to Series 60 font system
       
    16 * 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef __AKNFONTACCESS_H__
       
    22 #define __AKNFONTACCESS_H__
       
    23 
       
    24 class CAknLayoutFont;
       
    25 class CFbsFont;
       
    26 
       
    27 #include <AknFontSpecification.h>
       
    28 
       
    29 class AknFontAccess
       
    30     {
       
    31 public:
       
    32     
       
    33     /**
       
    34     * Generic font family enumeration. These can be used in place of the family name descriptors
       
    35     */
       
    36     enum TAknFontFamily
       
    37         {
       
    38         EAknFontFamilyNotSpecified = 0,
       
    39         EAknFontFamilySansSerif,
       
    40         EAknFontFamilySerif,
       
    41         EAknFontFamilyMonospace
       
    42         };
       
    43 
       
    44 public:
       
    45 
       
    46     /**
       
    47     * Returns a font that matches the metrics supplied. The provider can return a scaled 
       
    48     * or bitmap font as long as it meets the provided criteria. If an exact match isn't 
       
    49     * found then a null is returned.
       
    50     *
       
    51     * @since Series 60 release 2.8
       
    52     * 
       
    53     * @param aBitmapDevice Device for which the font will be requested 
       
    54     * @param aFontStyle of type TFontStyle. Use to set weight and posture of the font
       
    55     * @param aFontSize  Font size in twips. 
       
    56     * @param aFontFamily Font is one of the enumerations in TAknFontFamily
       
    57     *        Note that serif and sansSerif are proportional fonts 
       
    58     * 
       
    59     * @return A font pointer. CBitmapDevice::ReleaseFont must be called to release the font resource on the
       
    60     * device context when the font is no longer required. If an exact match isn't found NULL is returned
       
    61     */
       
    62     IMPORT_C static CFbsFont* GetFont(
       
    63         CBitmapDevice& aBitmapDevice,        
       
    64         const TFontStyle aFontStyle,
       
    65         TInt aFontSizeInTwips, 
       
    66         TAknFontFamily aFontFamily); 
       
    67     /**
       
    68     * Returns a font that matches the metrics supplied. The provider can return a scaled 
       
    69     * or bitmap font as long as it meets the provided criteria. If an exact match isn't 
       
    70     * found than a null is returned.
       
    71     *
       
    72     * @since Series 60 release 2.8
       
    73     * 
       
    74     * @param aBitmapDevice Device for which the font will be requested 
       
    75     * @param aFontStyle of type TFontStyle. Use to set weight and posture of the font
       
    76     * @param aFontSize Font size in twips. 
       
    77     * @param aFontFamilyname Font family is the text name of the font family and may be, for example:
       
    78     *               "courier", "helvetica", "times roman" etc. Font names are not case-sensitive. 
       
    79     * 
       
    80     * @return A font pointer. CBitmapDevice::ReleaseFont must be called to release the font resource on the
       
    81     * device context when the font is no longer required. If an exact match isn't found NULL is returned
       
    82     */
       
    83     IMPORT_C static CFbsFont* GetFont(
       
    84         CBitmapDevice& aBitmapDevice,        
       
    85         const TFontStyle aFontStyle, 
       
    86         TInt aFontSizeInTwips, 
       
    87         const TDesC& aFontFamilyName); 
       
    88     /**
       
    89     * Returns a font that matches the metrics supplied. The provider can return a scaled 
       
    90     * or bitmap font as long as it meets the provided criteria. A best fit is used that 
       
    91     * is prioritized as follows: fontSize, fontStyle, fontFamily 
       
    92     * This will succeed as long as there is at least one font on the phone. 
       
    93     * @since Series 60 release 2.8
       
    94     * 
       
    95     * @param aBitmapDevice Device for which the font will be requested 
       
    96     * @param aFontStyle of type TFontStyle. Use to set weight and posture of the font
       
    97     * @param aFontSize Font size in twips. 
       
    98     * @param aFontFamily Font is one of the following emumerations values: 
       
    99     *         monospace, sansSerif, serif 
       
   100     *        Note that serif and sansSerif are proportional fonts 
       
   101     * 
       
   102     * @return A font pointer. CBitmapDevice::ReleaseFont must be called to release the font resource on the
       
   103     * device context when the font is no longer required.  A font is always returned.
       
   104     */
       
   105     IMPORT_C static CFbsFont* GetClosestFont(
       
   106         CBitmapDevice& aBitmapDevice,        
       
   107         const TFontStyle aFontStyle, 
       
   108         TInt aFontSizeInTwips, 
       
   109         TAknFontFamily aFontFamily); 
       
   110     /**
       
   111     * Returns a font that matches the metrics supplied. The provider can return a scaled 
       
   112     * or bitmap font as long as it meets the provided criteria. A best fit is used that 
       
   113     * is prioritized as follows: fontSize, fontStyle, fontFamily 
       
   114     * This will succeed as long as there is at least one font on the phone.
       
   115     * @since Series 60 release 2.8
       
   116     * 
       
   117     * @param aBitmapDevice Device for which the font will be requested 
       
   118     * @param aFontStyle of type TFontStyle. Use to set weight and posture of the font
       
   119     * @param aFontSize Font size in twips. 
       
   120     * @param aFontFamilyname Font family is the text name of the font family and may be, for example:
       
   121     *               "courier", "helvetica", "times roman" etc. Font names are not case-sensitive. 
       
   122     * 
       
   123     * @return A font pointer. CBitmapDevice::ReleaseFont must be called to release the font resource on the
       
   124     * device context when the font is no longer required.  A font is always returned.
       
   125     */
       
   126     IMPORT_C static CFbsFont* GetClosestFont(
       
   127         CBitmapDevice& aBitmapDevice,        
       
   128         const TFontStyle aFontStyle, 
       
   129         TInt aFontSizeInTwips, 
       
   130         const TDesC& aFontFamilyName); 
       
   131             
       
   132     /**
       
   133     * Return a fully constructed CAknLayoutFont object based upon the specification passed in.
       
   134     * The Avkon font specifiation object uses TAknFontCategory to determine the font. 
       
   135     *
       
   136     * The font object is returned as non-const, since it is owned and will eventually be deleted by the client.
       
   137     * 
       
   138     * This method can only be used for TAknFontSpecification objects that are stored in Pixels. 
       
   139     * (See TAknFontSpecification::Units() )
       
   140     *
       
   141     * @since Series 60 release 2.8
       
   142     * @param aBitmapDevice  Device for which the font is required (not used in 2.8; CEikonEnv::ScreenDevice() is used)
       
   143     * @param aSpec          Series 60 font specification object
       
   144     * @return               pointer to a CAknLayoutFont object, owned by the caller
       
   145     */
       
   146     IMPORT_C static CAknLayoutFont* CreateLayoutFontFromSpecificationL(
       
   147         CBitmapDevice& aBitmapDevice,   
       
   148         const TAknFontSpecification& aSpec );
       
   149 
       
   150     /**
       
   151     * Return a fully constructed CAknLayoutFont object based upon the typeface and specification passed in.
       
   152     * The TTypeface object contains a typeface name that is used as the primary key to select a font.  
       
   153     * The Series 60  font specifiation object is also used, but any value of TAknFontCategory passed in is reset to 
       
   154     * EAknFontCategoryUndefined, and is not used to select the font. 
       
   155     *
       
   156     * The font object is returned as non-const, since it is owned and will eventually be deleted by the client.
       
   157     * 
       
   158     * This method can only be used for TAknFontSpecification objects that are stored in Pixels
       
   159     * (See TAknFontSpecification::Units() )
       
   160     *
       
   161     * @since Series 60 release 2.8
       
   162     * @param aBitmapDevice  Device for which the font is required (not used in 2.8; CEikonEnv::ScreenDevice() is used)
       
   163     * @param aTypeface      Symbian Typface object
       
   164     * @param aSpec             Series 60 font specification object
       
   165     * @return                       pointer to a CAknLayoutFont object, owned by the caller
       
   166     */
       
   167     IMPORT_C static CAknLayoutFont* CreateLayoutFontFromSpecificationL(
       
   168         CBitmapDevice& aBitmapDevice,        
       
   169         const TTypeface& aTypeface, 
       
   170         const TAknFontSpecification& aSpec);
       
   171 
       
   172            
       
   173 private:
       
   174     /**
       
   175     * Method containing all the real implementation for the GetFontXXX APIs
       
   176     */
       
   177     static CFbsFont* DoGetFont( 
       
   178         CBitmapDevice& aBitmapDevice,        
       
   179         const TFontStyle aFontStyle, 
       
   180         TInt aFontSizeInTwips, 
       
   181         const TTypeface& aFontFamilyTypeface,
       
   182         TBool aExactMatchRequired);                 
       
   183     };
       
   184 
       
   185 #endif //  __AKNFONTACCESS_H__
       
   186 
       
   187 // End of file
       
   188 
       
   189 
       
   190 
       
   191 
       
   192 
       
   193 
       
   194 
       
   195 
       
   196