sl@0: /* sl@0: * Copyright (c) 2007-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: * Tests FNTSTORE with respect to the Open Font system. sl@0: * Creates a dummy rasterizer and tests font file loading and unloading and sl@0: * font creation. This just exercises the way the Open Font system connects to the sl@0: * 'classic' bitmap-font-only font system. sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent Internal Symbian test code sl@0: */ sl@0: sl@0: #include "T_FSOPEN.H" sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #ifdef _DEBUG sl@0: _LIT(KFBSERVFontDir,"\\resource\\fonts\\"); sl@0: #endif// _DEBUG sl@0: sl@0: sl@0: _LIT(KFontDummy,"z:\\PlatTest\\Graphics\\TestData\\dummy_fonts\\dummy"); sl@0: _LIT(KFontDummy_b,"z:\\PlatTest\\Graphics\\TestData\\dummy_fonts\\dummy_b"); sl@0: _LIT(KFontDummy_i,"z:\\PlatTest\\Graphics\\TestData\\dummy_fonts\\dummy_i"); sl@0: _LIT(KFontDummy_bi,"z:\\PlatTest\\Graphics\\TestData\\dummy_fonts\\dummy_bi"); sl@0: sl@0: const TUint32 KDevanagariScriptCode = 0x64657661; sl@0: _LIT16(KTextToShape, "\x0915\x094D\x0937\x0924\x094D\x0930\x093F\x092F"); sl@0: sl@0: sl@0: sl@0: sl@0: CDummyShaperFactory* CDummyShaperFactory::NewL() sl@0: { sl@0: CDummyShaperFactory* r = new(ELeave) CDummyShaperFactory; sl@0: return r; sl@0: } sl@0: sl@0: CDummyShaperFactory::CDummyShaperFactory() sl@0: { sl@0: } sl@0: sl@0: CDummyShaperFactory::~CDummyShaperFactory() sl@0: { sl@0: sl@0: } sl@0: sl@0: sl@0: CShaper* CDummyShaperFactory::NewShaperL(CBitmapFont* aBitmapfont, TInt aScript, TInt aLanguage, RHeap* aHeap) sl@0: { sl@0: return CDummyShaper::NewL(aBitmapfont, aScript, aLanguage, aHeap); sl@0: } sl@0: sl@0: void* CShaperFactory::ExtendedInterface(TUid /*aInterfaceId*/) sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: sl@0: CShaper * CDummyShaper::NewL(CBitmapFont* aBitmapfont, TInt aScript, TInt aLanguage, RHeap* aHeap) sl@0: { sl@0: CDummyShaper* newShaper = new(ELeave)CDummyShaper(); sl@0: CleanupStack::PushL(newShaper); sl@0: TInt error = newShaper->ConstructL(aBitmapfont, aScript, aLanguage, aHeap); sl@0: sl@0: // if the layout engine fails to construct with this font return NULL sl@0: if (error == KErrNone ) sl@0: { sl@0: CleanupStack::Pop(); // newShaper sl@0: return newShaper; sl@0: } sl@0: else sl@0: { sl@0: CleanupStack::PopAndDestroy(); sl@0: return NULL; sl@0: } sl@0: } sl@0: sl@0: sl@0: /** sl@0: Construct an instance of CDummyShaper sl@0: @param aOpenFont The required font sl@0: @param aHeap The heap to be used for storage by the engine sl@0: @return KErrNone if successful or a system wide error code. sl@0: Note that KErrGeneral may be returned in certain out of memory situations. sl@0: @see CShaper sl@0: */ sl@0: TInt CDummyShaper::ConstructL(CBitmapFont* /*aBitmapfont*/, TInt /*aScript*/, TInt /*aLanguage*/, RHeap* /*aHeap*/ ) sl@0: { sl@0: return KErrNone; sl@0: } sl@0: sl@0: CDummyShaper::CDummyShaper() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: Frees all resources owned by ... sl@0: */ sl@0: CDummyShaper::~CDummyShaper() sl@0: { sl@0: } sl@0: sl@0: /** This is implementation of CShaper::ShapeText for the Icu layout Engine sl@0: The data is taken from TInput and pass to the shaper. sl@0: A memory buffer is allocated on aHeapForOutput starting with TShapeHeader is allocated. sl@0: The results of the shaping are copied into this buffer and passed back via aOutput. sl@0: @param aOutput On success a new structure containing the results allocated on aHeapForOutput. sl@0: @param aInput The input text and other parameters. sl@0: @param aHeapForOutput On success, aOutput should be allocated from this and nothing else. sl@0: On failure, nothing should be allocated from it. sl@0: @return Error value from one of the system-wide error codes on failure, KErrNone on success. sl@0: @see CShaper::ShapeText sl@0: */ sl@0: TInt CDummyShaper::ShapeText(TShapeHeader*& /*aOutput*/, const TInput& /*aInput*/, RHeap* /*aHeapForOutput*/) sl@0: { sl@0: // This shaper doesnt return any results sl@0: return KErrNotSupported; sl@0: } sl@0: sl@0: class CDummyFontFile: public COpenFontFile sl@0: { sl@0: public: sl@0: static CDummyFontFile* NewL(TInt aUid,const TDesC& aFileName); sl@0: TBool GetNearestFontHelperOld(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight, sl@0: TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const; sl@0: private: sl@0: CDummyFontFile(TInt aUid,const TDesC& aFileName); sl@0: void ConstructL(); sl@0: // From COpenFontFile sl@0: void GetNearestFontInPixelsL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList, sl@0: const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight, sl@0: COpenFont*& aFont,TOpenFontSpec& aActualFontSpec); sl@0: void GetNearestFontToDesignHeightInPixelsL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList, sl@0: const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight, sl@0: COpenFont*& aFont,TOpenFontSpec& aActualFontSpec); sl@0: void GetNearestFontToMaxHeightInPixelsL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList, sl@0: const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight, sl@0: COpenFont*& aFont,TOpenFontSpec& aActualFontSpec, TInt aMaxHeight); sl@0: virtual TBool HasUnicodeCharacterL(TInt aFaceIndex,TInt aCode) const; sl@0: }; sl@0: sl@0: class CDummyFont: public COpenFont sl@0: { sl@0: public: sl@0: static CDummyFont* NewL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,CDummyFontFile* aFontFile,TInt aSizeInPixels); sl@0: private: sl@0: CDummyFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,CDummyFontFile* aFontFile,TInt aSizeInPixels); sl@0: // From COpenFont sl@0: virtual void RasterizeL(TInt aCode,TOpenFontGlyphData* aGlyphData); sl@0: }; sl@0: sl@0: CTFsOpen::CTFsOpen(CTestStep* aStep) : sl@0: CTGraphicsBase(aStep) sl@0: { sl@0: INFO_PRINTF1(_L("FontStore and the Open Font System")); sl@0: } sl@0: sl@0: CTFsOpen::~CTFsOpen() sl@0: { sl@0: iFilesys.Close(); sl@0: delete iFontStore; sl@0: iHeap->__DbgMarkEnd(0); sl@0: iHeap->Close(); sl@0: __UHEAP_MARKEND; sl@0: User::Heap().Check(); sl@0: } sl@0: sl@0: void CTFsOpen::ConstructL() sl@0: { sl@0: __UHEAP_MARK; sl@0: iHeap = UserHeap::ChunkHeap(NULL,0x10000,0x10000); sl@0: if (iHeap == NULL) sl@0: User::Leave(KErrGeneral); sl@0: iHeap->__DbgMarkStart(); sl@0: iFontStore = CFontStore::NewL(iHeap); sl@0: sl@0: // Install the dummy rasterizer. sl@0: COpenFontRasterizer* r = CDummyRasterizer::NewL(); sl@0: CleanupStack::PushL(r); sl@0: iFontStore->InstallRasterizerL(r); sl@0: CleanupStack::Pop(); sl@0: sl@0: // Install the dummy shaper sl@0: CShaperFactory* shaperFactory = CDummyShaperFactory::NewL(); sl@0: CleanupStack::PushL(shaperFactory); sl@0: iFontStore->InstallShaperFactoryL(shaperFactory); sl@0: CleanupStack::Pop(); sl@0: } sl@0: sl@0: void CTFsOpen::RunTestCaseL(TInt aCurTestCase) sl@0: { sl@0: ((CTFsOpenStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: switch(aCurTestCase) sl@0: { sl@0: case 1: sl@0: ((CTFsOpenStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0031")); sl@0: AddAndRemoveFilesL(); sl@0: break; sl@0: case 2: sl@0: ((CTFsOpenStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0032")); sl@0: CreateAndReleaseFontsL(); sl@0: break; sl@0: case 3: sl@0: ((CTFsOpenStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0033")); sl@0: #ifdef _DEBUG sl@0: TestGetNearestFontHelperL(); sl@0: #endif //_DEBUG sl@0: break; sl@0: case 4: sl@0: ((CTFsOpenStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-FNTSTORE-UT-1498")); sl@0: CreateShaperL(); sl@0: break; sl@0: case 5: sl@0: ((CTFsOpenStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTFsOpenStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: } sl@0: ((CTFsOpenStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FNTSTORE-0031 sl@0: sl@0: @SYMTestCaseDesc sl@0: Tests adding and removing files from the font store. sl@0: sl@0: @SYMTestActions sl@0: 1. Finds or creates a font file object to support a font file. sl@0: If an appropriate font file object exists then no new open font file is created. sl@0: In this case the reference count of the font file object is incremented. sl@0: 2. Gets the number of typefaces held in the font store. sl@0: 3. Checks all fonts are in the same typeface family. sl@0: 4. Checks all fonts have different FontStore ids. sl@0: 5. Tries to add a font (which has been added once already) and checks it gets sl@0: the same id as when it was added. sl@0: 6. Releases four load fonts. sl@0: 7. Checks font that was loaded twice should still be loaded. sl@0: 8. Removes last reference a font and checks all fonts are unloaded correctly. sl@0: sl@0: @SYMTestExpectedResults sl@0: Test should pass sl@0: */ sl@0: void CTFsOpen::AddAndRemoveFilesL() sl@0: { sl@0: TEST(iFontStore->NumTypefaces() == 0); sl@0: sl@0: INFO_PRINTF1(_L("loading dummy Open Fonts\n")); sl@0: sl@0: TUid id1 = iFontStore->AddFileL(KFontDummy); sl@0: TUid id2 = iFontStore->AddFileL(KFontDummy_b); sl@0: TUid id3 = iFontStore->AddFileL(KFontDummy_i); sl@0: TUid id4 = iFontStore->AddFileL(KFontDummy_bi); sl@0: sl@0: // all fonts are in the same typeface family sl@0: INFO_PRINTF1(_L("increasing reference count for for an Open Font file\n")); sl@0: TEST(iFontStore->NumTypefaces() == 1); sl@0: sl@0: // ids should each be different sl@0: TEST(id1 != id2); sl@0: TEST(id1 != id3); sl@0: TEST(id1 != id4); sl@0: TEST(id2 != id3); sl@0: TEST(id2 != id4); sl@0: TEST(id3 != id4); sl@0: sl@0: // ask for one of the font files again sl@0: TUid id5 = iFontStore->AddFileL(KFontDummy_bi); sl@0: sl@0: // should get the same UID as the first time sl@0: TEST(id4 == id5); sl@0: sl@0: INFO_PRINTF1(_L("unloading dummy Open Fonts\n")); sl@0: iFontStore->RemoveFile(id1); sl@0: iFontStore->RemoveFile(id2); sl@0: iFontStore->RemoveFile(id3); sl@0: iFontStore->RemoveFile(id4); sl@0: sl@0: // font that was loaded twice should still be loaded sl@0: TEST(iFontStore->NumTypefaces() == 1); sl@0: sl@0: // remove last reference sl@0: iFontStore->RemoveFile(id5); sl@0: sl@0: // all fonts unloaded sl@0: TEST(iFontStore->NumTypefaces() == 0); sl@0: } sl@0: sl@0: void CTFsOpen::TestFont(const TFontSpec& aSpec) sl@0: { sl@0: iHeap->__DbgMarkStart(); sl@0: sl@0: CFont* font = NULL; sl@0: TInt error = iFontStore->GetNearestFontToDesignHeightInTwips(font,aSpec); sl@0: TEST(error == KErrNone); sl@0: TEST(font != NULL); sl@0: INFO_PRINTF2(_L("desired font spec: %S: "),&aSpec.iTypeface.iName); sl@0: if (aSpec.iFontStyle.StrokeWeight() == EStrokeWeightBold) sl@0: INFO_PRINTF1(_L("bold ")); sl@0: if (aSpec.iFontStyle.Posture() == EPostureItalic) sl@0: INFO_PRINTF1(_L("italic ")); sl@0: INFO_PRINTF2(_L("%dpt"),(aSpec.iHeight + 10) / 20); sl@0: INFO_PRINTF1(_L("\n")); sl@0: TFontSpec actual_spec = font->FontSpecInTwips(); sl@0: INFO_PRINTF2(_L("actual font spec: %S: "),&actual_spec.iTypeface.iName); sl@0: if (actual_spec.iFontStyle.StrokeWeight() == EStrokeWeightBold) sl@0: INFO_PRINTF1(_L("bold ")); sl@0: if (actual_spec.iFontStyle.Posture() == EPostureItalic) sl@0: INFO_PRINTF1(_L("italic ")); sl@0: INFO_PRINTF2(_L("%dpt"),(actual_spec.iHeight + 10) / 20); sl@0: INFO_PRINTF1(_L("\n")); sl@0: iFontStore->ReleaseFont(font); sl@0: sl@0: TEST (iHeap->__DbgMarkEnd(0) == 0); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FNTSTORE-0032 sl@0: sl@0: @SYMTestCaseDesc sl@0: Creates fonts and tests their properties sl@0: and then releases them. sl@0: sl@0: @SYMTestActions sl@0: 1. Adds four files to the font store. sl@0: 2. Retrieves number of typefaces. sl@0: 3. For all of the typefaces available it gets sl@0: the typeface support and retrieves its font height sl@0: in twips. sl@0: 4. Tests the fonts properties. sl@0: 5. Releases a hold on all font file objects allocated. sl@0: sl@0: @SYMTestExpectedResults sl@0: Test should pass sl@0: */ sl@0: void CTFsOpen::CreateAndReleaseFontsL() sl@0: { sl@0: TUid id1 = iFontStore->AddFileL(KFontDummy); sl@0: TUid id2 = iFontStore->AddFileL(KFontDummy_b); sl@0: TUid id3 = iFontStore->AddFileL(KFontDummy_i); sl@0: TUid id4 = iFontStore->AddFileL(KFontDummy_bi); sl@0: sl@0: int typefaces = iFontStore->NumTypefaces(); sl@0: for (int typeface = 0; typeface < typefaces; typeface++) sl@0: { sl@0: TTypefaceSupport support; sl@0: iFontStore->TypefaceSupport(support,typeface); sl@0: TFontSpec fs; sl@0: fs.iTypeface = support.iTypeface; sl@0: for (int height = 0; height < support.iNumHeights; height++) sl@0: { sl@0: fs.iHeight = iFontStore->FontHeightInTwips(typeface,height); sl@0: TestFont(fs); sl@0: } sl@0: } sl@0: sl@0: iFontStore->RemoveFile(id1); sl@0: iFontStore->RemoveFile(id2); sl@0: iFontStore->RemoveFile(id3); sl@0: iFontStore->RemoveFile(id4); sl@0: } sl@0: sl@0: /** sl@0: @file sl@0: @SYMTestCaseID GRAPHICS-SYSLIB-FNTSTORE-UT-1498 sl@0: @SYMTestCaseDesc Test the Shaper API sl@0: @SYMTestPriority High sl@0: @SYMTestActions This test checks the CBitmapFont::ShapeTextL() using a dummy font and a dummy shaper sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMPREQ PREQ18 sl@0: */ sl@0: void CTFsOpen::CreateShaperL() sl@0: { sl@0: __UHEAP_MARK; sl@0: INFO_PRINTF1(_L("Creating Shaper and Shaping Text\n")); sl@0: sl@0: // Add fonts sl@0: TUid id1 = iFontStore->AddFileL(KFontDummy); sl@0: TUid id2 = iFontStore->AddFileL(KFontDummy_b); sl@0: TUid id3 = iFontStore->AddFileL(KFontDummy_i); sl@0: TUid id4 = iFontStore->AddFileL(KFontDummy_bi); sl@0: sl@0: TInt error = 0; sl@0: TInt err = 0; sl@0: int typefaces = iFontStore->NumTypefaces(); sl@0: for (TInt typeface = 0; typeface < typefaces; typeface++) sl@0: { sl@0: TTypefaceSupport support; sl@0: iFontStore->TypefaceSupport(support,typeface); sl@0: TFontSpec fs; sl@0: fs.iTypeface = support.iTypeface; sl@0: for (TInt height = 0; height < support.iNumHeights; height++) sl@0: { sl@0: //Create a font sl@0: CFont* font = NULL; sl@0: fs.iHeight = iFontStore->FontHeightInTwips(typeface,height); sl@0: // get a COpenFont object sl@0: iFontStore->GetNearestFontToDesignHeightInPixels(font, fs); sl@0: CleanupStack::PushL(font); sl@0: sl@0: //do some dummy shaping sl@0: TShapeHeader* shape = 0; sl@0: sl@0: TShapeMessageParameters params; sl@0: params.iStart = 0; sl@0: params.iEnd = 8; sl@0: params.iScript = KDevanagariScriptCode; sl@0: params.iLanguage = 0; sl@0: sl@0: sl@0: TRAP(err, shape = ((CBitmapFont*)font)->ShapeTextL(KTextToShape, 0, params)); sl@0: TEST(err == KErrNotSupported); sl@0: sl@0: // Now do some dummy deletion of the TShapeHeader sl@0: TInt dummyHandle=0; sl@0: TRAP(error, ((CBitmapFont*)font)->DeleteShape(dummyHandle,shape)); sl@0: TEST(error == KErrNone); sl@0: CleanupStack::Pop(font); sl@0: iFontStore->ReleaseFont(font); sl@0: } sl@0: } sl@0: sl@0: // Remove the fonts sl@0: iFontStore->RemoveFile(id1); sl@0: iFontStore->RemoveFile(id2); sl@0: iFontStore->RemoveFile(id3); sl@0: iFontStore->RemoveFile(id4); sl@0: sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: /** End of Shaper Tests*/ sl@0: sl@0: /** sl@0: @SYMTestCaseID sl@0: GRAPHICS-FNTSTORE-0033 sl@0: sl@0: @SYMTestCaseDesc sl@0: Tests the GetNearestFontHelper function. This function may be used by sl@0: derived classes in their GetNearestFontInPixelsL() sl@0: implementations. It finds the nearest font in the typeface attribute array, sl@0: if any, to the provided font specification. If there is a possible match it sl@0: places the face index in aFaceIndex and the actual specification (including sl@0: algorithmic effects) in aActualFontSpec. sl@0: sl@0: @SYMTestActions sl@0: 1. Connects to the file system. sl@0: 2. Finds a specified file. sl@0: 3. Retrieves a font file. sl@0: 4. Sets different font attributes. sl@0: 5. Calls the GetNearestFontHelper and GetNearestFontHelperOld functions. sl@0: 6. Checks if the two functions give the same result. sl@0: sl@0: @SYMTestExpectedResults sl@0: Test should pass sl@0: */ sl@0: #ifdef _DEBUG sl@0: void CTFsOpen::TestGetNearestFontHelperL() sl@0: { sl@0: INFO_PRINTF1(_L("GetNearestFontHelper\n")); sl@0: User::LeaveIfError(iFilesys.Connect()); sl@0: TFindFile file_finder(iFilesys); sl@0: CDir* file_list = NULL; sl@0: _LIT(KFBSERVFontFilePattern, "*.ttf"); sl@0: TInt error = file_finder.FindWildByDir(KFBSERVFontFilePattern,KFBSERVFontDir,file_list); sl@0: while (!error) sl@0: { sl@0: CleanupStack::PushL(file_list); sl@0: for (int i = 0; i < file_list->Count(); i++) sl@0: { sl@0: TParse parse; sl@0: if (parse.Set((*file_list)[i].iName,&file_finder.File(),NULL) == KErrNone) sl@0: { sl@0: TPtrC name = parse.Name(); sl@0: INFO_PRINTF2(_L("Font file: %S\r\n"), &name); sl@0: CDummyFontFile* font_file = CDummyFontFile::NewL(0,parse.FullName()); sl@0: sl@0: TOpenFontSpec font_spec1; sl@0: TOpenFontSpec font_spec2_new; sl@0: TOpenFontSpec font_spec2_old; sl@0: sl@0: TInt face_index = 0; sl@0: sl@0: font_spec1.SetName(KNullDesC); sl@0: font_spec1.SetHeight(10); sl@0: sl@0: font_spec1.SetCoverage(0,0,0,0); sl@0: font_spec1.SetBold(EFalse); sl@0: font_spec1.SetItalic(EFalse); sl@0: font_spec1.SetSerif(EFalse); sl@0: font_spec1.SetMonoWidth(EFalse); sl@0: TBool res1 = font_file->GetNearestFontHelper(font_spec1,0,0,face_index,font_spec2_new); sl@0: TBool res2 = font_file->GetNearestFontHelperOld(font_spec1,0,0,face_index,font_spec2_old); sl@0: TEST(res2 ? res1 && (font_spec2_new == font_spec2_old) : ETrue); sl@0: sl@0: font_spec1.SetBold(ETrue); sl@0: res1 = font_file->GetNearestFontHelper(font_spec1,0,0,face_index,font_spec2_new); sl@0: res2 = font_file->GetNearestFontHelperOld(font_spec1,0,0,face_index,font_spec2_old); sl@0: TEST(res2 ? res1 && (font_spec2_new == font_spec2_old) : ETrue); sl@0: sl@0: font_spec1.SetItalic(ETrue); sl@0: res1 = font_file->GetNearestFontHelper(font_spec1,0,0,face_index,font_spec2_new); sl@0: res2 = font_file->GetNearestFontHelperOld(font_spec1,0,0,face_index,font_spec2_old); sl@0: TEST(res2 ? res1 && (font_spec2_new == font_spec2_old) : ETrue); sl@0: sl@0: font_spec1.SetSerif(ETrue); sl@0: res1 = font_file->GetNearestFontHelper(font_spec1,0,0,face_index,font_spec2_new); sl@0: res2 = font_file->GetNearestFontHelperOld(font_spec1,0,0,face_index,font_spec2_old); sl@0: TEST(res2 ? res1 && (font_spec2_new == font_spec2_old) : ETrue); sl@0: sl@0: font_spec1.SetMonoWidth(ETrue); sl@0: res1 = font_file->GetNearestFontHelper(font_spec1,0,0,face_index,font_spec2_new); sl@0: res2 = font_file->GetNearestFontHelperOld(font_spec1,0,0,face_index,font_spec2_old); sl@0: TEST(res2 ? res1 && (font_spec2_new == font_spec2_old) : ETrue); sl@0: sl@0: font_spec1.SetCoverage(8); sl@0: font_spec1.SetBold(EFalse); sl@0: font_spec1.SetItalic(EFalse); sl@0: font_spec1.SetSerif(EFalse); sl@0: font_spec1.SetMonoWidth(EFalse); sl@0: res1 = font_file->GetNearestFontHelper(font_spec1,0,0,face_index,font_spec2_new); sl@0: res2 = font_file->GetNearestFontHelperOld(font_spec1,0,0,face_index,font_spec2_old); sl@0: TEST(res2 ? res1 && (font_spec2_new == font_spec2_old) : ETrue); sl@0: sl@0: delete font_file; sl@0: } sl@0: } sl@0: CleanupStack::PopAndDestroy(); // file_list sl@0: if (!error) sl@0: error = file_finder.FindWild(file_list); sl@0: } sl@0: } sl@0: #endif //_DEBUG sl@0: sl@0: CDummyRasterizer* CDummyRasterizer::NewL() sl@0: { sl@0: return new(ELeave) CDummyRasterizer; sl@0: } sl@0: sl@0: COpenFontFile* CDummyRasterizer::NewFontFileL(TInt aUid,const TDesC& aFileName,RFs& /*aFileSession*/) sl@0: { sl@0: // Allow 'dummy', 'dummy_b', etc. Don't actually open a file; just create a dummy font. sl@0: if (aFileName.CompareF(KFontDummy) == 0 || sl@0: aFileName.CompareF(KFontDummy_b) == 0 || sl@0: aFileName.CompareF(KFontDummy_i) == 0 || sl@0: aFileName.CompareF(KFontDummy_bi) == 0) sl@0: return CDummyFontFile::NewL(aUid,aFileName); sl@0: return NULL; sl@0: } sl@0: sl@0: CDummyFontFile::CDummyFontFile(TInt aUid,const TDesC& aFileName): sl@0: COpenFontFile(aUid,aFileName) sl@0: { sl@0: } sl@0: sl@0: CDummyFontFile* CDummyFontFile::NewL(TInt aUid,const TDesC& aFileName) sl@0: { sl@0: CDummyFontFile* f = new(ELeave)CDummyFontFile(aUid,aFileName); sl@0: CleanupStack::PushL(f); sl@0: f->ConstructL(); sl@0: CleanupStack::Pop(); sl@0: return f; sl@0: } sl@0: sl@0: TBool CDummyFontFile::GetNearestFontHelperOld(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight, sl@0: TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const sl@0: { sl@0: return COpenFontFile::GetNearestFontHelperOld(aDesiredFontSpec,aPixelWidth,aPixelHeight,aFaceIndex,aActualFontSpec); sl@0: } sl@0: sl@0: void CDummyFontFile::ConstructL() sl@0: { sl@0: const TDesC& filename = FileName(); sl@0: TOpenFontFaceAttrib attrib; sl@0: sl@0: if (filename.CompareF(KFontDummy) == 0) sl@0: attrib.SetFullName(_L("Dummy")); sl@0: else if (filename.CompareF(KFontDummy_b) == 0) sl@0: { sl@0: attrib.SetFullName(_L("Dummy Bold")); sl@0: attrib.SetBold(TRUE); sl@0: } sl@0: else if (filename.CompareF(KFontDummy_i) == 0) sl@0: { sl@0: attrib.SetFullName(_L("Dummy Italic")); sl@0: attrib.SetItalic(TRUE); sl@0: } sl@0: else if (filename.CompareF(KFontDummy_bi) == 0) sl@0: { sl@0: attrib.SetFullName(_L("Dummy Bold Italic")); sl@0: attrib.SetBold(TRUE); sl@0: attrib.SetItalic(TRUE); sl@0: } sl@0: attrib.SetFamilyName(_L("Dummy")); sl@0: attrib.SetLocalFullName(attrib.FullName()); sl@0: attrib.SetCoverage(TOpenFontFaceAttrib::ELatinSet); sl@0: attrib.SetMinSizeInPixels(8); sl@0: AddFaceL(attrib); sl@0: } sl@0: sl@0: void CDummyFontFile::GetNearestFontInPixelsL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList, sl@0: const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight, sl@0: COpenFont*& aFont,TOpenFontSpec& aActualFontSpec) sl@0: sl@0: { sl@0: aFont = NULL; sl@0: TInt face_index = 0; sl@0: if (GetNearestFontHelper(aDesiredFontSpec,aPixelWidth,aPixelHeight,face_index,aActualFontSpec)) sl@0: aFont = CDummyFont::NewL(aHeap,aSessionCacheList,this,aActualFontSpec.Height()); sl@0: } sl@0: sl@0: void CDummyFontFile::GetNearestFontToDesignHeightInPixelsL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList, sl@0: const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight, sl@0: COpenFont*& aFont,TOpenFontSpec& aActualFontSpec) sl@0: sl@0: { sl@0: aFont = NULL; sl@0: TInt face_index = 0; sl@0: if (GetNearestFontHelper(aDesiredFontSpec,aPixelWidth,aPixelHeight,face_index,aActualFontSpec)) sl@0: aFont = CDummyFont::NewL(aHeap,aSessionCacheList,this,aActualFontSpec.Height()); sl@0: } sl@0: sl@0: void CDummyFontFile::GetNearestFontToMaxHeightInPixelsL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList, sl@0: const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight, sl@0: COpenFont*& aFont,TOpenFontSpec& aActualFontSpec,TInt /*aMaxHeight*/) sl@0: sl@0: { sl@0: aFont = NULL; sl@0: TInt face_index = 0; sl@0: if (GetNearestFontHelper(aDesiredFontSpec,aPixelWidth,aPixelHeight,face_index,aActualFontSpec)) sl@0: aFont = CDummyFont::NewL(aHeap,aSessionCacheList,this,aActualFontSpec.Height()); sl@0: } sl@0: sl@0: TBool CDummyFontFile::HasUnicodeCharacterL(TInt /*aFaceIndex*/,TInt /*aCode*/) const sl@0: { sl@0: return EFalse; // this dummy font has no characters sl@0: } sl@0: sl@0: CDummyFont* CDummyFont::NewL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList, sl@0: CDummyFontFile* aFontFile,TInt aSizeInPixels) sl@0: { sl@0: CDummyFont* f = (CDummyFont*)aHeap->AllocL(sizeof(CDummyFont)); sl@0: new(f) CDummyFont(aHeap,aSessionCacheList,aFontFile,aSizeInPixels); sl@0: return f; sl@0: } sl@0: sl@0: CDummyFont::CDummyFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,CDummyFontFile* aFontFile, sl@0: TInt aSizeInPixels): sl@0: COpenFont(aHeap,aSessionCacheList,aFontFile) sl@0: { sl@0: iMetrics.SetSize(aSizeInPixels); sl@0: iMetrics.SetAscent(aSizeInPixels * 3 / 4); sl@0: iMetrics.SetDescent(aSizeInPixels - iMetrics.Ascent()); sl@0: iMetrics.SetMaxHeight(iMetrics.Ascent()); sl@0: iMetrics.SetMaxDepth(iMetrics.Descent()); sl@0: iMetrics.SetMaxWidth(aSizeInPixels * 2); sl@0: } sl@0: sl@0: void CDummyFont::RasterizeL(TInt /*aCode*/,TOpenFontGlyphData* /*aGlyphData*/) sl@0: { sl@0: User::Leave(KErrNotSupported); // this dummy font has no glyphs sl@0: } sl@0: sl@0: static void ExpandCleanupStackL() sl@0: { sl@0: TInt count = 0; sl@0: for (; count < 10; count++) sl@0: CleanupStack::PushL((TUint32*)0x1); sl@0: CleanupStack::Pop(count); sl@0: } sl@0: sl@0: //-------------- sl@0: __CONSTRUCT_STEP__(FsOpen) sl@0: sl@0: sl@0: void CTFsOpenStep::TestSetupL() sl@0: { sl@0: ExpandCleanupStackL(); sl@0: }