uiresources_pub/font_definition_api/inc/AknFontSpecification.h
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef AKNFONTSPECIFICATION_H
       
    21 #define AKNFONTSPECIFICATION_H
       
    22 
       
    23 #include <gdi.h>
       
    24 #include <AknFontCategory.hrh>
       
    25 #include <babitflags.h>
       
    26 
       
    27 /**
       
    28 * Object representing the series 60 requirements for a font. It contains information
       
    29 * from the layout specification that fonts bound to the given font id should honor.
       
    30 * 
       
    31 * It formst the basis of the request to font provisioning to provide a suitable font
       
    32 *
       
    33 *  @lib FontUtils.lib
       
    34 *  @since 2.8
       
    35 *
       
    36 *  @internal
       
    37 */
       
    38 class TAknFontSpecification
       
    39     {
       
    40 public:
       
    41 
       
    42     enum TAknFontSpecificationUnits
       
    43         {
       
    44         EPixels = 0,
       
    45         ETwips
       
    46         };
       
    47 
       
    48 public:
       
    49     /**
       
    50     * Construct font specification from Font ID.
       
    51     *
       
    52     *@param aFontId     Series 60 font id from which to create a font.
       
    53     */
       
    54     IMPORT_C TAknFontSpecification( TInt aFontId );
       
    55 
       
    56     /**
       
    57     * Construct the font specifiation from Symbian OS TFontSpec and MGraphicsDeviceMap
       
    58     * The Symbian OS TFontSpec must be set in Twips.  The MGraphicsDeviceMap is used to convert to
       
    59     * pixels for the text pane height.
       
    60     *
       
    61     * Note that the units policy during and in effect at the end of this constructor is EPixels.
       
    62     * 
       
    63     * Note that the TTypeface part of the TFontSpec is lost in this construction
       
    64     *
       
    65     * @param aCategory      Series 60 Font category to use
       
    66     * @param aFontSpec      Provides the metrics and Style information to use for the match
       
    67     * @param aDeviceMap     Device map used to convert the aFontSpec's twips to pixels
       
    68     * 
       
    69     */
       
    70     IMPORT_C TAknFontSpecification(  
       
    71         TAknFontCategory aCategory, 
       
    72         const TFontSpec& aFontSpec, 
       
    73         const MGraphicsDeviceMap* aDeviceMap );
       
    74     
       
    75     /**
       
    76     * Sets the Series 60 font category.
       
    77     * 
       
    78     * @param aCategory  New category to set.
       
    79     */
       
    80     IMPORT_C void SetFontCategory( TAknFontCategory aCategory );
       
    81     
       
    82     /**
       
    83     * Series 60 Layout Specification font category: 
       
    84     *   Primary, Secondary, Title etc.
       
    85     *
       
    86     * @return   Series 60 font category
       
    87     */
       
    88     IMPORT_C TAknFontCategory FontCategory() const;
       
    89 
       
    90     /**
       
    91     * The requested height for a font. This represents the maximum vertical range that can be 
       
    92     * guraranteed to draw in the text pane.
       
    93     *
       
    94     * Note also that this value is the height requested by layout or the client, and might not correspond to 
       
    95     * the design height, ascent + descent, or max height reported by the attached font. See the APIs
       
    96     * CAknLayoutFont::TextPaneTopToBaseline and BaselineToTextPaneBottom. 
       
    97     *
       
    98     * If TextPaneHeightIsDesignHeight() is EFalse, then the font will be requested to fit entirely within
       
    99     * this range.  
       
   100     *
       
   101     * If TextPaneHeightIsDesignHeight() is set, then this value is passed to the font request as the font
       
   102     * design height, in which case the font may not render entirely within the "text pane height".
       
   103     * 
       
   104     * @param aNewHeight     Text pane height to be used by the font.
       
   105     */
       
   106     IMPORT_C void SetTextPaneHeight( TInt aNewHeight );
       
   107 
       
   108     /**
       
   109     * The requested height of the font. This represents the maximum vertical range that can be 
       
   110     * guaranteed to draw in the text pane.
       
   111     *
       
   112     * Note also that this value is the height requested by layout or the client, and may not correspond to 
       
   113     * the design height, ascent + descent, or max height reported by the attached font. See the APIs
       
   114     * CAknLayoutFont::TextPaneTopToBaseline and BaselineToTextPaneBottom. 
       
   115     * 
       
   116     * If TextPaneHeightIsDesignHeight() is EFalse, then the font is to be requested to fit entirely within
       
   117     * this range.  
       
   118     *
       
   119     * If TextPaneHeightIsDesignHeight() is set, then this value is passed to the font request as the font
       
   120     * design height, in which case the font may not render entirely within the "text pane height".
       
   121     *
       
   122     * Depending upon the value of TextPaneHeightIsInTwips(), the value returned is in Pixels or Twips. 
       
   123     * Note that calling SetTextPaneHeightIsInTwips() does not perform any conversion of the text pane height;
       
   124     * It retains its set value.
       
   125     * 
       
   126     * @return Requested text pane height.
       
   127     */
       
   128     IMPORT_C TInt TextPaneHeight() const;
       
   129        
       
   130     /**
       
   131     * Set the stoke weight to request using the Symbian OS stroke weight enumeration. 
       
   132     *
       
   133     * @aParam aWeight   The stroke weight. 
       
   134     */
       
   135     IMPORT_C void SetWeight( TFontStrokeWeight aWeight );
       
   136     
       
   137     /**
       
   138     * Sets the posture (e.g. upright, italic) of requested font using the Symbian OS enumeration.
       
   139     * @param aPostore   posture to request
       
   140     */
       
   141     IMPORT_C void SetPosture( TFontPosture aPosture );
       
   142     
       
   143     /**
       
   144     * Sets the policy to use in requesting the font height. Fonts may be requested either by "design height" (which is 
       
   145     * usually approximately the ascent + descent) or by maximum height.
       
   146     * If false, this setting means the number set by SetTextPaneHeight is intended to match
       
   147     * the font's maximum extent; all characters will fit within the text pane.
       
   148     * If true, then the value passed by SetTextPaneHeight will be used to request design height.
       
   149     *
       
   150     * This API has no effect if called on a TAknFontSpecification that has already been bound to a font
       
   151     *
       
   152     * The default value upon construction is EFalse.
       
   153     *
       
   154     * @param aTextPaneHeightIsDesignHeight  If EFalse, ensure that the font fits entirely
       
   155     *                                       within the text pane height
       
   156     *                                       If not EFalse, then the text pane height is treated as the font
       
   157     *                                       design height.
       
   158     */
       
   159     IMPORT_C void SetTextPaneHeightIsDesignHeight( TBool aTextPaneHeightIsDesignHeight );
       
   160     
       
   161     /**
       
   162     * Accessor API for the height policy.
       
   163     * 
       
   164     * @return   EFalse if text pane height is to be the maximum font extent.
       
   165     *           ETrue if text pane height is to be treated as the font's design height 
       
   166     */
       
   167     IMPORT_C TBool TextPaneIsDesignHeight() const;
       
   168 
       
   169     /**
       
   170     * Sets a flag indicating to font requests whether they should insist upon an exact match.
       
   171     * Whether a font match is treated as exact or not depends upon various things, including:
       
   172     *     - if a request is made via a generic font family or via a font family enumeration, then typeface is not tested for "exactness"
       
   173     *     - fonts may be forced to be rendered at certain sizes (within a small number of pixels). This still counts as an exact match
       
   174     * 
       
   175     * The default value upon construction is EFalse;
       
   176     *
       
   177     * @param aRequiresExactMatch       
       
   178     */
       
   179     IMPORT_C void SetExactMatchRequired ( TBool aRequiresExactMatch );
       
   180     
       
   181     /**
       
   182     * Accessor API for whether an exact match is required for the font (See SetExactMatchRequired() )
       
   183     *
       
   184     * @return   whether an exact match is required or not.
       
   185     */
       
   186     IMPORT_C TBool ExactMatchRequired() const;
       
   187 
       
   188     /**
       
   189     * Sets the units for the Text Pane Height APIs.  Note that calling this API does not 
       
   190     * result in the numerical value of the text pane height being recalculated. 
       
   191     * Upon construction, TAknFontSpecification objects store TextPaneHeight in pixels. 
       
   192     * If you then call SetUnits to Twips, you will also have to call SetTextPaneHeight to pass in the new
       
   193     * (twips) value. 
       
   194     *
       
   195     * @param aUnits
       
   196     */
       
   197     IMPORT_C void SetUnits( TAknFontSpecification::TAknFontSpecificationUnits aUnits );
       
   198 
       
   199     /**
       
   200     * Accessor API for the units being used.
       
   201     *
       
   202     * @return units currently being used.
       
   203     */
       
   204     IMPORT_C TAknFontSpecification::TAknFontSpecificationUnits Units() const;     
       
   205    
       
   206     /**
       
   207     * Accessor for the requested weight
       
   208     *
       
   209     * @return Symbian OS stroke weight enumeration (e.g. EStrokeWeightBold)
       
   210     */
       
   211     IMPORT_C TFontStrokeWeight Weight() const ;
       
   212     
       
   213     /**
       
   214     * Accessor for the requested posture
       
   215     *
       
   216     * @return Symbian OS font posture enumeration (e.g. EPostureItalic)
       
   217     */
       
   218     IMPORT_C TFontPosture Posture() const;
       
   219 
       
   220     /**
       
   221     * Accessor for the requested outline effect 
       
   222     *
       
   223     * @since 5.0
       
   224     *
       
   225     * @return ETrue iff outline font effect has been requested
       
   226     */
       
   227     IMPORT_C TBool IsOutlineEffectOn() const;
       
   228 
       
   229 private:
       
   230     void LoadAnyCDLFontInstanceL();
       
   231 
       
   232 private:
       
   233     TAknFontCategory iBaseFontCategory;
       
   234     TInt iTextPaneHeight;
       
   235     // Symbian OS Font Style object convenient for holding style info
       
   236     TFontStyle iRequiredStyle;
       
   237     TBitFlags iFlags;
       
   238     TInt iSpare2; 
       
   239     };
       
   240 
       
   241 #endif
       
   242 // End of File