sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: // the only way to get at the local to file static function MatchFontSpecsInPixels sl@0: #include "FNTSTORE.CPP" sl@0: #include "T_MatchFonts.h" sl@0: sl@0: _LIT( KDjvMono, "DejaVu Sans Mono" ); sl@0: _LIT( KDjvSerif, "DejaVu Serif Condensed" ); sl@0: _LIT( KDjvSans, "DejaVu Sans Condensed" ); sl@0: sl@0: class CTMatchFonts : public CTGraphicsBase sl@0: { sl@0: public: sl@0: CTMatchFonts(CTestStep* aStep); sl@0: sl@0: protected: sl@0: //from CTGraphicsStep sl@0: virtual void RunTestCaseL(TInt aCurTestCase); sl@0: virtual void ConstructL(); sl@0: private: sl@0: TOpenFontSpec iIdealFontSpec1; sl@0: TOpenFontSpec iIdealFontSpec2; sl@0: TOpenFontSpec iIdealFontSpec3; sl@0: TOpenFontSpec iDjvMonoFontSpec; sl@0: TOpenFontSpec iDjvSerifFontSpec; sl@0: TOpenFontSpec iDjvSansFontSpec; sl@0: }; sl@0: sl@0: CTMatchFonts::CTMatchFonts(CTestStep* aStep) : sl@0: CTGraphicsBase(aStep) sl@0: { sl@0: sl@0: } sl@0: sl@0: void CTMatchFonts::ConstructL() sl@0: { sl@0: sl@0: iIdealFontSpec1.SetName( KNullDesC ); sl@0: iIdealFontSpec1.SetHeight( 10 ); sl@0: iIdealFontSpec1.SetItalic( EFalse ); sl@0: iIdealFontSpec1.SetSlantFactor( 0 ); sl@0: iIdealFontSpec1.SetBold( EFalse ); sl@0: iIdealFontSpec1.SetBitmapType( EMonochromeGlyphBitmap ); sl@0: iIdealFontSpec1.SetMonoWidth( ETrue ); sl@0: iIdealFontSpec1.SetSerif( ETrue ); sl@0: sl@0: iDjvMonoFontSpec.SetName( KDjvMono ); sl@0: iDjvMonoFontSpec.SetHeight( 10 ); sl@0: iDjvMonoFontSpec.SetItalic( EFalse ); sl@0: iDjvMonoFontSpec.SetSlantFactor( 0 ); sl@0: iDjvMonoFontSpec.SetBold( EFalse ); sl@0: iDjvMonoFontSpec.SetBitmapType( EMonochromeGlyphBitmap ); sl@0: iDjvMonoFontSpec.SetMonoWidth( ETrue ); sl@0: iDjvMonoFontSpec.SetSerif( ETrue ); sl@0: sl@0: iIdealFontSpec2.SetName( KNullDesC ); sl@0: iIdealFontSpec2.SetHeight( 10 ); sl@0: iIdealFontSpec2.SetItalic( EFalse ); sl@0: iIdealFontSpec2.SetSlantFactor( 0 ); sl@0: iIdealFontSpec2.SetBold( EFalse ); sl@0: iIdealFontSpec2.SetBitmapType( EMonochromeGlyphBitmap ); sl@0: iIdealFontSpec2.SetMonoWidth( EFalse ); sl@0: iIdealFontSpec2.SetSerif( ETrue ); sl@0: sl@0: iDjvSerifFontSpec.SetName( KDjvSerif ); sl@0: iDjvSerifFontSpec.SetHeight( 10 ); sl@0: iDjvSerifFontSpec.SetItalic( EFalse ); sl@0: iDjvSerifFontSpec.SetSlantFactor( 0 ); sl@0: iDjvSerifFontSpec.SetBold( EFalse ); sl@0: iDjvSerifFontSpec.SetBitmapType( EMonochromeGlyphBitmap ); sl@0: iDjvSerifFontSpec.SetMonoWidth( EFalse ); sl@0: iDjvSerifFontSpec.SetSerif( ETrue ); sl@0: sl@0: iIdealFontSpec3.SetName( KNullDesC ); sl@0: iIdealFontSpec3.SetHeight( 10 ); sl@0: iIdealFontSpec3.SetItalic( EFalse ); sl@0: iIdealFontSpec3.SetSlantFactor( 0 ); sl@0: iIdealFontSpec3.SetBold( EFalse ); sl@0: iIdealFontSpec3.SetBitmapType( EMonochromeGlyphBitmap ); sl@0: iIdealFontSpec3.SetMonoWidth( EFalse ); sl@0: iIdealFontSpec3.SetSerif( EFalse ); sl@0: sl@0: iDjvSansFontSpec.SetName( KDjvSans ); sl@0: iDjvSansFontSpec.SetHeight( 10 ); sl@0: iDjvSansFontSpec.SetItalic( EFalse ); sl@0: iDjvSansFontSpec.SetSlantFactor( 0 ); sl@0: iDjvSansFontSpec.SetBold( EFalse ); sl@0: iDjvSansFontSpec.SetBitmapType( EMonochromeGlyphBitmap ); sl@0: iDjvSansFontSpec.SetMonoWidth( EFalse ); sl@0: iDjvSansFontSpec.SetSerif( EFalse ); sl@0: sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FNTSTORE-0035 sl@0: sl@0: @SYMTestCaseDesc sl@0: Creates a reference font and compares it to different fonts sl@0: and sees which font matches the reference font the best. sl@0: sl@0: @SYMTestActions sl@0: 1. Reference font: monospaced serif sl@0: Compared fonts: DejaVu Sans Mono, DejaVu Serif Condensed, DejaVu Sans Condensed sl@0: 2. Reference font: proporional serif font sl@0: Compared fonts: DejaVu Sans Mono, DejaVu Serif Condensed, DejaVu Sans Condensed sl@0: 3. Reference font: proporional sans serif sl@0: Compared fonts: DejaVu Sans Mono, DejaVu Serif Condensed, DejaVu Sans Condensed sl@0: sl@0: @SYMTestExpectedResults sl@0: 1. Should choose DejaVu Sans Mono above DejaVu Serif Condensed above DejaVu Sans Condensed sl@0: 2. Should choose DejaVu Serif Condensed above DejaVu Sans Condensed above DejaVu Sans Mono sl@0: 3. Should choose DejaVu Sans Condensed above DejaVu Serif Condensed above DejaVu Sans Mono sl@0: */ sl@0: void CTMatchFonts::RunTestCaseL( TInt aCurTestCase ) sl@0: { sl@0: TInt weighting1; sl@0: TInt weighting2; sl@0: TInt weighting3; sl@0: ((CTMatchFontsStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: sl@0: switch ( aCurTestCase ) sl@0: { sl@0: case 1: sl@0: ((CTMatchFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0035")); sl@0: // Looking for a monospaced serif font (like DejaVu Sans Mono) sl@0: weighting1 = MatchFontSpecsInPixels( iDjvMonoFontSpec, iIdealFontSpec1 ); sl@0: weighting2 = MatchFontSpecsInPixels( iDjvSerifFontSpec, iIdealFontSpec1 ); sl@0: weighting3 = MatchFontSpecsInPixels( iDjvSansFontSpec, iIdealFontSpec1 ); sl@0: // Should choose DejaVu Sans Mono above DejaVu Serif Condensed above DejaVu Sans Condensed sl@0: TEST( ( weighting1 > weighting2 ) && ( weighting2 > weighting3 ) ); sl@0: break; sl@0: case 2: sl@0: ((CTMatchFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0035")); sl@0: // Looking for a proporional serif font (like DejaVu Serif Condensed) sl@0: weighting1 = MatchFontSpecsInPixels( iDjvMonoFontSpec, iIdealFontSpec2 ); sl@0: weighting2 = MatchFontSpecsInPixels( iDjvSerifFontSpec, iIdealFontSpec2 ); sl@0: weighting3 = MatchFontSpecsInPixels( iDjvSansFontSpec, iIdealFontSpec2 ); sl@0: // Should choose DejaVu Serif Condensed above DejaVu Sans Condensed above DejaVu Sans Mono sl@0: TEST( ( weighting2 > weighting3 ) && ( weighting3 > weighting1 ) ); sl@0: break; sl@0: case 3: sl@0: ((CTMatchFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0035")); sl@0: // Looking for a proporional sans serif font (like DejaVu Sans Condensed) sl@0: weighting1 = MatchFontSpecsInPixels( iDjvMonoFontSpec, iIdealFontSpec3 ); sl@0: weighting2 = MatchFontSpecsInPixels( iDjvSerifFontSpec, iIdealFontSpec3 ); sl@0: weighting3 = MatchFontSpecsInPixels( iDjvSansFontSpec, iIdealFontSpec3 ); sl@0: // Should choose DejaVu Sans Condensed above DejaVu Serif Condensed above DejaVu Sans Mono sl@0: TEST( ( weighting3 > weighting2 ) && ( weighting2 > weighting1 ) ); sl@0: break; sl@0: case 4: sl@0: ((CTMatchFontsStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTMatchFontsStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: } sl@0: ((CTMatchFontsStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: //-------------- sl@0: __CONSTRUCT_STEP__(MatchFonts)