fontsupport/fontprovider/Src/FontProvider.cpp
changeset 0 05e9090e2422
child 1 ba33815114d6
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2004-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:   Matches Fonts to a criteria and what is available on the product.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    24 #include <uikon/eikdefmacros.h>
       
    25 #endif
       
    26 #include <eikenv.h>
       
    27 #include <featmgr.h> 
       
    28 #include <gdi.h>
       
    29 #include <eikenv.h>
       
    30 #include <eikappui.h>
       
    31 #include <e32std.h>
       
    32 #include <languages.hrh>
       
    33 
       
    34 // This component's "own" header comes from a S60 export from the System Include
       
    35 #include <AknFontProvider.h>
       
    36 #include <AknFontSpecification.h>
       
    37 #include <AknFontProviderSuppliedMetrics.h>
       
    38 
       
    39 // Used for type TCdlArray, which is used for declaring arrays of static const data
       
    40 #include <CdlTypes.h> 
       
    41 
       
    42 // Used for TOpenFontSpec to enable antialising
       
    43 #include <openfont.h>
       
    44 
       
    45 // For FontUtils
       
    46 #include <gulutil.h>
       
    47 
       
    48 #include <f32file.h>
       
    49 
       
    50 // CONSTANTS
       
    51 
       
    52 // General "Wildcard" value. 
       
    53 #define EAny    -1
       
    54 
       
    55 // Wildcard specific for the category 
       
    56 #define EAknFontCategoryAny -1
       
    57 
       
    58 // Used to request no additional "boldness"
       
    59 #define ENotBold  EStrokeWeightNormal 
       
    60 
       
    61 // Used to request bold typeface
       
    62 #define EBold  EStrokeWeightBold 
       
    63 
       
    64 // Used to turn antialising off 
       
    65 #define ENotAntialiase  0
       
    66 
       
    67 // Used to turn antialising on
       
    68 #define EAntialiase  1
       
    69 
       
    70 //
       
    71 // Font names to be used in the tables
       
    72 //
       
    73 
       
    74 _LIT(KS60TCAndHK,"Sans MT  UniT_HKSCS_S60");
       
    75 _LIT(KS60SC,"Sans MT 936_S60");
       
    76 _LIT(KS60TCAndHKHiRes,"Sans MT TC Big5HK_S60C");
       
    77 _LIT(KS60SCHiRes,"Sans MT SC 936_S60C");
       
    78 _LIT(KJapaneseHensei,"Heisei Kaku Gothic S60");
       
    79 _LIT(KS60Digital, "Series 60 ZDigi");
       
    80 _LIT(KS60Sans, "Series 60 Sans");
       
    81 _LIT(KS60SansTitleSemiBold, "Series 60 Sans TitleSmBd");
       
    82 
       
    83 _LIT(KS60Korean,"Series 60 Korean");
       
    84 //chinese adaptation changes
       
    85 //stroke SC latin 
       
    86 _LIT(KS60SCSANSRLF, "S60SCSANSRLF");
       
    87 _LIT(KS60SCSANSSBLF, "S60SCSANSSBLF");
       
    88 _LIT(KS60SCSANSTTLSMBLDLF, "S60SCSANSTTLSMBLDLF");
       
    89 //stroke TCHK latin
       
    90 _LIT(KS60TCHKSANSRLF, "S60TCHKSANSRLF");
       
    91 _LIT(KS60TCHKSANSSBLF, "S60TCHKSANSSBLF");
       
    92 _LIT(KS60TCHKSANSTTLSMBLDLF, "S60TCHKSANSTTLSMBLDLF");
       
    93 //HiRes SC latin
       
    94 _LIT(KS60SCHRSANSRLF, "S60SCHRSANSRLF");
       
    95 _LIT(KS60SCHRSANSSBLF, "S60SCHRSANSSBLF");
       
    96 _LIT(KS60SCHRSANSTTLSMBLDLF, "S60SCHRSANSTTLSMBLDLF");
       
    97 //HiRes TCHK latin
       
    98 _LIT(KS60TCHKHRSANSRLF, "S60TCHKHRSANSRLF");
       
    99 _LIT(KS60TCHKHRSANSSBLF, "S60TCHKHRSANSSBLF");
       
   100 _LIT(KS60TCHKHRSANSTTLSMBLDLF, "S60TCHKHRSANSTTLSMBLDLF");
       
   101 //end
       
   102 
       
   103 
       
   104 // Texts for measuring maximum ascents and descents:
       
   105 _LIT(KWesternFontMaxExtentText, "\x00C1\x00C7" );
       
   106 
       
   107 // Language support map
       
   108 #define ELanguageSupportBasicLatin                  0x00000001
       
   109 #define ELanguageSupportLatin1Supplement            0x00000002
       
   110 #define ELanguageSupportLatinExtendedA              0x00000004
       
   111 #define ELanguageSupportLatinExtendedB              0x00000008
       
   112 #define ELanguageSupportGreek                       0x00000010
       
   113 #define ELanguageSupportCyrillic                    0x00000020
       
   114 #define ELanguageSupportHebrew                      0x00000040
       
   115 #define ELanguageSupportArabic                      0x00000080
       
   116 #define ELanguageSupportThai                        0x00001000
       
   117 #define ELanguageSupportChinesePRC                  0x00002000
       
   118 #define ELanguageSupportChineseTaiwanHK             0x00004000
       
   119 #define ELanguageSupportChineseHiRes                0x00008000
       
   120 #define ELanguageSupportEnclosedCJK                 0x00010000
       
   121 #define ELanguageSupportCJKUnifiedIdeographsLevel0  0x00020000
       
   122 #define ELanguageSupportCJKUnifiedIdeographsLevel1  0x00040000
       
   123 #define ELanguageSupportJapanese                    0x00080000
       
   124 #define ELanguageSupportKorean                      0x00100000
       
   125 #define ELanguageSupportHangul                      0x00200000
       
   126 //chinese adaptation
       
   127 #define ELanguageSupportChineseFontLinking          0x00400000
       
   128 //end
       
   129 #define ELanguageSupportDevanagari                  0x01000000
       
   130 #define ELanguageSupportS60PrivateUseArea1          0x10000000
       
   131 
       
   132 // Test characters for language support
       
   133 // Latin uppercase A
       
   134 #define KTestCharLatin      0x0041
       
   135 // Hiragana Letter small A
       
   136 #define KTestCharHiragana   0x3041
       
   137 // ye - chosen as a non-trivial and identifiable common chinese character
       
   138 #define KTestCharChinese    0x4e5f
       
   139 // Thai character Ko Kai
       
   140 #define KTestCharThai       0x0e01
       
   141 // Korean character "o"
       
   142 #define KTestCharKorean     0x3147
       
   143 
       
   144 #define EElafLangs (   ELanguageSupportBasicLatin \
       
   145                                | ELanguageSupportLatin1Supplement \
       
   146                                | ELanguageSupportLatinExtendedA \
       
   147                                | ELanguageSupportLatinExtendedB \
       
   148                                | ELanguageSupportGreek \
       
   149                                | ELanguageSupportCyrillic \
       
   150                                | ELanguageSupportHebrew \
       
   151                                | ELanguageSupportArabic \
       
   152                                | ELanguageSupportS60PrivateUseArea1 )
       
   153 
       
   154 #define ESouthAndSoutheastAsianCommonLangs (    ELanguageSupportBasicLatin \
       
   155                                | ELanguageSupportLatin1Supplement \
       
   156                                | ELanguageSupportLatinExtendedA \
       
   157                                | ELanguageSupportLatinExtendedB \
       
   158                                | ELanguageSupportGreek \
       
   159                                | ELanguageSupportCyrillic \
       
   160                                | ELanguageSupportHebrew \
       
   161                                | ELanguageSupportArabic \
       
   162                                | ELanguageSupportS60PrivateUseArea1 )
       
   163 
       
   164 
       
   165 #define EDevanagariLangs (   ESouthAndSoutheastAsianCommonLangs \
       
   166                                | ELanguageSupportDevanagari )
       
   167 
       
   168 
       
   169 #define EApacCommonLangs ( ELanguageSupportBasicLatin \
       
   170                                    | ELanguageSupportLatin1Supplement \
       
   171                                    | ELanguageSupportS60PrivateUseArea1 )
       
   172 
       
   173 #define EThaiLangs        (   EApacCommonLangs \
       
   174                                       | ELanguageSupportThai )
       
   175 
       
   176 #define EJapaneseLangs    (  EApacCommonLangs \
       
   177                                      | ELanguageSupportJapanese )
       
   178 
       
   179 #define EKoreanLangs    (  EApacCommonLangs \
       
   180                                      | ELanguageSupportKorean )
       
   181 
       
   182 #define EChineseLangs     ( EApacCommonLangs \
       
   183                                     | ELanguageSupportCJKUnifiedIdeographsLevel0 \
       
   184                                     | ELanguageSupportCJKUnifiedIdeographsLevel1 )
       
   185 
       
   186 #define EChineseLangsPRC     ( EChineseLangs \
       
   187                                     | ELanguageSupportChinesePRC )
       
   188 
       
   189 #define EChineseLangsTaiwanHK     ( EChineseLangs \
       
   190                                     | ELanguageSupportChineseTaiwanHK )
       
   191 
       
   192 #define EChineseLangsPRCHiRes     ( EChineseLangs \
       
   193                                     | ELanguageSupportChinesePRC \
       
   194                                     | ELanguageSupportChineseHiRes)
       
   195 
       
   196 #define EChineseLangsTaiwanHKHiRes     ( EChineseLangs \
       
   197                                         | ELanguageSupportChineseTaiwanHK \
       
   198                                         | ELanguageSupportChineseHiRes)
       
   199 
       
   200 //chinese adaptation
       
   201 #define EChineseLangsPRCLF     ( EChineseLangs \
       
   202                                     | ELanguageSupportChinesePRC \
       
   203                                     | ELanguageSupportChineseFontLinking )
       
   204 
       
   205 #define EChineseLangsTaiwanHKLF     ( EChineseLangs \
       
   206                                     | ELanguageSupportChineseTaiwanHK \
       
   207                                     | ELanguageSupportChineseFontLinking )
       
   208 
       
   209 #define EChineseLangsPRCHiResLF     ( EChineseLangs \
       
   210                                     | ELanguageSupportChinesePRC \
       
   211                                     | ELanguageSupportChineseHiRes \
       
   212                                     | ELanguageSupportChineseFontLinking )
       
   213 
       
   214 #define EChineseLangsTaiwanHKHiResLF     ( EChineseLangs \
       
   215                                         | ELanguageSupportChineseTaiwanHK \
       
   216                                         | ELanguageSupportChineseHiRes \
       
   217                                         | ELanguageSupportChineseFontLinking )
       
   218 //end                                    
       
   219 
       
   220 
       
   221 // Wildcard value for langs (font is to be used for all languages)
       
   222 #define EAnyLangs           0xffffffff
       
   223 
       
   224 //chinese adaptation
       
   225 /**
       
   226 * For internal use only
       
   227 * Structure holds info about linked typeface info that needs to be created
       
   228 * the values here gets populated from link.ink, any configurable info can be added here
       
   229 * the module which uses this structure can be modified later to make it
       
   230 * configurable for eg: via centrep keys
       
   231 */
       
   232 struct SLinkedFontDetails
       
   233     {
       
   234     TBool iCanonical;
       
   235     TInt iGroup;
       
   236     TBuf<KMaxTypefaceNameLength> iFontName;
       
   237     TBuf<KMaxTypefaceNameLength> iLinkFontName;
       
   238     TInt iFontCategory;//1 - Regular, 2 - Bold
       
   239     };
       
   240 //end
       
   241 
       
   242 /**
       
   243 * 
       
   244 */
       
   245 struct SHeightRequest
       
   246     {
       
   247     TUint16 iDesignHeight;
       
   248     TUint16 iRequestHeight;
       
   249     };
       
   250 
       
   251 /**
       
   252 * Structure to hold information about the deviation of character range's baselines from the 
       
   253 * baseline (i.e. ascent) advertised by CFont.  A raising of the bitmap is +ve.
       
   254 * The raising of the baseline can be given proportionally, as a fraction of the ascent, by providing 
       
   255 * a non-zero denominator.
       
   256 * 
       
   257 * In defining arrays of this structure, there must always be a line defined following any line that is
       
   258 * to be used.
       
   259 */
       
   260 struct SBaselineDelta 
       
   261     {
       
   262     TUint iFirstCharacter;
       
   263     TInt iRelativeBaselineLift;
       
   264     TInt iDenominator;
       
   265     };
       
   266 
       
   267 /**
       
   268 * Principal structure of the Product font table. 
       
   269 */
       
   270 struct SAknProductFontTableLine
       
   271     {
       
   272     TInt iCategory;
       
   273     TInt iMinSize;
       
   274     TInt iMaxSize;
       
   275     TInt iBold;
       
   276     TInt iItalic;
       
   277     TInt iSizeToUse;
       
   278     TInt iBoldnessToUse;
       
   279     TInt iAntialisingToUse;
       
   280     TUint iSupportedLanguagesPattern;
       
   281     const TDesC* iTypefaceName;
       
   282     const TDesC* iGroupName;
       
   283     TCdlArray<SBaselineDelta> const* iBaselineData;
       
   284     TCdlArray<SHeightRequest> const* iHeightRequestData;
       
   285     const TDesC* iMaxAscentDescentChars;
       
   286     };
       
   287 //
       
   288 // height request sizes to use for Agfa vector fonts mapped from text pane height:
       
   289 //
       
   290 
       
   291 CDL_ARRAY_START( SHeightRequest, latinHeightRequestArray)
       
   292     {
       
   293         {  2,  2 }, 
       
   294         { 10,  8 }, 
       
   295         { 11,  9 }, 
       
   296         { 13, 11 }, 
       
   297         { 14, 12 }, 
       
   298         { 14, 13 }, 
       
   299         { 16, 14 }, 
       
   300         { 18, 15 }, 
       
   301         { 19, 16 }, 
       
   302         { 24, 21 }, 
       
   303         { 25, 22 }, 
       
   304         { 26, 24 }, 
       
   305         { 27, 25 }, 
       
   306         { 28, 26 }, 
       
   307         { 29, 26 }, 
       
   308         { 30, 27 }, 
       
   309         { 79, 72 }, 
       
   310         { 218, 200 }, 
       
   311     }
       
   312 CDL_ARRAY_END(SHeightRequest, latinHeightRequestArray);
       
   313 
       
   314 
       
   315 CDL_ARRAY_START( SHeightRequest, agfaDigitalHeightRequestArray)
       
   316     {
       
   317         { 5, 5 },
       
   318         { 18, 16 },
       
   319         { 20, 18 },
       
   320         { 22, 20 },
       
   321         { 24, 21 },
       
   322         { 30, 26 },
       
   323         { 32, 29 },
       
   324         { 33, 29 },
       
   325         { 35, 31 },
       
   326         { 40, 35 },
       
   327         { 44, 39 },
       
   328         { 46, 41 },
       
   329         { 470, 430 },
       
   330     }
       
   331 CDL_ARRAY_END(SHeightRequest, agfaDigitalHeightRequestArray);
       
   332 
       
   333 
       
   334 CDL_ARRAY_START( SHeightRequest, strokeFontHeightRequestArray)
       
   335     {
       
   336         { 13, 12 }, 
       
   337         { 14, 14 }, 
       
   338         { 15, 14 }, 
       
   339         { 16, 16 }, 
       
   340         { 17, 16 }, 
       
   341         { 18, 18 }, 
       
   342         { 19, 18 }, 
       
   343         { 20, 20 }, 
       
   344         { 21, 20 }, 
       
   345     }
       
   346 CDL_ARRAY_END(SHeightRequest, strokeFontHeightRequestArray);
       
   347 
       
   348 //
       
   349 // Baseline adjustment for APAC fonts
       
   350 //
       
   351 
       
   352 CDL_ARRAY_START( SBaselineDelta, apacVectorFontBaselineArray )
       
   353     {
       
   354         { 0x0000,   1, 6 },
       
   355         { 0x0fff,   0, KAknFontProviderBaselineCorrectionIsAbsolute }
       
   356     }
       
   357 CDL_ARRAY_END( SBaselineDelta, apacVectorFontBaselineArray );
       
   358 
       
   359 CDL_ARRAY_START( SBaselineDelta, heiseiBaselineArray )
       
   360     {
       
   361         { 0x0000,   1, 7.8 },
       
   362         { 0x0fff,   0, KAknFontProviderBaselineCorrectionIsAbsolute }
       
   363     }
       
   364 CDL_ARRAY_END( SBaselineDelta, heiseiBaselineArray );
       
   365 CDL_ARRAY_START( SBaselineDelta, koreanVectorFontBaselineArray )
       
   366     {
       
   367         { 0x0000,   -1, 6 },
       
   368         { 0x0fff,   0, KAknFontProviderBaselineCorrectionIsAbsolute }
       
   369     }    
       
   370    
       
   371 CDL_ARRAY_END( SBaselineDelta, koreanVectorFontBaselineArray );
       
   372 
       
   373 CDL_ARRAY_START( SHeightRequest, heiseiFontHeightRequestArray)
       
   374     {
       
   375         { 13, 12 }, 
       
   376         { 14, 14 }, 
       
   377         { 15, 14 }, 
       
   378         { 16, 16 }, 
       
   379         { 17, 16 }, 
       
   380         { 18, 18 }, 
       
   381         { 19, 18 }, 
       
   382         { 20, 20 }, 
       
   383         { 21, 20 }, 
       
   384     }
       
   385 CDL_ARRAY_END(SHeightRequest, heiseiFontHeightRequestArray);
       
   386 
       
   387 CDL_ARRAY_START( SHeightRequest, koreanFontHeightRequestArray)
       
   388     {
       
   389         { 8, 6 },
       
   390         { 9, 6 },
       
   391         { 10, 8 },
       
   392         { 11, 8 },
       
   393         { 12, 10 },
       
   394         { 13, 10 },
       
   395         { 14, 12 },
       
   396         { 15, 12 },
       
   397         { 16, 14 },
       
   398         { 17, 14 },
       
   399         { 18, 16 },
       
   400         { 19, 16 },
       
   401         { 20, 18 },
       
   402         { 21, 18 },
       
   403         { 22, 20 },
       
   404         { 23, 20 },
       
   405         { 24, 22 },
       
   406         { 25, 22 },
       
   407         { 26, 24 },
       
   408         { 27, 24 },
       
   409         { 28, 26 }, 
       
   410         { 29, 26 }, 
       
   411         { 30, 27 }, 
       
   412         { 79, 60 }, 
       
   413 		{ 218, 200 },
       
   414     }
       
   415 CDL_ARRAY_END(SHeightRequest, koreanFontHeightRequestArray);
       
   416 
       
   417 CDL_ARRAY_START( SHeightRequest, chnlinkedFontHeightRequestArray)
       
   418     {
       
   419         {  2,  2 }, 
       
   420         { 10,  8 }, 
       
   421         { 11,  9 }, 
       
   422         { 13, 10 }, 
       
   423         { 14, 12 }, 
       
   424         { 15, 12 }, 
       
   425         { 16, 14 }, 
       
   426         { 17, 14 }, 
       
   427         { 18, 14 }, 
       
   428         { 19, 16 }, 
       
   429         { 20, 16 }, 
       
   430         { 21, 18 }, 
       
   431         { 24, 21 }, 
       
   432         { 25, 22 }, 
       
   433         { 26, 24 }, 
       
   434         { 27, 25 }, 
       
   435         { 28, 26 }, 
       
   436         { 29, 26 }, 
       
   437         { 30, 27 }, 
       
   438         { 79, 72 }, 
       
   439         { 218, 200 }, 
       
   440     }
       
   441 CDL_ARRAY_END(SHeightRequest, chnlinkedFontHeightRequestArray);
       
   442 
       
   443 // Typeface Aliasing
       
   444 
       
   445 // Minimum length for alias substring matching
       
   446 #define KMinAliasLength 2
       
   447 
       
   448 struct SAknLanguagesAndTypefaceTableLine
       
   449     {
       
   450     TUint iSupportedLanguagesPattern;
       
   451     const TDesC* iTypefaceName;
       
   452     };
       
   453 
       
   454 struct SAknAliasTableLine
       
   455     {
       
   456     const TDesC* iAlias;
       
   457     const TDesC* iGroupName;
       
   458     TCdlArray<SAknLanguagesAndTypefaceTableLine> const* iLanguagesAndTypefaceTable;
       
   459     TBool iIsAliasGeneric;
       
   460     };
       
   461 
       
   462 // Aliases
       
   463 _LIT(KSystemOne, "System One");
       
   464 _LIT(KArial, "arial");
       
   465 _LIT(KVerdana, "verdana");
       
   466 _LIT(KSansSerifHyphen, "sans-serif");
       
   467 _LIT(KSansSerif, "sansserif");
       
   468 _LIT(KHelvetica, "helvetica");
       
   469 _LIT(KGeorgia, "georgia");
       
   470 _LIT(KTimes, "times");
       
   471 _LIT(KTimesNewRoman, "times new roman");
       
   472 _LIT(KSerif, "serif");
       
   473 _LIT(KMonospace, "monospaced");
       
   474 _LIT(KCourier, "courier");
       
   475 
       
   476 // Group names
       
   477 _LIT(KS60Group, "S60Group");
       
   478 
       
   479 // Default
       
   480 _LIT(KDefaultGroupName, "S60Group");
       
   481 
       
   482 /*
       
   483 * Language and typefaces combinations to use without regard to size and style
       
   484 *
       
   485 * First element is language coverage bit pattern
       
   486 * Second element is the typeface or typeface family to use.  Should be able to handle all sizes on device
       
   487 *
       
   488 */
       
   489 CDL_ARRAY_START( SAknLanguagesAndTypefaceTableLine, languagesAndTypefaceTable)
       
   490     {
       
   491         { EElafLangs,  LIT_AS_DESC_PTR(KS60Sans) },
       
   492         { EChineseLangsPRC, LIT_AS_DESC_PTR(KS60SC) },
       
   493         { EChineseLangsTaiwanHK, LIT_AS_DESC_PTR(KS60TCAndHK) },
       
   494         { EJapaneseLangs, LIT_AS_DESC_PTR(KJapaneseHensei) },
       
   495         { EChineseLangsPRCHiRes, LIT_AS_DESC_PTR(KS60SCHiRes) },
       
   496         { EChineseLangsTaiwanHKHiRes, LIT_AS_DESC_PTR(KS60TCAndHKHiRes) },
       
   497         //chinese adaptation
       
   498         { EChineseLangsPRCLF, LIT_AS_DESC_PTR(KS60SCSANSRLF) },
       
   499         { EChineseLangsTaiwanHKLF, LIT_AS_DESC_PTR(KS60TCHKSANSRLF) },
       
   500         { EChineseLangsPRCHiResLF, LIT_AS_DESC_PTR(KS60SCHRSANSRLF) },
       
   501         { EChineseLangsTaiwanHKHiResLF, LIT_AS_DESC_PTR(KS60TCHKHRSANSRLF) },
       
   502         //end
       
   503         { EAnyLangs, LIT_AS_DESC_PTR(KS60Sans) } // Ultimate fallback
       
   504     }
       
   505 CDL_ARRAY_END(SAknLanguagesAndTypefaceTableLine, languagesAndTypefaceTable);
       
   506 
       
   507 
       
   508 /*
       
   509 * Main Configuration for Aliasing.  
       
   510 *
       
   511 * First element is the alias
       
   512 * next element is the group matching typeface. This may be NULL. If not NULL it is used to match in the 
       
   513 *     product font table, in a similar manner to category matching. 
       
   514 * next element points to the language and typeface table
       
   515 * next element is a Flag to say if the matching is generic. This is used to see if the aliasing counts 
       
   516 *     as an exact match or not
       
   517 */
       
   518 static const SAknAliasTableLine aliasTable[] = {
       
   519     { LIT_AS_DESC_PTR(KSystemOne) ,LIT_AS_DESC_PTR(KS60Group), &languagesAndTypefaceTable, ETrue  },
       
   520     { LIT_AS_DESC_PTR(KSansSerifHyphen) ,LIT_AS_DESC_PTR(KS60Group), &languagesAndTypefaceTable, ETrue  },
       
   521     { LIT_AS_DESC_PTR(KSansSerif) ,LIT_AS_DESC_PTR(KS60Group), &languagesAndTypefaceTable, ETrue  },
       
   522     { LIT_AS_DESC_PTR(KSerif) ,LIT_AS_DESC_PTR(KS60Group), &languagesAndTypefaceTable, ETrue  },
       
   523     { LIT_AS_DESC_PTR(KMonospace) ,LIT_AS_DESC_PTR(KS60Group), &languagesAndTypefaceTable, ETrue  },
       
   524     { LIT_AS_DESC_PTR(KArial) ,LIT_AS_DESC_PTR(KS60Group), &languagesAndTypefaceTable, EFalse  },
       
   525     { LIT_AS_DESC_PTR(KVerdana),LIT_AS_DESC_PTR(KS60Group), &languagesAndTypefaceTable, EFalse  },
       
   526     { LIT_AS_DESC_PTR(KHelvetica),LIT_AS_DESC_PTR(KS60Group), &languagesAndTypefaceTable, EFalse  },
       
   527     { LIT_AS_DESC_PTR(KGeorgia),LIT_AS_DESC_PTR(KS60Group), &languagesAndTypefaceTable, EFalse  },
       
   528     { LIT_AS_DESC_PTR(KTimes),LIT_AS_DESC_PTR(KS60Group), &languagesAndTypefaceTable, EFalse  },
       
   529     { LIT_AS_DESC_PTR(KTimesNewRoman) ,LIT_AS_DESC_PTR(KS60Group), &languagesAndTypefaceTable, EFalse  },
       
   530     { LIT_AS_DESC_PTR(KCourier) ,LIT_AS_DESC_PTR(KS60Group), &languagesAndTypefaceTable, EFalse  },
       
   531     { LIT_AS_DESC_PTR(KNullDesC) ,LIT_AS_DESC_PTR(KS60Group), &languagesAndTypefaceTable, EFalse }
       
   532 };
       
   533 
       
   534 // Product font table.
       
   535 
       
   536 // Default index in case of total failure to match a request
       
   537 const TInt KDefaultFontTableIndex(0);
       
   538 
       
   539 static const SAknProductFontTableLine productFontTable[] = {
       
   540     // Category matching
       
   541     // Latin and Devanagari part
       
   542     { EAknFontCategorySecondary,    10,   15,   EStrokeWeightNormal, 0,    EAny, ENotBold, ENotAntialiase, EElafLangs, LIT_AS_DESC_PTR(KS60Sans), NULL, NULL, &latinHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   543     { EAknFontCategorySecondary,    EAny, EAny, EStrokeWeightNormal, EAny, EAny, ENotBold, EAntialiase,    EElafLangs, LIT_AS_DESC_PTR(KS60Sans), NULL, NULL, &latinHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   544     { EAknFontCategorySecondary,    10,   15,   EStrokeWeightBold,   0,    EAny, EBold,    ENotAntialiase, EElafLangs, LIT_AS_DESC_PTR(KS60Sans), NULL, NULL, &latinHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   545     { EAknFontCategorySecondary,    EAny, EAny, EStrokeWeightBold,   EAny, EAny, EBold,    EAntialiase,    EElafLangs, LIT_AS_DESC_PTR(KS60Sans), NULL, NULL, &latinHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   546     { EAknFontCategoryPrimarySmall, 10,   15,   EAny,                0,    EAny, EBold,    ENotAntialiase, EElafLangs, LIT_AS_DESC_PTR(KS60Sans), NULL, NULL, &latinHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   547     { EAknFontCategoryPrimarySmall, EAny, EAny, EAny,                EAny, EAny, EBold,    EAntialiase,    EElafLangs, LIT_AS_DESC_PTR(KS60Sans), NULL, NULL, &latinHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   548     { EAknFontCategoryPrimary,      10,   15,   EAny,                0,    EAny, EBold,    ENotAntialiase, EElafLangs, LIT_AS_DESC_PTR(KS60Sans), NULL, NULL, &latinHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   549     { EAknFontCategoryPrimary,      EAny, EAny, EAny,                EAny, EAny, EBold,    EAntialiase,    EElafLangs, LIT_AS_DESC_PTR(KS60Sans), NULL, NULL, &latinHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   550     { EAknFontCategoryTitle,        10,   19,   EAny,                0,    EAny, ENotBold, ENotAntialiase, EElafLangs, LIT_AS_DESC_PTR(KS60SansTitleSemiBold), NULL, NULL, &latinHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   551     { EAknFontCategoryTitle,        EAny, EAny, EAny,                EAny, EAny, ENotBold, EAntialiase,    EElafLangs, LIT_AS_DESC_PTR(KS60SansTitleSemiBold), NULL, NULL, &latinHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   552 
       
   553     // use this digital one for any Languages
       
   554     { EAknFontCategoryDigital,      EAny, 10, EAny, 0,    EAny, ENotBold, ENotAntialiase, EAnyLangs, LIT_AS_DESC_PTR(KS60Digital), NULL, NULL, &agfaDigitalHeightRequestArray, NULL },
       
   555     { EAknFontCategoryDigital,      11, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EAnyLangs, LIT_AS_DESC_PTR(KS60Digital), NULL, NULL, &agfaDigitalHeightRequestArray, NULL },
       
   556     
       
   557     // The following two to impose a "Series 60 Sans" family at the FontProvider level for elaf
       
   558     { EAknFontCategoryAny,          10,   15,   EStrokeWeightNormal, 0,    EAny, ENotBold, ENotAntialiase, EElafLangs, LIT_AS_DESC_PTR(KS60Sans), LIT_AS_DESC_PTR(KS60Group), NULL, &latinHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   559     { EAknFontCategoryAny,          EAny, EAny, EStrokeWeightNormal, EAny, EAny, ENotBold, EAntialiase, EElafLangs, LIT_AS_DESC_PTR(KS60Sans), LIT_AS_DESC_PTR(KS60Group), NULL, &latinHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   560     { EAknFontCategoryAny,          10,   15,   EStrokeWeightBold,   0,    EAny, EBold,    ENotAntialiase, EElafLangs, LIT_AS_DESC_PTR(KS60Sans), LIT_AS_DESC_PTR(KS60Group), NULL, &latinHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   561     { EAknFontCategoryAny,          EAny, EAny, EStrokeWeightBold,   EAny, EAny, EBold,    EAntialiase, EElafLangs, LIT_AS_DESC_PTR(KS60Sans), LIT_AS_DESC_PTR(KS60Group), NULL, &latinHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   562 
       
   563     { EAknFontCategorySecondary,    12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsPRC, LIT_AS_DESC_PTR(KS60SC), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   564     { EAknFontCategorySecondary,    EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRC, LIT_AS_DESC_PTR(KS60SC), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   565     { EAknFontCategoryPrimarySmall, 12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsPRC, LIT_AS_DESC_PTR(KS60SC), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   566     { EAknFontCategoryPrimarySmall, EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRC, LIT_AS_DESC_PTR(KS60SC), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   567     { EAknFontCategoryPrimary,      12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsPRC, LIT_AS_DESC_PTR(KS60SC), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   568     { EAknFontCategoryPrimary,      EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRC, LIT_AS_DESC_PTR(KS60SC), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   569     { EAknFontCategoryTitle,        12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsPRC, LIT_AS_DESC_PTR(KS60SC), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   570     { EAknFontCategoryTitle,        EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRC, LIT_AS_DESC_PTR(KS60SC), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   571     { EAknFontCategoryAny,          12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsPRC, LIT_AS_DESC_PTR(KS60SC), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   572     { EAknFontCategoryAny,          EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRC, LIT_AS_DESC_PTR(KS60SC), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   573 
       
   574     { EAknFontCategorySecondary,    12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsTaiwanHK, LIT_AS_DESC_PTR(KS60TCAndHK), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   575     { EAknFontCategorySecondary,    EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHK, LIT_AS_DESC_PTR(KS60TCAndHK), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   576     { EAknFontCategoryPrimarySmall, 12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsTaiwanHK, LIT_AS_DESC_PTR(KS60TCAndHK), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   577     { EAknFontCategoryPrimarySmall, EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHK, LIT_AS_DESC_PTR(KS60TCAndHK), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   578     { EAknFontCategoryPrimary,      12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsTaiwanHK, LIT_AS_DESC_PTR(KS60TCAndHK), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   579     { EAknFontCategoryPrimary,      EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHK, LIT_AS_DESC_PTR(KS60TCAndHK), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   580     { EAknFontCategoryTitle,        12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsTaiwanHK, LIT_AS_DESC_PTR(KS60TCAndHK), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   581     { EAknFontCategoryTitle,        EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHK, LIT_AS_DESC_PTR(KS60TCAndHK), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   582     { EAknFontCategoryAny,          12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsTaiwanHK, LIT_AS_DESC_PTR(KS60TCAndHK), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   583     { EAknFontCategoryAny,          EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHK, LIT_AS_DESC_PTR(KS60TCAndHK), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &strokeFontHeightRequestArray, NULL },
       
   584 
       
   585     { EAknFontCategorySecondary,    12,   15,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EJapaneseLangs, LIT_AS_DESC_PTR(KJapaneseHensei), LIT_AS_DESC_PTR(KS60Group), &heiseiBaselineArray, &heiseiFontHeightRequestArray, NULL },
       
   586     { EAknFontCategorySecondary,    EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EJapaneseLangs, LIT_AS_DESC_PTR(KJapaneseHensei), LIT_AS_DESC_PTR(KS60Group), &heiseiBaselineArray, &heiseiFontHeightRequestArray, NULL },
       
   587     { EAknFontCategoryPrimarySmall, 12,   15,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EJapaneseLangs, LIT_AS_DESC_PTR(KJapaneseHensei), LIT_AS_DESC_PTR(KS60Group), &heiseiBaselineArray, &heiseiFontHeightRequestArray, NULL },
       
   588     { EAknFontCategoryPrimarySmall, EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EJapaneseLangs, LIT_AS_DESC_PTR(KJapaneseHensei), LIT_AS_DESC_PTR(KS60Group), &heiseiBaselineArray, &heiseiFontHeightRequestArray, NULL },
       
   589     { EAknFontCategoryPrimary,      12,   15,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EJapaneseLangs, LIT_AS_DESC_PTR(KJapaneseHensei), LIT_AS_DESC_PTR(KS60Group), &heiseiBaselineArray, &heiseiFontHeightRequestArray, NULL },
       
   590     { EAknFontCategoryPrimary,      EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EJapaneseLangs, LIT_AS_DESC_PTR(KJapaneseHensei), LIT_AS_DESC_PTR(KS60Group), &heiseiBaselineArray, &heiseiFontHeightRequestArray, NULL },
       
   591     { EAknFontCategoryTitle,        12,   15,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EJapaneseLangs, LIT_AS_DESC_PTR(KJapaneseHensei), LIT_AS_DESC_PTR(KS60Group), &heiseiBaselineArray, &heiseiFontHeightRequestArray, NULL },
       
   592     { EAknFontCategoryTitle,        EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EJapaneseLangs, LIT_AS_DESC_PTR(KJapaneseHensei), LIT_AS_DESC_PTR(KS60Group), &heiseiBaselineArray, &heiseiFontHeightRequestArray, NULL },
       
   593     { EAknFontCategoryAny,          12,   15,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EJapaneseLangs, LIT_AS_DESC_PTR(KJapaneseHensei), LIT_AS_DESC_PTR(KS60Group), &heiseiBaselineArray, &heiseiFontHeightRequestArray, NULL },
       
   594     { EAknFontCategoryAny,          EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EJapaneseLangs, LIT_AS_DESC_PTR(KJapaneseHensei), LIT_AS_DESC_PTR(KS60Group), &heiseiBaselineArray, &heiseiFontHeightRequestArray, NULL },
       
   595 
       
   596     { EAknFontCategorySecondary,    0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCHiRes, LIT_AS_DESC_PTR(KS60SCHiRes), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   597     { EAknFontCategoryPrimarySmall, 0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCHiRes, LIT_AS_DESC_PTR(KS60SCHiRes), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   598     { EAknFontCategoryPrimary,      0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCHiRes, LIT_AS_DESC_PTR(KS60SCHiRes), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   599     { EAknFontCategoryTitle,        0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCHiRes, LIT_AS_DESC_PTR(KS60SCHiRes), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   600     { EAknFontCategoryAny,          0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCHiRes, LIT_AS_DESC_PTR(KS60SCHiRes), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   601 
       
   602     { EAknFontCategorySecondary,    0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKHiRes, LIT_AS_DESC_PTR(KS60TCAndHKHiRes), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   603     { EAknFontCategoryPrimarySmall, 0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKHiRes, LIT_AS_DESC_PTR(KS60TCAndHKHiRes), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   604     { EAknFontCategoryPrimary,      0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKHiRes, LIT_AS_DESC_PTR(KS60TCAndHKHiRes), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   605     { EAknFontCategoryTitle,        0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKHiRes, LIT_AS_DESC_PTR(KS60TCAndHKHiRes), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   606     { EAknFontCategoryAny,          0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKHiRes, LIT_AS_DESC_PTR(KS60TCAndHKHiRes), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   607 
       
   608     { EAknFontCategorySecondary,   8, 17,    	EAny, EAny, EAny, ENotBold, ENotAntialiase, EKoreanLangs, LIT_AS_DESC_PTR(KS60Korean), LIT_AS_DESC_PTR(KS60Group), &koreanVectorFontBaselineArray, &koreanFontHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   609     { EAknFontCategorySecondary,    EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase,    EKoreanLangs, LIT_AS_DESC_PTR(KS60Korean), LIT_AS_DESC_PTR(KS60Group), &koreanVectorFontBaselineArray, &koreanFontHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   610     { EAknFontCategoryPrimarySmall, 8, 17,     	EAny, EAny, EAny, ENotBold, ENotAntialiase, EKoreanLangs, LIT_AS_DESC_PTR(KS60Korean), LIT_AS_DESC_PTR(KS60Group), &koreanVectorFontBaselineArray, &koreanFontHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   611     { EAknFontCategoryPrimarySmall, EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase,    EKoreanLangs, LIT_AS_DESC_PTR(KS60Korean), LIT_AS_DESC_PTR(KS60Group), &koreanVectorFontBaselineArray, &koreanFontHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   612     { EAknFontCategoryPrimary,      8, 17,     	EAny, EAny, EAny, ENotBold, ENotAntialiase, EKoreanLangs, LIT_AS_DESC_PTR(KS60Korean), LIT_AS_DESC_PTR(KS60Group), &koreanVectorFontBaselineArray, &koreanFontHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   613     { EAknFontCategoryPrimary,      EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase,    EKoreanLangs, LIT_AS_DESC_PTR(KS60Korean), LIT_AS_DESC_PTR(KS60Group), &koreanVectorFontBaselineArray, &koreanFontHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   614     { EAknFontCategoryTitle,        8, 17,     	EAny, EAny, EAny, ENotBold, ENotAntialiase, EKoreanLangs, LIT_AS_DESC_PTR(KS60Korean), LIT_AS_DESC_PTR(KS60Group), &koreanVectorFontBaselineArray, &koreanFontHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   615     { EAknFontCategoryTitle,        EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase,    EKoreanLangs, LIT_AS_DESC_PTR(KS60Korean), LIT_AS_DESC_PTR(KS60Group), &koreanVectorFontBaselineArray, &koreanFontHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   616     { EAknFontCategoryAny,          8, 17,  	EAny, EAny, EAny, ENotBold, ENotAntialiase, EKoreanLangs, LIT_AS_DESC_PTR(KS60Korean), LIT_AS_DESC_PTR(KS60Group), &koreanVectorFontBaselineArray, &koreanFontHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   617     { EAknFontCategoryAny,          EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, 	EKoreanLangs, LIT_AS_DESC_PTR(KS60Korean), LIT_AS_DESC_PTR(KS60Group), &koreanVectorFontBaselineArray, &koreanFontHeightRequestArray, LIT_AS_DESC_PTR(KWesternFontMaxExtentText) },
       
   618 //chinese adaptation
       
   619     { EAknFontCategorySecondary,    12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsPRCLF, LIT_AS_DESC_PTR(KS60SCSANSRLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   620     { EAknFontCategorySecondary,    EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCLF, LIT_AS_DESC_PTR(KS60SCSANSRLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   621     { EAknFontCategoryPrimarySmall, 12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsPRCLF, LIT_AS_DESC_PTR(KS60SCSANSSBLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   622     { EAknFontCategoryPrimarySmall, EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCLF, LIT_AS_DESC_PTR(KS60SCSANSSBLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   623     { EAknFontCategoryPrimary,      12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsPRCLF, LIT_AS_DESC_PTR(KS60SCSANSSBLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   624     { EAknFontCategoryPrimary,      EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCLF, LIT_AS_DESC_PTR(KS60SCSANSSBLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   625     { EAknFontCategoryTitle,        12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsPRCLF, LIT_AS_DESC_PTR(KS60SCSANSTTLSMBLDLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   626     { EAknFontCategoryTitle,        EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCLF, LIT_AS_DESC_PTR(KS60SCSANSTTLSMBLDLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   627     { EAknFontCategoryAny,          12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsPRCLF, LIT_AS_DESC_PTR(KS60SCSANSRLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   628     { EAknFontCategoryAny,          EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCLF, LIT_AS_DESC_PTR(KS60SCSANSRLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   629 
       
   630     { EAknFontCategorySecondary,    12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsTaiwanHKLF, LIT_AS_DESC_PTR(KS60TCHKSANSRLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   631     { EAknFontCategorySecondary,    EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKLF, LIT_AS_DESC_PTR(KS60TCHKSANSRLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   632     { EAknFontCategoryPrimarySmall, 12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsTaiwanHKLF, LIT_AS_DESC_PTR(KS60TCHKSANSSBLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   633     { EAknFontCategoryPrimarySmall, EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKLF, LIT_AS_DESC_PTR(KS60TCHKSANSSBLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   634     { EAknFontCategoryPrimary,      12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsTaiwanHKLF, LIT_AS_DESC_PTR(KS60TCHKSANSSBLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   635     { EAknFontCategoryPrimary,      EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKLF, LIT_AS_DESC_PTR(KS60TCHKSANSSBLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   636     { EAknFontCategoryTitle,        12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsTaiwanHKLF, LIT_AS_DESC_PTR(KS60TCHKSANSTTLSMBLDLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   637     { EAknFontCategoryTitle,        EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKLF, LIT_AS_DESC_PTR(KS60TCHKSANSTTLSMBLDLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   638     { EAknFontCategoryAny,          12,   21,   EAny, 0,    EAny, ENotBold, ENotAntialiase, EChineseLangsTaiwanHKLF, LIT_AS_DESC_PTR(KS60TCHKSANSRLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   639     { EAknFontCategoryAny,          EAny, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKLF, LIT_AS_DESC_PTR(KS60TCHKSANSRLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, &chnlinkedFontHeightRequestArray, NULL },
       
   640 
       
   641     { EAknFontCategorySecondary,    0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCHiResLF, LIT_AS_DESC_PTR(KS60SCHRSANSRLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   642     { EAknFontCategoryPrimarySmall, 0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCHiResLF, LIT_AS_DESC_PTR(KS60SCHRSANSSBLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   643     { EAknFontCategoryPrimary,      0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCHiResLF, LIT_AS_DESC_PTR(KS60SCHRSANSSBLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   644     { EAknFontCategoryTitle,        0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCHiResLF, LIT_AS_DESC_PTR(KS60SCHRSANSTTLSMBLDLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   645     { EAknFontCategoryAny,          0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsPRCHiResLF, LIT_AS_DESC_PTR(KS60SCHRSANSRLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   646 
       
   647     { EAknFontCategorySecondary,    0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKHiResLF, LIT_AS_DESC_PTR(KS60TCHKHRSANSRLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   648     { EAknFontCategoryPrimarySmall, 0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKHiResLF, LIT_AS_DESC_PTR(KS60TCHKHRSANSSBLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   649     { EAknFontCategoryPrimary,      0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKHiResLF, LIT_AS_DESC_PTR(KS60TCHKHRSANSSBLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   650     { EAknFontCategoryTitle,        0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKHiResLF, LIT_AS_DESC_PTR(KS60TCHKHRSANSTTLSMBLDLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL },
       
   651     { EAknFontCategoryAny,          0, EAny, EAny, EAny, EAny, ENotBold, EAntialiase, EChineseLangsTaiwanHKHiResLF, LIT_AS_DESC_PTR(KS60TCHKHRSANSRLF), LIT_AS_DESC_PTR(KS60Group), &apacVectorFontBaselineArray, NULL, NULL }
       
   652 //end
       
   653     };
       
   654 // ============================ GLOBAL FUNCTIONS ========================================
       
   655 
       
   656 /**
       
   657  * DLL entry point
       
   658  */
       
   659 #ifndef EKA2
       
   660 GLDEF_C TInt E32Dll(TDllReason /* aReason */)
       
   661     {
       
   662     return(KErrNone);
       
   663     }
       
   664 #endif
       
   665 
       
   666 // ============================ LOCAL FUNCTIONS ===============================
       
   667 //chinese adaptation func. declarations
       
   668 TInt IntializeLinkedFontL();
       
   669 void PopulateFontFileNames(TFileText& tfile, RPointerArray<SLinkedFontDetails>& fontfiles, const TDesC& stop);
       
   670 TInt CreateLinkFontsL(RPointerArray<SLinkedFontDetails>& fontfiles);
       
   671 TBool ChineseLinkedFontPresent(const TDesC& newFaceName);
       
   672 TInt DoPopulateAndCreateLinkFontsL(TFileText atfile,  TDesC& astartTok, TDesC& astopTok);
       
   673 TBool LinkTypefacesInstalled();
       
   674 //end
       
   675 LOCAL_C void Panic(TAknFontProviderPanicCodes aPanic)
       
   676     {
       
   677     _LIT( KFontProviderCategory, "Font Provider" );
       
   678     User::Panic( KFontProviderCategory, aPanic );
       
   679     }
       
   680 
       
   681 /*
       
   682 * Utility routine to pull common flags and size in pixels from the TAknFontSpecification.
       
   683 */
       
   684 LOCAL_C void SetLocalFlagsAndMetrics(
       
   685     const TAknFontSpecification& aMetrics,
       
   686     MGraphicsDeviceMap& aDevice, 
       
   687     TBool& aNeedsExactMatch, 
       
   688     TBool& aReduceSize, 
       
   689     TInt& aSizeInPixels )
       
   690     {
       
   691     // Set flags for suppressing size downgrade, and suppressing fallbacks 
       
   692     aNeedsExactMatch = aMetrics.ExactMatchRequired();
       
   693     aReduceSize = !aMetrics.TextPaneIsDesignHeight();
       
   694     
       
   695     // Calculate size in pixels
       
   696     aSizeInPixels = aMetrics.TextPaneHeight();
       
   697     if ( aMetrics.Units() == TAknFontSpecification::ETwips )
       
   698         {
       
   699         aSizeInPixels = aDevice.VerticalTwipsToPixels( aMetrics.TextPaneHeight() );
       
   700         }
       
   701     }
       
   702 
       
   703 /*
       
   704 * Sets the bit field that describes which languages are required to be supported by the matched font
       
   705 */
       
   706 LOCAL_C TUint FontProviderRequiredLangs()
       
   707     {
       
   708     TUint requiredLangs(0);
       
   709     TLanguage uilang = User::Language();
       
   710     TBool fJapanese = FeatureManager::FeatureSupported(KFeatureIdJapanese);
       
   711     TBool fTCHKFonts = FeatureManager::FeatureSupported(KFeatureIdChineseTaiwanHkFonts);
       
   712     TBool fSCFonts = FeatureManager::FeatureSupported(KFeatureIdChinesePrcFonts);
       
   713     TBool fHiResFonts = FeatureManager::FeatureSupported(KFeatureIdChineseFontsHires);
       
   714     TBool fKorean = FeatureManager::FeatureSupported(KFeatureIdKorean);
       
   715    //chinese adaptation
       
   716     TBool fChLinkFlag = FeatureManager::FeatureSupported(KFeatureIdFfLinkedFontsChinese);
       
   717     TBool fChLinkedFonts = EFalse;
       
   718     //handling error here
       
   719     //fontlinking unsuccessful, handle with normal font files as earlier
       
   720     if(fChLinkFlag)
       
   721         {
       
   722       if(!LinkTypefacesInstalled())
       
   723         fChLinkedFonts = EFalse;
       
   724     else
       
   725         fChLinkedFonts = ETrue;
       
   726         }
       
   727     //end
       
   728 
       
   729     if(fKorean)
       
   730         {
       
   731         requiredLangs |= EKoreanLangs;
       
   732         }
       
   733     else if (fJapanese)
       
   734         {
       
   735         requiredLangs |= EJapaneseLangs;
       
   736         }
       
   737     else if (fTCHKFonts)
       
   738         {
       
   739         // TCHK, but use PRC fonts, if lang settings say it's PRC English
       
   740         if ((fSCFonts) && (uilang == KLangPrcEnglish || uilang == ELangPrcChinese))
       
   741             {
       
   742             //chinese adaptation
       
   743             if (fChLinkedFonts && fHiResFonts)
       
   744                 {
       
   745                 requiredLangs |= EChineseLangsPRCHiResLF;
       
   746                 }
       
   747             else if(fChLinkedFonts)
       
   748                 {
       
   749                 requiredLangs |= EChineseLangsPRCLF;
       
   750                 }            
       
   751             //end
       
   752             else if (fHiResFonts)
       
   753                 {
       
   754                 requiredLangs |= EChineseLangsPRCHiRes;
       
   755                 }
       
   756             else
       
   757                 {
       
   758                 requiredLangs |= EChineseLangsPRC;
       
   759                 }
       
   760             }
       
   761         else
       
   762             {
       
   763             //chinese adaptation
       
   764             if (fChLinkedFonts && fHiResFonts)
       
   765                 {
       
   766                 requiredLangs |= EChineseLangsTaiwanHKHiResLF;
       
   767                 }  
       
   768             else if(fChLinkedFonts)
       
   769                 {
       
   770                 requiredLangs |= EChineseLangsTaiwanHKLF;
       
   771                 }
       
   772             //end
       
   773             else if (fHiResFonts)
       
   774                 {
       
   775                 requiredLangs |= EChineseLangsTaiwanHKHiRes;
       
   776                 }
       
   777             else
       
   778                 {
       
   779                 requiredLangs |= EChineseLangsTaiwanHK;
       
   780                 }
       
   781             }
       
   782         }
       
   783     else if (fSCFonts)
       
   784         {
       
   785         //chinese adaptation
       
   786         if (fChLinkedFonts && fHiResFonts)
       
   787             {
       
   788             requiredLangs |= EChineseLangsPRCHiResLF;
       
   789             }
       
   790         else if(fChLinkedFonts)
       
   791             {
       
   792             requiredLangs |= EChineseLangsPRCLF;
       
   793             }
       
   794         //end
       
   795         // PRC (SC)
       
   796         else if (fHiResFonts)
       
   797             {
       
   798             requiredLangs |= EChineseLangsPRCHiRes;
       
   799             }
       
   800         else
       
   801             {
       
   802             requiredLangs |= EChineseLangsPRC;
       
   803             }
       
   804         }
       
   805     else
       
   806         {
       
   807         requiredLangs |= EElafLangs;    
       
   808         }
       
   809 
       
   810     return requiredLangs;
       
   811     }
       
   812 
       
   813 /*
       
   814 * Applies size reduction to the height that will be passed to the Symbian font request. This is usually to 
       
   815 * account for glyph excursions that go beyond the fonts "design height".
       
   816 */
       
   817 LOCAL_C TInt ReducedFontHeight(
       
   818     TInt aOriginalHeight, 
       
   819     TCdlArray<SHeightRequest> const* aHeightRequestArray )
       
   820     {
       
   821     TInt numberOfSizes = aHeightRequestArray->Count();
       
   822     TInt requestHeight(aOriginalHeight);
       
   823     for ( TInt i = 0; i < numberOfSizes; i++ )
       
   824         {
       
   825         SHeightRequest heightRequest  = (*aHeightRequestArray)[i];
       
   826 
       
   827         if ( heightRequest.iDesignHeight == aOriginalHeight )
       
   828             {
       
   829             requestHeight = heightRequest.iRequestHeight;
       
   830             break;
       
   831             }
       
   832         if ( (i+1) < numberOfSizes )
       
   833             {
       
   834             SHeightRequest nextHeightRequest  = (*aHeightRequestArray)[i+1];
       
   835             if ( heightRequest.iDesignHeight < aOriginalHeight
       
   836                 && aOriginalHeight < nextHeightRequest.iDesignHeight )
       
   837                 {
       
   838                 // Interpolate. Inequalities above guarantee denominator is Positive
       
   839                 // Formula used is:
       
   840                 // y = [ x*(y2 - y1) + y1*x2 - y2*x1 ] / (x2 - x1)  
       
   841                 //
       
   842                 TInt denominator = nextHeightRequest.iDesignHeight - heightRequest.iDesignHeight;
       
   843                 TInt numerator = aOriginalHeight * ( nextHeightRequest.iRequestHeight - heightRequest.iRequestHeight)
       
   844                     + heightRequest.iRequestHeight * nextHeightRequest.iDesignHeight
       
   845                     - nextHeightRequest.iRequestHeight * heightRequest.iDesignHeight;
       
   846 
       
   847                 requestHeight = numerator/denominator; // rounds down
       
   848                 break;
       
   849                 }
       
   850             }
       
   851         }
       
   852     return requestHeight;
       
   853     }
       
   854 
       
   855 /*
       
   856 * Fills in additional metrics, if available, for the font being returned.
       
   857 */
       
   858 LOCAL_C void SetFontProviderSuppliedMetrics( const CFbsFont* aFont, 
       
   859                         const SAknProductFontTableLine* aLine, 
       
   860                         TAknFontProviderSuppliedMetrics& aInfo )
       
   861     {
       
   862     // Measure the font
       
   863     TOpenFontMetrics openFontMetrics;
       
   864     aFont->GetFontMetrics(openFontMetrics);
       
   865 
       
   866     // Record maximum extent, up (min) and down (max) ,from the baseline
       
   867     TInt minY(0); 
       
   868     TInt maxY(0);
       
   869 
       
   870     if ( aLine )
       
   871         {
       
   872         // Check the specified maximal text 
       
   873         const TDesC* maxExtentText = aLine->iMaxAscentDescentChars;
       
   874         if ( maxExtentText )
       
   875             {
       
   876             TInt len = maxExtentText->Length();
       
   877             for ( TInt i = 0; i < len; i++)
       
   878                 {
       
   879                 TOpenFontCharMetrics openFontCharMetrics;
       
   880                 const TUint8* aBitmap;
       
   881                 TSize size;
       
   882                 if ( aFont->GetCharacterData((*maxExtentText)[i],openFontCharMetrics, aBitmap, size) )
       
   883                     {
       
   884                     TRect rect;
       
   885                     openFontCharMetrics.GetHorizBounds( rect );
       
   886                     minY = Min( minY, rect.iTl.iY );
       
   887                     maxY = Max( maxY, rect.iBr.iY );
       
   888                     }
       
   889                 }
       
   890             }
       
   891                        
       
   892         }
       
   893     else // No fontprovider line is available. Use the openfont apis
       
   894         {
       
   895         minY = - openFontMetrics.MaxHeight();
       
   896         maxY = openFontMetrics.MaxDepth();        
       
   897         }
       
   898         
       
   899     // Fill in return data.
       
   900     if ( minY < 0 )
       
   901         aInfo.SetExcessAscent( -minY - aFont->AscentInPixels() );
       
   902     else
       
   903         aInfo.SetExcessAscent(0);
       
   904 
       
   905     if ( maxY > 0 )
       
   906         aInfo.SetExcessDescent( maxY - aFont->DescentInPixels() );
       
   907     else
       
   908         aInfo.SetExcessDescent(0);
       
   909 
       
   910     // Policy for where to put missing font height: 
       
   911     // Put any "empty" space at the top. That is, max descent goes just to TextPaneBottom 
       
   912     aInfo.SetMaxDescentToTextPaneBottom(0);
       
   913     }
       
   914 
       
   915 LOCAL_C TBool SetLanguageDependentDeAliasedTypeface( 
       
   916            TCdlArray<SAknLanguagesAndTypefaceTableLine> const* aLangAndTypefaceTable, 
       
   917            TUint aRequiredLanguages, 
       
   918            TTypeface& aTypeface )
       
   919     {
       
   920     TBool found(EFalse);
       
   921     // Search through aliases until you find a language set + alias combination that is OK
       
   922     TInt numberOfRowsInLanguageTable = aLangAndTypefaceTable->Count();
       
   923     for ( TInt index = 0; index < numberOfRowsInLanguageTable; index++ )
       
   924         {
       
   925         const SAknLanguagesAndTypefaceTableLine& subLine = aLangAndTypefaceTable->At(index);
       
   926  
       
   927         if ( ( subLine.iSupportedLanguagesPattern == EAnyLangs) ||
       
   928              ( ( aRequiredLanguages & subLine.iSupportedLanguagesPattern ) == aRequiredLanguages )  )
       
   929             {
       
   930             found = ETrue;
       
   931             aTypeface.iName = subLine.iTypefaceName->Left(KMaxTypefaceNameLength);
       
   932             break;
       
   933             }
       
   934         }
       
   935 
       
   936     return found;    
       
   937     }
       
   938 
       
   939 // aTypefaceOut might not be the same object as aGroupTypeface
       
   940 // parameter aAliasIsGeneric is not touched unless there is a match. Then it gets the value read from the
       
   941 // table.
       
   942 LOCAL_C void DeAliasTypeface( TUint aLangs, 
       
   943     const TTypeface& aTypefaceIn, 
       
   944     TTypeface& aTypefaceOut, 
       
   945     TTypeface& aGroupTypeface,
       
   946     TBool& aAliasIsGeneric )
       
   947     {
       
   948     TTypeface input(aTypefaceIn);
       
   949 
       
   950     // Search through aliases until you find match
       
   951     TInt numberOfRows = sizeof( aliasTable )/ sizeof( SAknAliasTableLine );
       
   952   
       
   953     for (TInt index = 0; index < numberOfRows; index++)
       
   954         {
       
   955         SAknAliasTableLine line = aliasTable[index];
       
   956         // Check for leading substring or both are null descriptors
       
   957         if ( (input.iName.Length() >= KMinAliasLength && line.iAlias->FindF(input.iName ) == 0 ) ||
       
   958             ( input.iName.Length() == 0 && (line.iAlias)->Length() == 0 ) )
       
   959             {
       
   960             aAliasIsGeneric = line.iIsAliasGeneric;
       
   961             if (line.iGroupName)
       
   962                 {
       
   963                 aGroupTypeface = aTypefaceIn;         
       
   964                 aGroupTypeface.iName = line.iGroupName->Left(KMaxTypefaceNameLength);
       
   965                 }
       
   966 
       
   967             if ( line.iLanguagesAndTypefaceTable )
       
   968                 {
       
   969                 (void)SetLanguageDependentDeAliasedTypeface( line.iLanguagesAndTypefaceTable, aLangs, aTypefaceOut );
       
   970                 }
       
   971             // Stop looking.  Both group name and iLanguagesAndTypefaceTable need to be on same line.
       
   972             break;
       
   973             }
       
   974  
       
   975         }
       
   976 
       
   977     return;    
       
   978     }
       
   979 
       
   980 LOCAL_C TBool MatchIsExact( const TFontSpec aRequestedSpec, const CFont* aFont)
       
   981     {
       
   982     TFontSpec specFromFont = aFont->FontSpecInTwips();
       
   983     
       
   984 /*
       
   985 Notes on what an exact match is:
       
   986 i)   if typeface, unmapped, is found in the table and italics and bold match.
       
   987 ii)  if font family, unmapped, is found in the table and italics and bold match.
       
   988 iii) if requests is mapped from a generic name and italics and bold match 
       
   989 iv)  if typeface is blank and italics and bold match
       
   990 
       
   991 Now, whatever aliasing has been performed previously, it is impossible to tell here, but we 
       
   992 can judge based upon the two fontspecs.
       
   993 */
       
   994 
       
   995     if ( aRequestedSpec.iTypeface.iName.Length() != 0)
       
   996         {
       
   997         if (!(aRequestedSpec.iTypeface.iName.MatchF( specFromFont.iTypeface.iName)==0 ))
       
   998             {
       
   999             return EFalse;
       
  1000             }
       
  1001         // Note, that it is impossible here to see if FBserv has performed a font family level match    
       
  1002         }
       
  1003     else // typeface is absent
       
  1004         {
       
  1005         if (aRequestedSpec.iTypeface.Attributes() != specFromFont.iTypeface.Attributes() )
       
  1006             {
       
  1007             return EFalse;
       
  1008             }
       
  1009         }
       
  1010         
       
  1011     if (    (aRequestedSpec.iFontStyle.StrokeWeight() != specFromFont.iFontStyle.StrokeWeight() )
       
  1012         ||  (aRequestedSpec.iFontStyle.Posture() != specFromFont.iFontStyle.Posture() )   )       
       
  1013         {
       
  1014         return EFalse;
       
  1015         }
       
  1016         
       
  1017     return ETrue;    
       
  1018     }
       
  1019 
       
  1020 
       
  1021 /*
       
  1022 * Sets up a TFontSpec to request antialising
       
  1023 */
       
  1024 /*LOCAL_C void SetFontSpecAntiAliased( TFontSpec& afontSpec )
       
  1025     {
       
  1026     TOpenFontSpec openSpec;
       
  1027     openSpec.SetBitmapType(EAntiAliasedGlyphBitmap);
       
  1028     openSpec.GetTFontSpec(afontSpec); // sets the antialiasing into the TFontSpec
       
  1029     }
       
  1030 */
       
  1031 
       
  1032 /*
       
  1033 * Utility routine to apply the results of a matched font provider line at index aFontIndex into a Symbian 
       
  1034 * TFontSpec object.
       
  1035 */
       
  1036 LOCAL_C void SetUpFontSpecFromTableLine( 
       
  1037     TInt aFoundIndex, 
       
  1038     const TAknFontSpecification& aMetrics, 
       
  1039     TInt aSizeInPixels, 
       
  1040     TBool aReduceSize, 
       
  1041     TFontSpec& aFontSpec )
       
  1042     {
       
  1043     __ASSERT_ALWAYS( aFoundIndex > KErrNotFound, Panic(EAknFontPanicIndexOutOfRange) );
       
  1044 
       
  1045 
       
  1046     if ( productFontTable[aFoundIndex].iAntialisingToUse != ENotAntialiase )
       
  1047         {
       
  1048         //SetFontSpecAntiAliased( aFontSpec );
       
  1049          aFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
       
  1050         }
       
  1051 
       
  1052     // Get typeface from table
       
  1053     aFontSpec.iTypeface.iName =  (*(productFontTable[aFoundIndex].iTypefaceName)).Left(KMaxTypefaceNameLength);
       
  1054                     
       
  1055     // Height is in pixels. This is only suitable for sending to GetNearestFontInPixels
       
  1056     aFontSpec.iHeight = (productFontTable[aFoundIndex].iSizeToUse == EAny ? 
       
  1057         aSizeInPixels : productFontTable[aFoundIndex].iSizeToUse );
       
  1058     
       
  1059     if ( productFontTable[aFoundIndex].iBoldnessToUse == EBold 
       
  1060         || (productFontTable[aFoundIndex].iBoldnessToUse == EAny && (aMetrics.Weight() == EStrokeWeightBold) ) )
       
  1061         aFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold );
       
  1062 
       
  1063     if ( aMetrics.Posture() == EPostureItalic )
       
  1064         aFontSpec.iFontStyle.SetPosture(EPostureItalic);
       
  1065     
       
  1066     if ( aMetrics.IsOutlineEffectOn() )
       
  1067     	{
       
  1068     	aFontSpec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue);
       
  1069     	//outline effect works only when AA is set
       
  1070     	aFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);	
       
  1071     	}
       
  1072         
       
  1073 
       
  1074     // Alter the font specification iHeight using the table
       
  1075     // Check the "reduceSize" flag to see if we want size reduction
       
  1076     if ( aReduceSize && productFontTable[aFoundIndex].iHeightRequestData )
       
  1077         aFontSpec.iHeight = ReducedFontHeight( aFontSpec.iHeight, productFontTable[aFoundIndex].iHeightRequestData );
       
  1078         
       
  1079     // Ensure proportionality flag is set. Assumes all S60 fonts are proportional
       
  1080     aFontSpec.iTypeface.SetIsProportional(ETrue);    
       
  1081     }
       
  1082 
       
  1083 /*
       
  1084 * This returns true if the typeface is in the list of typefaces that the system says are available
       
  1085 * It may leave.
       
  1086 */
       
  1087 LOCAL_C TBool TypefaceAvailableL( 
       
  1088     CGraphicsDevice& aDevice, 
       
  1089     const TTypeface& aTypeface )
       
  1090     {
       
  1091     TBool found(EFalse);
       
  1092 
       
  1093     CDesCArray* array = new(ELeave) CDesCArrayFlat( 6 );
       
  1094     CleanupStack::PushL( array );
       
  1095 
       
  1096     FontUtils::GetAvailableFontsL(aDevice, *array, EGulNoSymbolFonts);
       
  1097     for ( TInt i = 0; i < array->Count(); i++ )
       
  1098         {       
       
  1099         TPtrC fontName((*array)[i]);
       
  1100 
       
  1101         if ( fontName.MatchF(aTypeface.iName) == 0 )
       
  1102             {
       
  1103             found = ETrue;
       
  1104             break;
       
  1105             }
       
  1106         }
       
  1107 
       
  1108     CleanupStack::PopAndDestroy( array );
       
  1109     return found;
       
  1110     }
       
  1111 
       
  1112 LOCAL_C TInt FindGroupAliasInTable( const TTypeface& aGroupTypeface, 
       
  1113                                    const TAknFontSpecification& aMetrics, 
       
  1114                                    TUint aRequiredLangs, 
       
  1115                                    TInt aSizeInPixels,
       
  1116                                    TBool aNeedsExactMatch,
       
  1117                                    TBool& aFellBack)
       
  1118     {
       
  1119     TInt numberOfRows = sizeof( productFontTable )/ sizeof( SAknProductFontTableLine );
       
  1120     TInt foundIndex = KErrNotFound;
       
  1121     TInt languageAndTypefaceDependentFallbackIndex(KErrNotFound);
       
  1122   
       
  1123     for (TInt index = 0; index < numberOfRows; index++)
       
  1124         {
       
  1125         SAknProductFontTableLine line = productFontTable[index];
       
  1126 
       
  1127        // Test typeface and language first to capture a language dependent fallback alias mapping
       
  1128 
       
  1129        // Passed-in typeface is checked first.   
       
  1130        // Then if groupname was given, use group name from the aliasing to check for a group match
       
  1131        // If no groupname was given, use the direct typeface, comparing agains actuals
       
  1132         if ( line.iGroupName && line.iGroupName->MatchF(aGroupTypeface.iName) == 0  )
       
  1133             {
       
  1134             if ( ( ( aRequiredLangs & line.iSupportedLanguagesPattern ) == aRequiredLangs )
       
  1135                   || line.iSupportedLanguagesPattern == EAnyLangs )
       
  1136                 {
       
  1137 
       
  1138                 // Latch the first index to pass this point (will become a fallback later)
       
  1139                 if (languageAndTypefaceDependentFallbackIndex == KErrNotFound)
       
  1140                     languageAndTypefaceDependentFallbackIndex = index;
       
  1141                 
       
  1142                 if (    ( line.iMinSize <= aSizeInPixels || line.iMinSize == EAny )
       
  1143                     &&  ( aSizeInPixels <= line.iMaxSize || line.iMaxSize == EAny) )
       
  1144                     {
       
  1145                     if ( COMPARE_BOOLS(productFontTable[index].iBold, ( aMetrics.Weight() == EStrokeWeightBold ) ) // it matches...
       
  1146                         || (productFontTable[index].iBold == EAny) ) // ... or use what was passed in
       
  1147                         {
       
  1148                         if ( COMPARE_BOOLS(productFontTable[index].iItalic, ( aMetrics.Posture() == EPostureItalic ) ) // it matches...
       
  1149                             || productFontTable[index].iItalic == EAny ) // ... or use what was passed in
       
  1150                             {
       
  1151                             foundIndex = index;
       
  1152                             break;
       
  1153                             }
       
  1154                         }
       
  1155                     }
       
  1156                 }
       
  1157             }
       
  1158         }
       
  1159 
       
  1160     if ( !aNeedsExactMatch && foundIndex == KErrNotFound )
       
  1161         {
       
  1162         // Consider the fallback index found above.  Only use if it the passed in typeface cannot be used
       
  1163         if( languageAndTypefaceDependentFallbackIndex != KErrNotFound  )
       
  1164             {
       
  1165             // Typeface and language content OK. Something else not quite right.
       
  1166             aFellBack = ETrue;
       
  1167             foundIndex = languageAndTypefaceDependentFallbackIndex;
       
  1168             }
       
  1169 
       
  1170      // else foundIndex stays at KErrNotFound for use later
       
  1171             
       
  1172         }        
       
  1173     return foundIndex;
       
  1174     }
       
  1175 
       
  1176 LOCAL_C void SetUpFontSpecFromTypefaceAndSpecification( 
       
  1177     const TTypeface& aTypeface,
       
  1178     const TAknFontSpecification& aMetrics,
       
  1179     TInt aSizeInPixels, 
       
  1180     TFontSpec& aFontSpec )
       
  1181     {
       
  1182     aFontSpec.iTypeface = aTypeface;
       
  1183     aFontSpec.iHeight = aSizeInPixels;
       
  1184 
       
  1185     // Transfer styles straight across
       
  1186     if  (aMetrics.Weight() == EStrokeWeightBold  )
       
  1187         aFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold );
       
  1188     if ( aMetrics.Posture() == EPostureItalic )
       
  1189         aFontSpec.iFontStyle.SetPosture(EPostureItalic);
       
  1190     
       
  1191     // Ensure proportionality flag is set. Assumes all S60 fonts are proportional
       
  1192     aFontSpec.iTypeface.SetIsProportional(ETrue);    
       
  1193     }
       
  1194 
       
  1195 LOCAL_C TBool HasRequiredLanguages( 
       
  1196     TUint aRequiredLanguages, 
       
  1197     CGraphicsDevice* /*aDevice*/, 
       
  1198     const CFbsFont* aFont )
       
  1199     {
       
  1200     TBool retVal(ETrue);
       
  1201 
       
  1202     if ( ELanguageSupportBasicLatin & aRequiredLanguages )
       
  1203         {
       
  1204         if ( !aFont->HasCharacter(KTestCharLatin) )
       
  1205             retVal = EFalse;
       
  1206         }
       
  1207     if ( retVal && (ELanguageSupportChinesePRC & aRequiredLanguages) )
       
  1208         {
       
  1209         if ( !aFont->HasCharacter(KTestCharChinese) )
       
  1210             retVal = EFalse;
       
  1211         }
       
  1212     if ( retVal && (ELanguageSupportChineseTaiwanHK & aRequiredLanguages) )
       
  1213         {
       
  1214         if ( !aFont->HasCharacter(KTestCharChinese) )
       
  1215             retVal = EFalse;
       
  1216         }
       
  1217     if ( retVal && (ELanguageSupportThai & aRequiredLanguages) )
       
  1218         {
       
  1219         if ( !aFont->HasCharacter(KTestCharThai) )
       
  1220             retVal = EFalse;
       
  1221         }
       
  1222     if ( retVal && (ELanguageSupportJapanese & aRequiredLanguages) )
       
  1223         {
       
  1224         if ( !aFont->HasCharacter(KTestCharHiragana) )
       
  1225             retVal = EFalse;
       
  1226         }
       
  1227 	if ( retVal && (ELanguageSupportKorean & aRequiredLanguages) )
       
  1228         {
       
  1229         if ( !aFont->HasCharacter(KTestCharKorean) )
       
  1230             retVal = EFalse;
       
  1231         }
       
  1232     return retVal;
       
  1233     }
       
  1234 
       
  1235 /*
       
  1236 * A default index is set if the index is found to be KErrNotFound
       
  1237 * @param aFoundIndex Upon exit, this is guaranteed to be 0 or +ve
       
  1238 * @param aFellBack  This is not affected if no fallback is has been performed
       
  1239 *                   Set to ETrue if there was a fallback.
       
  1240 */
       
  1241 LOCAL_C void FallBackIfNeeded( TInt& aFoundIndex, TInt& aFellBack )
       
  1242     {
       
  1243     if ( aFoundIndex <= KErrNotFound ) 
       
  1244         {
       
  1245         aFellBack = ETrue;
       
  1246         aFoundIndex = KDefaultFontTableIndex;
       
  1247         }
       
  1248     }
       
  1249 
       
  1250 /*
       
  1251 * This method tries to produce a font from the passed in typeface and metrics
       
  1252 * First availability of the typeface is checked. If it is available, it is then obtained from the 
       
  1253 * system, and checked for required languages support. Font is released if languages not supported.
       
  1254 *
       
  1255 * Null is returned if the above fails in any way.
       
  1256 */
       
  1257 LOCAL_C CFbsFont* TryToGetFontFromTypeface( 
       
  1258                                            CBitmapDevice* aDevice, 
       
  1259                                            const TTypeface& aTypeface,
       
  1260                                            const TAknFontSpecification& aMetrics,
       
  1261                                            TInt aSizeInPixels,
       
  1262                                            TUint aRequiredLanguages,
       
  1263                                            TFontSpec& aFontSpecUsed )
       
  1264 
       
  1265     {
       
  1266     CFbsFont* font = 0;
       
  1267     TBool available(EFalse);
       
  1268     TRAP_IGNORE( available = TypefaceAvailableL( *aDevice, aTypeface ) );
       
  1269     if ( available )
       
  1270         {
       
  1271         TFontSpec typefaceFontSpec;
       
  1272         if (aSizeInPixels > 16 )
       
  1273         {
       
  1274             //SetFontSpecAntiAliased( typefaceFontSpec );// Enable antialising
       
  1275             typefaceFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
       
  1276         }
       
  1277         SetUpFontSpecFromTypefaceAndSpecification( aTypeface, aMetrics, aSizeInPixels, typefaceFontSpec );
       
  1278 
       
  1279         if ( aDevice->GetNearestFontInPixels( (CFont*&)font, typefaceFontSpec ) != KErrNone )
       
  1280             {
       
  1281             font = 0;
       
  1282             }
       
  1283         else
       
  1284             {
       
  1285             if ( !HasRequiredLanguages( aRequiredLanguages, aDevice, font ) )
       
  1286                 {
       
  1287                 aDevice->ReleaseFont( font );
       
  1288                 font = 0;
       
  1289                 }
       
  1290             else
       
  1291                 {
       
  1292                 // fill in the fontSpec
       
  1293                 aFontSpecUsed = typefaceFontSpec;
       
  1294                 // otherwise, just keep the font around and suppress the fetch later on
       
  1295                 }
       
  1296             }
       
  1297         }
       
  1298     return font;
       
  1299     }
       
  1300 /* 
       
  1301 * This method tries to get a font from the system based on aliases. First the alias table is referred to returning
       
  1302 * "typeface group" and/or "direct typeface". The direct typeface is size/bold/italic independent, but language
       
  1303 * sensistive mapping from the alias.
       
  1304 *
       
  1305 * First the typeface group is searched for in the Product Font Table.  If this fails, the the fontspec is filled in
       
  1306 * using the passed in metrics and the directly aliased typeface, if there is one.
       
  1307 *
       
  1308 * If all that fails to fill in a fontspec, then a "Default typeface group" is used to search the Product Font Table.  
       
  1309 *
       
  1310 */ 
       
  1311 LOCAL_C CFbsFont* TryToGetFontFromAlias( 
       
  1312                                            CBitmapDevice* aDevice, 
       
  1313                                            const TTypeface& aTypeface,
       
  1314                                            const TAknFontSpecification& aMetrics,
       
  1315                                            TInt aSizeInPixels,
       
  1316                                            TUint aRequiredLanguages,
       
  1317                                            TBool aNeedsExactMatch,
       
  1318                                            TBool aReduceSize,
       
  1319                                            TFontSpec& aFontSpecUsed,
       
  1320                                            TInt& aFoundIndex,
       
  1321                                            TBool& aAliasIsGeneric, 
       
  1322                                            TBool& aFellBack
       
  1323                                            )
       
  1324 
       
  1325     {
       
  1326     CFbsFont* font = 0; // return value
       
  1327 
       
  1328     // Translate aliases
       
  1329     TTypeface groupTypeface; // used for matching in the font table
       
  1330     TTypeface directTypeface; // used as fallback
       
  1331     DeAliasTypeface( aRequiredLanguages, aTypeface, directTypeface, groupTypeface, aAliasIsGeneric );
       
  1332         
       
  1333     // Record whether there is a direct alias
       
  1334     TBool haveDirectTypeface(directTypeface.iName.Length() > 0 );
       
  1335 
       
  1336     if ( groupTypeface.iName.Length() > 0 )
       
  1337         {
       
  1338         aFoundIndex = FindGroupAliasInTable( 
       
  1339             groupTypeface, aMetrics, aRequiredLanguages, aSizeInPixels, aNeedsExactMatch, aFellBack);
       
  1340         }
       
  1341 
       
  1342     TBool specIsSetUp(EFalse);
       
  1343 
       
  1344     if ( aFoundIndex == KErrNotFound)
       
  1345         {
       
  1346         // Note that because the alias table has language matching, the direct typeface name should be 
       
  1347         // appropriate at least for language.
       
  1348         if ( haveDirectTypeface )
       
  1349             {
       
  1350             // Fill in the typeface directly from passed in information; no typeface yet.
       
  1351             SetUpFontSpecFromTypefaceAndSpecification( directTypeface, aMetrics, aSizeInPixels, aFontSpecUsed );
       
  1352             specIsSetUp = ETrue;
       
  1353             }
       
  1354         else if ( !aNeedsExactMatch )
       
  1355             {
       
  1356             // This is the end of the road.  No index from table, passed in typeface cannot be used, 
       
  1357             // and there is no size-independent alias
       
  1358             TInt fellback2; // Will be ignored
       
  1359             TTypeface defaultTypeface;
       
  1360             defaultTypeface.iName = KDefaultGroupName;
       
  1361             aFoundIndex = FindGroupAliasInTable( 
       
  1362                 defaultTypeface, aMetrics, aRequiredLanguages, aSizeInPixels, EFalse, fellback2);
       
  1363             FallBackIfNeeded( aFoundIndex, fellback2 );
       
  1364             SetUpFontSpecFromTableLine( aFoundIndex, aMetrics, aSizeInPixels, aReduceSize, aFontSpecUsed );
       
  1365             specIsSetUp = ETrue;
       
  1366             }
       
  1367         else
       
  1368             {
       
  1369             // leave font null and no spec set up. Going to return NULL eventually.
       
  1370             }
       
  1371 
       
  1372         }
       
  1373     else
       
  1374         {
       
  1375         SetUpFontSpecFromTableLine( aFoundIndex, aMetrics, aSizeInPixels, aReduceSize, aFontSpecUsed );
       
  1376         specIsSetUp = ETrue;
       
  1377         }
       
  1378 
       
  1379     if ( specIsSetUp )
       
  1380         {
       
  1381         if ( aDevice->GetNearestFontInPixels((CFont*&)font,aFontSpecUsed) != KErrNone )
       
  1382             {
       
  1383             font = 0;  // Assert will follow below
       
  1384             }
       
  1385         }
       
  1386 
       
  1387     return font;
       
  1388     }
       
  1389 
       
  1390 #ifdef _DEBUG
       
  1391 LOCAL_C void OutputDebugInfo( 
       
  1392                         CFbsFont* aFont,
       
  1393                         const TTypeface& aTypeface,
       
  1394                         const TAknFontSpecification& aMetrics,
       
  1395                         TInt aSizeInPixels,
       
  1396                         const TFontSpec& aFontSpec,
       
  1397                         const TAknFontProviderSuppliedMetrics& aInfo                       
       
  1398                         )
       
  1399     {
       
  1400     TBuf<256> buf;
       
  1401     if ( aFont )
       
  1402         {
       
  1403         TInt ascent = aFont->AscentInPixels();
       
  1404         TInt descent = aFont->DescentInPixels();
       
  1405         TInt range = aInfo.ExcessAscent() + aInfo.ExcessDescent() + ascent + descent;
       
  1406         TPtrC fontTypefaceName(aFont->FontSpecInTwips().iTypeface.iName);
       
  1407         buf.Format( _L("FontProvider:Type/Alias= %S; T'Pane Height=%d;  t'face req'st=%S; mappd ht=%d; t'face returnd=%S; actual range=%d(a,d,exa,exd=%d %d %d %d)" ), 
       
  1408          &(aTypeface.iName), aMetrics.TextPaneHeight(),&(aFontSpec.iTypeface.iName),aFontSpec.iHeight, &(fontTypefaceName), range, 
       
  1409          ascent, descent, aInfo.ExcessAscent(),aInfo.ExcessDescent() );
       
  1410         RDebug::Print( buf );
       
  1411         }
       
  1412     else
       
  1413         {
       
  1414         buf.Format( _L("FontProvider:Type/Alias= %S; T'Pane Height=%d;  t'face req'st=%S; sizeInPixels=%d; No Font Returned" ), 
       
  1415             &(aTypeface.iName), aMetrics.TextPaneHeight(),&(aFontSpec.iTypeface.iName),aSizeInPixels );
       
  1416         RDebug::Print( buf );
       
  1417         }
       
  1418     }
       
  1419 #endif
       
  1420 
       
  1421 // ============================ MEMBER FUNCTIONS ===============================
       
  1422 
       
  1423 
       
  1424 EXPORT_C CFbsFont* AknFontProvider::CreateFontFromTypefaceAndMetrics (
       
  1425     CBitmapDevice& aDevice,
       
  1426     const TTypeface& aTypeface, 
       
  1427     const TAknFontSpecification& aMetrics,
       
  1428     TAknFontProviderSuppliedMetrics& aInfo,
       
  1429     TInt& aFontProviderIndex )
       
  1430     {
       
  1431     // Set flags for suppressing size downgrade, and suppressing fallbacks 
       
  1432     TBool needsExactMatch;
       
  1433     TBool reduceSize;
       
  1434     TInt sizeInPixels;
       
  1435     SetLocalFlagsAndMetrics( aMetrics, aDevice, needsExactMatch, reduceSize, sizeInPixels );
       
  1436 
       
  1437     // Records whether the aliasing used was a generic one (e.g. "SansSerif" rather than "Arial")
       
  1438     // When generic mappings occur, they are counted as exact.
       
  1439     TBool aliasIsGeneric(ETrue); // Initialized to true in case there is no alias at all. 
       
  1440         
       
  1441     // This flags records if a fallback has taken place
       
  1442     TBool fellback(EFalse);
       
  1443     
       
  1444     // Obtain the required languages bit-pattern
       
  1445     TUint requiredLanguages = FontProviderRequiredLangs();
       
  1446 
       
  1447     TInt foundIndex(KErrNotFound);
       
  1448 
       
  1449     CFbsFont* font = 0;
       
  1450     TFontSpec fontSpec;
       
  1451 
       
  1452     font = TryToGetFontFromTypeface( 
       
  1453         &aDevice, aTypeface, aMetrics, sizeInPixels, requiredLanguages, fontSpec );
       
  1454     
       
  1455     if ( !font )
       
  1456         {
       
  1457         font = TryToGetFontFromAlias( 
       
  1458             &aDevice, aTypeface, aMetrics, sizeInPixels, 
       
  1459             requiredLanguages, needsExactMatch, reduceSize, 
       
  1460             fontSpec, foundIndex, aliasIsGeneric, fellback );
       
  1461         }
       
  1462 
       
  1463     // Handle presence/absence of font, ensuring return values are all filled in ( or not )
       
  1464 
       
  1465     if ( !font )
       
  1466         {
       
  1467         aFontProviderIndex = KErrNotFound;
       
  1468         }
       
  1469     /*
       
  1470     MatchIsExact tests if the Symbian API has come up with the requested font. aliasIsGeneric means 
       
  1471     that there was no aliasing, or that the aliasing was from generic keyword (e.g. "Serif")
       
  1472     */
       
  1473     else if ( needsExactMatch && ( fellback || !aliasIsGeneric || !MatchIsExact(fontSpec, font) ) )
       
  1474         {
       
  1475         aDevice.ReleaseFont(font);
       
  1476         aFontProviderIndex = KErrNotFound;
       
  1477         font = 0;
       
  1478         }
       
  1479     else
       
  1480         {
       
  1481         // Set call-back index for further (character specific) info
       
  1482         aFontProviderIndex = foundIndex; // Should be KErrNotFound for not-found typeface name
       
  1483         // Fill in other Font metrics
       
  1484         if ( foundIndex != KErrNotFound)
       
  1485             SetFontProviderSuppliedMetrics( font, &(productFontTable[foundIndex]), aInfo );
       
  1486         else // Fill in the information from the font's own information
       
  1487             SetFontProviderSuppliedMetrics( font, NULL, aInfo );
       
  1488         }
       
  1489 
       
  1490 #ifdef _DEBUG
       
  1491     OutputDebugInfo( font, aTypeface, aMetrics, sizeInPixels, fontSpec, aInfo );
       
  1492 #endif
       
  1493 
       
  1494     // error condition is when font is null and we do not need an exact match:
       
  1495     __ASSERT_ALWAYS( ( font || needsExactMatch ) , Panic( EAknFontPanicFailedToReturnFont ) );
       
  1496     return font; 
       
  1497     }   
       
  1498 
       
  1499 EXPORT_C CFbsFont* AknFontProvider::CreateFontFromMetrics (
       
  1500     CBitmapDevice& aDevice,
       
  1501     TInt aFontId, 
       
  1502     const TAknFontSpecification& aMetrics,
       
  1503     TAknFontProviderSuppliedMetrics& aInfo,
       
  1504     TInt& aFontProviderIndex )
       
  1505     {
       
  1506     TFontSpec fontSpec;
       
  1507     TInt foundIndex(KErrNotFound);
       
  1508     TBool needsExactMatch(EFalse);
       
  1509     TBool fallbackNeeded(EFalse);
       
  1510     DoGetFontSpecFromMetrics(aDevice, aFontId, aMetrics, fontSpec, foundIndex, needsExactMatch, fallbackNeeded);
       
  1511 
       
  1512     CFbsFont* font;
       
  1513     User::LeaveIfError(aDevice.GetNearestFontInPixels((CFont*&)font,fontSpec));
       
  1514 
       
  1515     // Fill in other Font metrics
       
  1516     SetFontProviderSuppliedMetrics( font, &(productFontTable[foundIndex]), aInfo );
       
  1517 
       
  1518 #ifdef _DEBUG
       
  1519     TBuf<256> buf;
       
  1520     TInt ascent = font->AscentInPixels();
       
  1521     TInt descent = font->DescentInPixels();
       
  1522     TInt range = aInfo.ExcessAscent() + aInfo.ExcessDescent() + ascent + descent;
       
  1523     TFontSpec realFontSpec = font->FontSpecInTwips();
       
  1524     buf.Format( _L("FontProvider: Category=%d, TextPane Height=%d; mapped request=%d; asked typeface=%S; given typeface=%S, actual range=%d(a,d,exa,exd=%d %d %d %d)" ), 
       
  1525         aMetrics.FontCategory(), aMetrics.TextPaneHeight(), fontSpec.iHeight, &(fontSpec.iTypeface.iName), &(realFontSpec.iTypeface.iName), range, 
       
  1526         ascent, descent, aInfo.ExcessAscent(),aInfo.ExcessDescent() );
       
  1527     RDebug::Print( buf );
       
  1528  
       
  1529     // additional debug print so see fonts available in system:   
       
  1530     /*
       
  1531     if (1)
       
  1532     {
       
  1533         buf.Format( _L("FontProvider: Availabe font families are:"));
       
  1534         RDebug::Print( buf );
       
  1535 
       
  1536         CDesCArray* array = new(ELeave) CDesCArrayFlat( 6 );
       
  1537         CleanupStack::PushL( array );
       
  1538 
       
  1539         FontUtils::GetAvailableFontsL(aDevice, *array, EGulNoSymbolFonts);
       
  1540         for ( TInt i = 0; i < array->Count(); i++ )
       
  1541             {       
       
  1542             TPtrC fontName((*array)[i]);
       
  1543             RDebug::Print( fontName );
       
  1544             }
       
  1545         CleanupStack::PopAndDestroy( array );
       
  1546     }
       
  1547     */
       
  1548 #endif
       
  1549 
       
  1550     // This flag is ETrue iff we find that category requested is matched exactly or was effectively not requested
       
  1551     // at all (EAknFontCategoryUndefined)
       
  1552     TBool categoryMatchIsExact =  
       
  1553         ( aMetrics.FontCategory() == productFontTable[foundIndex].iCategory )
       
  1554         || 
       
  1555         ( aMetrics.FontCategory() == EAknFontCategoryUndefined );
       
  1556         
       
  1557     /*
       
  1558     MatchIsExact tests if the Symbian API has come up with the requested font. aliasIsGeneric means 
       
  1559     that there was no aliasing, or that the aliasing was from generic keyword (e.g. "Serif")
       
  1560     */
       
  1561     if ( needsExactMatch && (fallbackNeeded || !categoryMatchIsExact || !MatchIsExact(fontSpec, font) ) )
       
  1562         {
       
  1563         aDevice.ReleaseFont(font);
       
  1564         aFontProviderIndex = KErrNotFound;
       
  1565         return(NULL);
       
  1566         }
       
  1567     else
       
  1568         {
       
  1569         // Set call-back index for further (character specific) info
       
  1570         aFontProviderIndex = foundIndex;
       
  1571         return(font);       
       
  1572         }
       
  1573     }
       
  1574 
       
  1575 EXPORT_C TBool AknFontProvider::HasBaselineCorrection( TInt aUsedIndex ) 
       
  1576     {
       
  1577     TBool retVal(EFalse);
       
  1578     if ( aUsedIndex != KErrNotFound)
       
  1579         {
       
  1580         
       
  1581 #ifdef _DEBUG
       
  1582         TInt numberOfRows = sizeof( productFontTable )/ sizeof( SAknProductFontTableLine );
       
  1583         __ASSERT_DEBUG( aUsedIndex < numberOfRows , Panic( EAknFontPanicIndexOutOfRange ) );
       
  1584 #endif
       
  1585 
       
  1586         SAknProductFontTableLine line = productFontTable[aUsedIndex];
       
  1587 
       
  1588         TCdlArray<SBaselineDelta> const* baselineArray = line.iBaselineData;
       
  1589 
       
  1590         retVal = ( baselineArray != NULL );
       
  1591         }
       
  1592     return retVal;
       
  1593     }
       
  1594 
       
  1595 EXPORT_C TInt AknFontProvider::BaselineDeltaForCharacter( TInt aUsedIndex, 
       
  1596                                                      TChar aCharacter, 
       
  1597                                                      TInt& aBaselineLift, 
       
  1598                                                      TInt& aDenominatorIfFractional )
       
  1599     {
       
  1600     TInt retVal( KErrNone );
       
  1601     // Force "NULL" behaviour
       
  1602     aBaselineLift = 0;
       
  1603     aDenominatorIfFractional = KAknFontProviderBaselineCorrectionIsAbsolute;
       
  1604     if ( aUsedIndex == KErrNotFound)
       
  1605         return retVal;
       
  1606     
       
  1607 #ifdef _DEBUG
       
  1608     TInt numberOfRows = sizeof( productFontTable )/ sizeof( SAknProductFontTableLine );
       
  1609     __ASSERT_DEBUG( aUsedIndex < numberOfRows , Panic( EAknFontPanicIndexOutOfRange ));
       
  1610 #endif
       
  1611 
       
  1612     SAknProductFontTableLine line = productFontTable[aUsedIndex];
       
  1613 
       
  1614     TCdlArray<SBaselineDelta> const* baselineArrayPtr = line.iBaselineData;
       
  1615 
       
  1616     if ( baselineArrayPtr )
       
  1617         {
       
  1618         TInt numberOfRanges = baselineArrayPtr->Count();
       
  1619         // first row that the character is in:
       
  1620         for ( TInt characterRangeIndex  = 0; characterRangeIndex < numberOfRanges; characterRangeIndex++)
       
  1621             {
       
  1622             const SBaselineDelta& baselineLine = baselineArrayPtr->At(characterRangeIndex);
       
  1623             if ( aCharacter >= baselineLine.iFirstCharacter  )
       
  1624                 {
       
  1625                 TInt nextIndex = characterRangeIndex + 1;
       
  1626                 TChar nextIndexCharacter = KMaxTInt; // Use if at last entry in range
       
  1627                 if ( nextIndex < numberOfRanges )
       
  1628                     {
       
  1629                     nextIndexCharacter  = baselineArrayPtr->At(nextIndex).iFirstCharacter;
       
  1630                     }
       
  1631                 if ( aCharacter < nextIndexCharacter )
       
  1632                     {
       
  1633                     aBaselineLift = baselineLine.iRelativeBaselineLift;
       
  1634                     aDenominatorIfFractional = baselineLine.iDenominator;
       
  1635                     break;
       
  1636                     }
       
  1637                 }
       
  1638             }
       
  1639         }
       
  1640                
       
  1641     return retVal;
       
  1642     }
       
  1643 
       
  1644 LOCAL_C void FindCharacterRangeForCharacter( 
       
  1645     const TChar& chNow, 
       
  1646     TCdlArray<SBaselineDelta> const* aBaselineArrayPtr, 
       
  1647     TChar& aMinCharInRange, 
       
  1648     TChar& aMaxCharInRangePlusOne, 
       
  1649     SBaselineDelta& aBaseline )
       
  1650     {
       
  1651     TInt numberOfRanges = aBaselineArrayPtr->Count();
       
  1652     __ASSERT_ALWAYS( numberOfRanges > 0, 
       
  1653         Panic( EAknFontPanicBadFontProviderDataStructure ) );
       
  1654 
       
  1655     TInt characterRangeIndex = numberOfRanges - 1; // Loop from the end
       
  1656     aMinCharInRange = KMaxTInt; // For initializing the monotonic check
       
  1657     while ( characterRangeIndex >= 0 )
       
  1658         {
       
  1659         aMaxCharInRangePlusOne = aMinCharInRange;
       
  1660         aMinCharInRange  = aBaselineArrayPtr->At(characterRangeIndex).iFirstCharacter;
       
  1661 
       
  1662         __ASSERT_DEBUG( aMinCharInRange < aMaxCharInRangePlusOne, Panic( EAknFontPanicBadFontProviderDataStructure ));
       
  1663                   
       
  1664         if ( chNow >= aMinCharInRange )
       
  1665             break;
       
  1666 
       
  1667         characterRangeIndex--;
       
  1668         }
       
  1669 
       
  1670     // Did we go negative on that last pass through (never hit the break)?
       
  1671     __ASSERT_DEBUG( characterRangeIndex >= 0, Panic( EAknFontPanicBadFontProviderDataStructure ));
       
  1672 
       
  1673     // This is the baseline to use
       
  1674     aBaseline = aBaselineArrayPtr->At(characterRangeIndex);
       
  1675     }
       
  1676 
       
  1677 EXPORT_C TInt AknFontProvider::MinimumBaselineDeltaForDescriptor( TInt aUsedIndex, 
       
  1678                                                      const TDesC& aText, 
       
  1679                                                      TInt& aMinBaselineLift, 
       
  1680                                                      TInt& aDenominatorIfFractional,
       
  1681                                                      TBool aQuitWhenDifferent,
       
  1682                                                      TInt& aNumInitialCharsTheSame)
       
  1683     {
       
  1684     TInt retVal(KErrNone);
       
  1685     // Force "NULL" behaviour. e.g. for zero length descriptors, or no printing characters
       
  1686     aMinBaselineLift = 0;
       
  1687     aDenominatorIfFractional = KAknFontProviderBaselineCorrectionIsAbsolute;
       
  1688     aNumInitialCharsTheSame = 0; 
       
  1689     
       
  1690     // KErrNotFound is a legal parameter value
       
  1691     if ( aUsedIndex == KErrNotFound )
       
  1692         return retVal;
       
  1693 
       
  1694 #ifdef _DEBUG
       
  1695     TInt numberOfRows = sizeof( productFontTable )/ sizeof( SAknProductFontTableLine );
       
  1696     __ASSERT_DEBUG( aUsedIndex < numberOfRows , Panic( EAknFontPanicIndexOutOfRange ));
       
  1697 #endif
       
  1698 
       
  1699     SAknProductFontTableLine line = productFontTable[aUsedIndex];
       
  1700 
       
  1701     TCdlArray<SBaselineDelta> const* baselineArrayPtr = line.iBaselineData;
       
  1702 
       
  1703     if ( !baselineArrayPtr )
       
  1704         return KErrNotFound;
       
  1705 
       
  1706     TInt numberOfRanges = baselineArrayPtr->Count();
       
  1707     __ASSERT_ALWAYS( numberOfRanges > 0, 
       
  1708         Panic( EAknFontPanicBadFontProviderDataStructure ) );
       
  1709 
       
  1710      // iFirstCharacter of first line must be 0
       
  1711     __ASSERT_ALWAYS( baselineArrayPtr->At(0).iFirstCharacter == 0, 
       
  1712         Panic( EAknFontPanicBadFontProviderDataStructure ) );
       
  1713 
       
  1714     TChar minCharInRange(KMaxTInt);
       
  1715     TChar maxCharInRangePlusOne(KMaxTInt);
       
  1716     SBaselineDelta baselineLine;
       
  1717     TInt thisBaselineLift(0);
       
  1718     TInt thisDenominator(KAknFontProviderBaselineCorrectionIsAbsolute);
       
  1719     TBool foundFirstDiffAlready(EFalse);
       
  1720     TInt processedChars(0);
       
  1721 
       
  1722     TInt length = aText.Length();
       
  1723     for ( TInt cIndex = 0; cIndex < length ; cIndex++ )
       
  1724         {
       
  1725         TChar chNow = aText[cIndex];
       
  1726 
       
  1727         if ( chNow.IsPrint() )
       
  1728             {
       
  1729             // Check if no longer in current range. Fails first time through for sensible chNow.
       
  1730             if (chNow < minCharInRange || chNow >= maxCharInRangePlusOne )
       
  1731                 {
       
  1732                 // Search again for correct range
       
  1733                 FindCharacterRangeForCharacter( 
       
  1734                     chNow, baselineArrayPtr, minCharInRange, maxCharInRangePlusOne, baselineLine);
       
  1735 
       
  1736                 // Just because we found a different range, does not mean the values are different. Have to check
       
  1737                 // later using stored and these new values.
       
  1738                 thisBaselineLift = baselineLine.iRelativeBaselineLift;
       
  1739                 thisDenominator = baselineLine.iDenominator;
       
  1740                 }
       
  1741 
       
  1742             processedChars++;
       
  1743 
       
  1744             // Should be in range now. Check if first printable character and capture metrics
       
  1745             if ( processedChars == 1 )
       
  1746                 {
       
  1747                 aMinBaselineLift = thisBaselineLift;
       
  1748                 // Denominator must be uniform, so we only need to capture it once
       
  1749                 if (thisDenominator != KAknFontProviderBaselineCorrectionIsAbsolute )
       
  1750                     aDenominatorIfFractional = thisDenominator;
       
  1751 
       
  1752                 aNumInitialCharsTheSame = cIndex+1; // has to take accound of skipped characters
       
  1753                 }
       
  1754             else
       
  1755                 {
       
  1756                 if ( thisBaselineLift != aMinBaselineLift )
       
  1757                     {
       
  1758                     if ( aQuitWhenDifferent )
       
  1759                         {
       
  1760                         break; // from for big loop over the descriptor
       
  1761                         }
       
  1762                     else
       
  1763                         {
       
  1764                         foundFirstDiffAlready = ETrue;
       
  1765                         aMinBaselineLift = Min( aMinBaselineLift, thisBaselineLift ); 
       
  1766                         }
       
  1767                     }
       
  1768                 else
       
  1769                     {
       
  1770                     if ( !foundFirstDiffAlready )
       
  1771                         aNumInitialCharsTheSame = cIndex+1; // has to take accound of skipped characters
       
  1772                     }
       
  1773                 }
       
  1774             }
       
  1775         }
       
  1776     return retVal;
       
  1777     }
       
  1778     
       
  1779 
       
  1780 EXPORT_C TInt AknFontProvider::FontProviderIndexFromFontSpec( const TFontSpec& aFontSpec ) 
       
  1781     {
       
  1782     // This implementation merely matches typeface.
       
  1783     TInt retval(KErrNotFound); // an invalid index
       
  1784     TInt numberOfRows = sizeof( productFontTable )/ sizeof( SAknProductFontTableLine );
       
  1785     for (TInt index = 0; index < numberOfRows; index++)
       
  1786         {
       
  1787         const SAknProductFontTableLine& line = productFontTable[index];
       
  1788         if ( line.iTypefaceName->Match( aFontSpec.iTypeface.iName ) == 0 )
       
  1789             {
       
  1790             retval = index;
       
  1791             break;
       
  1792             }
       
  1793         }
       
  1794 
       
  1795     return retval;
       
  1796     }
       
  1797 
       
  1798 EXPORT_C void AknFontProvider::InitializeSystemL ( const CEikonEnv& aEnv )
       
  1799     {
       
  1800     //chinese adaptation
       
  1801     TBool fChLinkedFonts = FeatureManager::FeatureSupported(KFeatureIdFfLinkedFontsChinese);
       
  1802     TBool fChinese = FeatureManager::FeatureSupported(KFeatureIdChinese);
       
  1803     if(fChinese && fChLinkedFonts)
       
  1804       {
       
  1805       //attempt to create linked font only once
       
  1806       if(!LinkTypefacesInstalled())
       
  1807 	    {
       
  1808 	     //TRAP call necessary
       
  1809 	     //not need to handle return value, hanled by LinkTypefacesInstalled()
       
  1810 	     TRAPD(errRet,IntializeLinkedFontL());
       
  1811       	}    	  
       
  1812       }
       
  1813     //end       
       
  1814     // This determines which languages are required
       
  1815     TUint langs = FontProviderRequiredLangs();
       
  1816     
       
  1817     // Set the system alias
       
  1818     CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(aEnv.ScreenDevice());
       
  1819     CleanupStack::PushL( store );
       
  1820     
       
  1821     TTypeface aliasedTypeface;
       
  1822     
       
  1823     // Search through aliases until you find match
       
  1824     TInt numberOfRows = sizeof( aliasTable )/ sizeof( SAknAliasTableLine );
       
  1825     for (TInt index = 0; index < numberOfRows; index++)
       
  1826         {
       
  1827         SAknAliasTableLine line = aliasTable[index];
       
  1828         
       
  1829         // No null descriptors
       
  1830         if ( (line.iAlias)->Length() != 0 ) 
       
  1831             {
       
  1832             // Only take aliases that are language-variated
       
  1833             if ( line.iLanguagesAndTypefaceTable )
       
  1834                 {
       
  1835                 if ( SetLanguageDependentDeAliasedTypeface( line.iLanguagesAndTypefaceTable, langs, aliasedTypeface ) )
       
  1836                     {
       
  1837                     store->SetFontNameAliasL( *(line.iAlias), aliasedTypeface.iName );
       
  1838                     // Set the default typeface name. It is the one with the alias "System One":
       
  1839                     if ( *(line.iAlias)==KSystemOne )
       
  1840                         {
       
  1841                         store->SetSystemDefaultTypefaceNameL(aliasedTypeface.iName);
       
  1842                         }
       
  1843                     }
       
  1844                 }
       
  1845             }
       
  1846  
       
  1847         }
       
  1848         
       
  1849     CleanupStack::PopAndDestroy( store );   
       
  1850     
       
  1851     return;
       
  1852     }
       
  1853 
       
  1854 
       
  1855 EXPORT_C TInt AknFontProvider::GetFontSpecFromMetrics(
       
  1856     CBitmapDevice& aDevice,
       
  1857     TInt aFontId, 
       
  1858     const TAknFontSpecification& aMetrics,
       
  1859     TFontSpec& aFontSpec,
       
  1860     TInt& aFontProviderIndex)
       
  1861     {
       
  1862     TBool needsExactMatch(EFalse);
       
  1863     TBool fallbackNeeded(EFalse);
       
  1864     return DoGetFontSpecFromMetrics(aDevice, aFontId, aMetrics, aFontSpec, aFontProviderIndex, needsExactMatch, fallbackNeeded);    
       
  1865     }
       
  1866     
       
  1867 TInt AknFontProvider::DoGetFontSpecFromMetrics(
       
  1868     CBitmapDevice& aDevice,
       
  1869     TInt /*aFontId*/, 
       
  1870     const TAknFontSpecification& aMetrics,
       
  1871     TFontSpec& aFontSpec,
       
  1872     TInt& aFontProviderIndex,
       
  1873     TBool& aNeedsExactMatch,
       
  1874     TBool& aFallbackNeeded)
       
  1875     {
       
  1876     // Set flags for suppressing size downgrade, and suppressing fallbacks 
       
  1877     TBool reduceSize; 
       
  1878     TInt sizeInPixels;
       
  1879     SetLocalFlagsAndMetrics( aMetrics, aDevice, aNeedsExactMatch, reduceSize, sizeInPixels );
       
  1880        
       
  1881     // Set the required languages bit pattern
       
  1882     TUint requiredLanguages = FontProviderRequiredLangs();
       
  1883 
       
  1884     TInt numberOfRows = sizeof( productFontTable )/ sizeof( SAknProductFontTableLine );
       
  1885     for (TInt index = 0; index < numberOfRows; index++)
       
  1886         {
       
  1887         SAknProductFontTableLine line = productFontTable[index];
       
  1888         if ( line.iCategory == aMetrics.FontCategory() || line.iCategory == EAny )
       
  1889             {
       
  1890             if (    ( line.iMinSize <= sizeInPixels || line.iMinSize == EAny )
       
  1891                 &&  ( sizeInPixels <= line.iMaxSize || line.iMaxSize == EAny) )
       
  1892                 {
       
  1893                 if ( COMPARE_BOOLS(productFontTable[index].iBold, ( aMetrics.Weight() == EStrokeWeightBold ) ) // it matches...
       
  1894                     || (productFontTable[index].iBold == EAny) ) // ... or use what was passed in
       
  1895                     {
       
  1896                     if ( COMPARE_BOOLS(productFontTable[index].iItalic, ( aMetrics.Posture() == EPostureItalic ) ) // it matches...
       
  1897                         || productFontTable[index].iItalic == EAny ) // ... or use what was passed in
       
  1898                         {
       
  1899                         if ( ( ( requiredLanguages & line.iSupportedLanguagesPattern ) == requiredLanguages )
       
  1900                               || line.iSupportedLanguagesPattern == EAnyLangs )
       
  1901                             {
       
  1902                             aFontProviderIndex = index;
       
  1903                             break;
       
  1904                             }
       
  1905                         }
       
  1906                     }
       
  1907                 }
       
  1908             }
       
  1909         }
       
  1910 
       
  1911     FallBackIfNeeded(aFontProviderIndex, aFallbackNeeded);
       
  1912 
       
  1913     // copy the line's information into the FontSpec
       
  1914     SetUpFontSpecFromTableLine( aFontProviderIndex, aMetrics, sizeInPixels, reduceSize, aFontSpec );
       
  1915 
       
  1916     // Specific feature for QVGA primary to avoid re-localization 
       
  1917     // These values would have to be maintained (or removed) depending on changes to layout spec
       
  1918    TRect rect = CEikonEnv::Static()->ScreenDevice()->SizeInPixels();  
       
  1919 
       
  1920    // Make sure layout is not asking any big big big fonts.
       
  1921     __ASSERT_DEBUG(rect.Height() > aFontSpec.iHeight,Panic(EAknFontPanicFontTooBig));
       
  1922 
       
  1923     if (rect.Height() < aFontSpec.iHeight)
       
  1924         {
       
  1925         aFontSpec.iHeight = rect.Height();
       
  1926         }
       
  1927         
       
  1928     return KErrNone;
       
  1929     }
       
  1930 
       
  1931     
       
  1932 //chinese adaptation
       
  1933 //1020509C UID of fontprovider
       
  1934 //cannot use PrivatePath() api as it will return parent process private path
       
  1935 _LIT(KFileName,"z:\\Private\\1020509C\\link.ini" );
       
  1936 void GetGroupCanonicalDetails(const TDesC& aToken,
       
  1937         SLinkedFontDetails*& aDetails)
       
  1938     {
       
  1939     _LIT(KGroup, "GROUP");
       
  1940     _LIT(KCanonical, "CANONICAL");
       
  1941     _LIT(KColon, ":");
       
  1942     _LIT(KLinkFacename, "FN");
       
  1943     _LIT(KBold, "BOLD");
       
  1944     _LIT(KRegular, "REGULAR");
       
  1945     TBuf<256> temp;
       
  1946     TInt start = 0;
       
  1947     TInt end = aToken.Find(KColon);
       
  1948 
       
  1949     do
       
  1950         {
       
  1951         temp.Copy(aToken.Mid(start, end));
       
  1952         //contains group entry
       
  1953         if (KErrNotFound != temp.Find(KGroup))
       
  1954             {
       
  1955             TPtrC ptrNum = temp.Mid(KGroup().Length());
       
  1956             TLex aNumLex(ptrNum);
       
  1957             aNumLex.Val(aDetails->iGroup);
       
  1958             }
       
  1959         //contains whether canonical
       
  1960         else if (KErrNotFound != temp.Find(KCanonical))
       
  1961             {
       
  1962             //					aCanonical = ETrue;		
       
  1963             TPtrC ptrNum = temp.Mid(KCanonical().Length());
       
  1964             TLex aNumLex(ptrNum);
       
  1965             aNumLex.Val(aDetails->iCanonical);
       
  1966             }
       
  1967         //contains link face name
       
  1968         else if (KErrNotFound != temp.Find(KLinkFacename))
       
  1969             {
       
  1970             aDetails->iLinkFontName.Copy(temp.Mid(KLinkFacename().Length()));
       
  1971             }
       
  1972         else if (KErrNotFound != temp.Find(KBold))
       
  1973             {
       
  1974             aDetails->iFontCategory = 2;
       
  1975             }
       
  1976         else if (KErrNotFound != temp.Find(KRegular))
       
  1977             {
       
  1978             aDetails->iFontCategory = 1;
       
  1979             }
       
  1980         //should be font name
       
  1981         else
       
  1982             {
       
  1983             aDetails->iFontName.Copy(temp);
       
  1984             }
       
  1985 
       
  1986         start += end + 1;
       
  1987         end = (aToken.Mid(start)).Find(KColon);
       
  1988 
       
  1989         }
       
  1990     while (KErrNotFound != end);
       
  1991     }
       
  1992 
       
  1993 TBool ChineseLinkedFontPresent(const TDesC& newFaceName)
       
  1994     {
       
  1995 
       
  1996     TBool FontPresent = EFalse;
       
  1997     TTypefaceSupport *typeface = NULL;
       
  1998     TInt fontCount = CEikonEnv::Static()->ScreenDevice()->NumTypefaces();
       
  1999 
       
  2000     for (TInt i = 0; (i < fontCount) && (FontPresent == EFalse); i++)
       
  2001         {
       
  2002         typeface = new TTypefaceSupport;
       
  2003         if (typeface != NULL)
       
  2004             {
       
  2005             CEikonEnv::Static()->ScreenDevice()->TypefaceSupport(*typeface, i);
       
  2006             if (!typeface->iTypeface.iName.Compare(newFaceName))
       
  2007                 { //Found linked font 
       
  2008                 FontPresent = ETrue;
       
  2009                 }
       
  2010             }
       
  2011         delete typeface;
       
  2012         typeface = NULL;
       
  2013         }
       
  2014 
       
  2015     return FontPresent;
       
  2016     }
       
  2017 
       
  2018 TInt CreateLinkFontsL(RPointerArray<SLinkedFontDetails>& fontfiles)
       
  2019     {
       
  2020     //	CFbsScreenDevice* dev = CFbsScreenDevice::NewL(0, EColor16MU);
       
  2021     //	CleanupStack::PushL(dev);
       
  2022     CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(NULL);
       
  2023     CleanupStack::PushL(store);
       
  2024     TInt ret;
       
  2025 
       
  2026     CLinkedTypefaceSpecification *typefaceSpec = NULL;
       
  2027 
       
  2028     for (int i = 0; i < fontfiles.Count(); i++)
       
  2029         {
       
  2030 
       
  2031         SLinkedFontDetails* tok = fontfiles[i];
       
  2032         //TDesC& linkName = tok->iLinkFontName;
       
  2033         TBuf<24> linkName(tok->iLinkFontName);
       
  2034         if (!ChineseLinkedFontPresent(linkName))
       
  2035             {
       
  2036             typefaceSpec = CLinkedTypefaceSpecification::NewLC(linkName);
       
  2037             for (int j = i; j < fontfiles.Count(); j++)
       
  2038                 {
       
  2039                 SLinkedFontDetails* first = fontfiles[j];
       
  2040                 TInt& groupId = fontfiles[j]->iGroup;
       
  2041                 TBool& canonical = fontfiles[j]->iCanonical;
       
  2042                 //TDesC& linkTypeFace = fontfiles[i]->iLinkFontName;
       
  2043                 TBuf<24> linkTypeFace(fontfiles[j]->iLinkFontName);
       
  2044                 //TDesC& fontFaceName = fontfiles[i]->iFontName;
       
  2045                 TBuf<24> fontFaceName(fontfiles[j]->iFontName);
       
  2046                 if (KErrNotFound != linkTypeFace.Find(linkName))
       
  2047                     {
       
  2048                     CLinkedTypefaceGroup* checkGroup =
       
  2049                             typefaceSpec->GroupById(groupId);
       
  2050                     if (NULL == checkGroup)
       
  2051                         {
       
  2052                         CLinkedTypefaceGroup* group =
       
  2053                                 CLinkedTypefaceGroup::NewLC(groupId);
       
  2054                         typefaceSpec->AddLinkedTypefaceGroupL(*group);
       
  2055                         CleanupStack::Pop();
       
  2056                         if(2 == fontfiles[j]->iFontCategory)
       
  2057                             group->SetBoldnessPercentage(1);
       
  2058                         else // 0 or 1
       
  2059                             group->SetBoldnessPercentage(0); //by default
       
  2060                         }
       
  2061 
       
  2062                     CLinkedTypefaceElementSpec *elementSpec =
       
  2063                             CLinkedTypefaceElementSpec::NewLC(fontFaceName,
       
  2064                                     groupId);
       
  2065                     if (canonical)
       
  2066                         elementSpec->SetCanonical(ETrue);
       
  2067                     typefaceSpec->AddTypefaceAtBackL(*elementSpec);
       
  2068                     CleanupStack::Pop(1, elementSpec);
       
  2069 
       
  2070                     }
       
  2071 
       
  2072                 }
       
  2073                 TRAP(ret, typefaceSpec->RegisterLinkedTypefaceL(*store));
       
  2074             CleanupStack::PopAndDestroy(1, typefaceSpec);
       
  2075             typefaceSpec = NULL;
       
  2076 
       
  2077             }
       
  2078 
       
  2079         }
       
  2080     CleanupStack::PopAndDestroy(1, store);
       
  2081 
       
  2082     return ret;
       
  2083     }
       
  2084 
       
  2085 void PopulateFontFileNames(TFileText& tfile,
       
  2086         RPointerArray<SLinkedFontDetails>& fontfiles, const TDesC& stop)
       
  2087     {
       
  2088     TBuf<256> filedatabuf;
       
  2089     while (tfile.Read(filedatabuf) != KErrEof)
       
  2090         {
       
  2091         if (KErrNotFound != filedatabuf.Match(stop))
       
  2092             {
       
  2093             break;
       
  2094             }
       
  2095         else
       
  2096             {
       
  2097             SLinkedFontDetails *details = new SLinkedFontDetails;
       
  2098             GetGroupCanonicalDetails(filedatabuf, details);
       
  2099             fontfiles.Append(details);
       
  2100             }
       
  2101         }
       
  2102 
       
  2103     }
       
  2104 
       
  2105 TInt IntializeLinkedFontL()
       
  2106     {
       
  2107     _LIT(KSCStart, "[SC_LINK_START]");
       
  2108     _LIT(KSCStop, "[SC_LINK_STOP]");
       
  2109     _LIT(KTCHKStart, "[TCHK_LINK_START]");
       
  2110     _LIT(KTCHKStop, "[TCHK_LINK_STOP]");
       
  2111     _LIT(KSCHRStart, "[SCHR_LINK_START]");
       
  2112     _LIT(KSCHRStop, "[SCHR_LINK_STOP]");
       
  2113     _LIT(KTCHKHRStart, "[TCHKHR_LINK_START]");
       
  2114     _LIT(KTCHKHRStop, "[TCHKHR_LINK_STOP]");
       
  2115 
       
  2116     TInt ret = KErrNone;
       
  2117     RPointerArray<SLinkedFontDetails> fontfiles;
       
  2118     RFs fs;
       
  2119     RFile rFile;
       
  2120     TFileText tfile;
       
  2121     User::LeaveIfError(fs.Connect());
       
  2122     ret = rFile.Open(fs, KFileName, EFileRead);
       
  2123     User::LeaveIfError(ret);
       
  2124     tfile.Set(rFile);
       
  2125     TBuf<256> filedatabuf;
       
  2126     TBuf<50> startTok;
       
  2127     TBuf<50> stopTok;
       
  2128 
       
  2129     TBool fChLinkedFonts = FeatureManager::FeatureSupported(
       
  2130             KFeatureIdFfLinkedFontsChinese);
       
  2131     TBool fTCHKFonts = FeatureManager::FeatureSupported(
       
  2132             KFeatureIdChineseTaiwanHkFonts);
       
  2133     TBool fSCFonts = FeatureManager::FeatureSupported(
       
  2134             KFeatureIdChinesePrcFonts);
       
  2135     TBool fHiResFonts = FeatureManager::FeatureSupported(
       
  2136             KFeatureIdChineseFontsHires);
       
  2137 
       
  2138     
       
  2139     if (fChLinkedFonts)
       
  2140         {
       
  2141 
       
  2142         if (fSCFonts && fHiResFonts)
       
  2143             {
       
  2144             startTok.Copy(KSCHRStart);
       
  2145             stopTok.Copy(KSCHRStop);
       
  2146             tfile.Seek(ESeekStart);
       
  2147             ret = DoPopulateAndCreateLinkFontsL(tfile, startTok, stopTok);
       
  2148             }
       
  2149         else if (fSCFonts)
       
  2150             {
       
  2151             startTok.Copy(KSCStart);
       
  2152             stopTok.Copy(KSCStop);
       
  2153             tfile.Seek(ESeekStart);
       
  2154             ret = DoPopulateAndCreateLinkFontsL(tfile, startTok, stopTok);
       
  2155             }
       
  2156         if (fTCHKFonts && fHiResFonts)
       
  2157             {
       
  2158             startTok.Copy(KTCHKHRStart);
       
  2159             stopTok.Copy(KTCHKHRStop);
       
  2160             tfile.Seek(ESeekStart);
       
  2161             ret = DoPopulateAndCreateLinkFontsL(tfile, startTok, stopTok);
       
  2162             }        
       
  2163         else if (fTCHKFonts)
       
  2164             {
       
  2165             startTok.Copy(KTCHKStart);
       
  2166             stopTok.Copy(KTCHKStop);
       
  2167             tfile.Seek(ESeekStart);
       
  2168             ret = DoPopulateAndCreateLinkFontsL(tfile, startTok, stopTok);
       
  2169             }
       
  2170         
       
  2171         }
       
  2172 
       
  2173     
       
  2174     rFile.Close();
       
  2175     fs.Close();
       
  2176     return ret;
       
  2177     }
       
  2178  
       
  2179 TInt DoPopulateAndCreateLinkFontsL(TFileText atfile,  TDesC& astartTok, TDesC& astopTok)
       
  2180     {
       
  2181     TInt ret = KErrNone;
       
  2182     TBuf<256> filedatabuf;
       
  2183     RPointerArray<SLinkedFontDetails> fontfiles;
       
  2184     while ( (atfile.Read(filedatabuf) != KErrEof) )
       
  2185         {
       
  2186         if (KErrNotFound != filedatabuf.Match(astartTok))
       
  2187             {
       
  2188             PopulateFontFileNames(atfile, fontfiles, astopTok);
       
  2189             ret = CreateLinkFontsL(fontfiles);
       
  2190             break;
       
  2191             }
       
  2192         }
       
  2193     fontfiles.Close();
       
  2194     return ret;
       
  2195     }
       
  2196 TBool LinkTypefacesInstalled()
       
  2197     {
       
  2198     CWsScreenDevice * screenDevice = CCoeEnv::Static()->ScreenDevice();
       
  2199     TInt noOfTypefaces = screenDevice->NumTypefaces();
       
  2200     TBool fTCHKFonts = FeatureManager::FeatureSupported(
       
  2201             KFeatureIdChineseTaiwanHkFonts);
       
  2202     TBool fSCFonts = FeatureManager::FeatureSupported(
       
  2203             KFeatureIdChinesePrcFonts);
       
  2204     TBool fHiResFonts = FeatureManager::FeatureSupported(
       
  2205             KFeatureIdChineseFontsHires);
       
  2206 
       
  2207     
       
  2208     TBool ret = EFalse;
       
  2209     TInt files = 0, ref = 0;
       
  2210     if(fSCFonts)
       
  2211         ref +=3;
       
  2212     if(fTCHKFonts)
       
  2213         ref +=3;
       
  2214     for (TInt i = 0; i < noOfTypefaces; i++)
       
  2215         {
       
  2216         TTypefaceSupport typefaceInfo;
       
  2217         screenDevice->TypefaceSupport(typefaceInfo, i);
       
  2218         if (fSCFonts && fHiResFonts)
       
  2219             {
       
  2220             if (typefaceInfo.iTypeface.iName.Compare(KS60SCHRSANSRLF)==0||
       
  2221                 typefaceInfo.iTypeface.iName.Compare(KS60SCHRSANSSBLF)==0||
       
  2222                 typefaceInfo.iTypeface.iName.Compare(KS60SCHRSANSTTLSMBLDLF)==0)
       
  2223                 {
       
  2224                 files++;
       
  2225                 }
       
  2226 
       
  2227             }
       
  2228         else if (fSCFonts)
       
  2229             {
       
  2230             if (typefaceInfo.iTypeface.iName.Compare(KS60SCSANSRLF)==0||
       
  2231                 typefaceInfo.iTypeface.iName.Compare(KS60SCSANSSBLF)==0||
       
  2232                 typefaceInfo.iTypeface.iName.Compare(KS60SCSANSTTLSMBLDLF)==0)
       
  2233                 {
       
  2234                 files++;
       
  2235                 }
       
  2236 
       
  2237             }
       
  2238            if (fTCHKFonts && fHiResFonts)
       
  2239             {
       
  2240             if (typefaceInfo.iTypeface.iName.Compare(KS60TCHKHRSANSRLF)==0||
       
  2241                 typefaceInfo.iTypeface.iName.Compare(KS60TCHKHRSANSSBLF)==0||
       
  2242                 typefaceInfo.iTypeface.iName.Compare(KS60TCHKHRSANSTTLSMBLDLF)==0)
       
  2243                 {
       
  2244                 files++;
       
  2245                 }
       
  2246 
       
  2247             }
       
  2248 
       
  2249            else if (fTCHKFonts)
       
  2250             {
       
  2251             if (typefaceInfo.iTypeface.iName.Compare(KS60TCHKSANSRLF)==0||
       
  2252                 typefaceInfo.iTypeface.iName.Compare(KS60TCHKSANSSBLF)==0||
       
  2253                 typefaceInfo.iTypeface.iName.Compare(KS60TCHKSANSTTLSMBLDLF)==0)
       
  2254                 {
       
  2255                 files++;
       
  2256                 }
       
  2257             }
       
  2258         }
       
  2259     if (ref == files)
       
  2260         ret = ETrue;
       
  2261     return ret;
       
  2262     }
       
  2263  
       
  2264 //  End of File