sl@0: /* sl@0: * Copyright (c) 2005-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: * This file contains text and glyph data for testing sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: sl@0: //class used for holding input and output data for the shaper, for testing purposes. sl@0: class CTestData : public CBase sl@0: { sl@0: public: sl@0: //ctor sl@0: CTestData(): iTypeFaceName(NULL), iFilename(NULL), iTextInput(NULL), iStart(0), iEnd(0), sl@0: iGlyphCount(0), iGlyphs(NULL), iIndices(NULL), iPositions(NULL) sl@0: {} sl@0: sl@0: ~CTestData(); sl@0: sl@0: //reads in all the data from the test file sl@0: void Internalize(TPtrC16 aTestDataFilename); sl@0: sl@0: //input parameters sl@0: TBuf16<50> iTypeFaceName; sl@0: TBuf16<100> iFilename; sl@0: TDes16* iTextInput; sl@0: TInt iStart; sl@0: TInt iEnd; sl@0: sl@0: //equivalent expected output sl@0: TInt iGlyphCount; sl@0: CArrayFixFlat* iGlyphs; // note RArray not used for these members as sl@0: CArrayFixFlat* iIndices; // is aligned to 4byte boundary sl@0: CArrayFixFlat* iPositions; sl@0: TPoint iAdvance; sl@0: TInt iCharacterCount; sl@0: }; sl@0: sl@0: CTestData::~CTestData(void) sl@0: { sl@0: delete iTextInput; sl@0: delete iGlyphs; sl@0: delete iIndices; sl@0: delete iPositions; sl@0: } sl@0: sl@0: void CTestData::Internalize(TPtrC16 aTestDataFilename) sl@0: { sl@0: // open rfs handle sl@0: RFs fs; sl@0: User::LeaveIfError(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: sl@0: // open file sl@0: RFile file; sl@0: file.Open(fs, aTestDataFilename, EFileRead); sl@0: sl@0: // set up file buf and read stream sl@0: RFileBuf buf; sl@0: buf.Attach(file); sl@0: CleanupClosePushL(buf); sl@0: RReadStream stream(&buf); sl@0: CleanupClosePushL(stream); sl@0: sl@0: //read in from file sl@0: TBuf16<1500> tempBuf; sl@0: TInt count; sl@0: TInt i=0; sl@0: TChar delimiter('|'); sl@0: sl@0: //FIRST THE INPUT DATA sl@0: sl@0: //number of input chars sl@0: count = stream.ReadInt16L(); sl@0: sl@0: //typeface name sl@0: stream.ReadL(iTypeFaceName,delimiter); sl@0: iTypeFaceName.Delete(iTypeFaceName.Length() - 1, 1); sl@0: sl@0: //filename sl@0: stream.ReadL(iFilename,delimiter); sl@0: iFilename.Delete(iFilename.Length() - 1, 1); sl@0: sl@0: //start sl@0: iStart = stream.ReadInt16L(); sl@0: stream.ReadL(tempBuf,delimiter); sl@0: sl@0: //end sl@0: iEnd = stream.ReadInt16L(); sl@0: stream.ReadL(tempBuf,delimiter); sl@0: sl@0: //text input sl@0: iTextInput = new(ELeave) TBuf16<1500>; sl@0: stream.ReadL(*iTextInput,count); sl@0: stream.ReadL(tempBuf,delimiter); sl@0: sl@0: //NOW THE OUTPUT DATA sl@0: sl@0: //firt the glyph count sl@0: iGlyphCount = stream.ReadInt16L(); sl@0: sl@0: //then the Glyphs sl@0: iGlyphs = new(ELeave) CArrayFixFlat(1); sl@0: for (i=0; iAppendL(stream.ReadInt32L()); sl@0: } sl@0: sl@0: //then the x and y positions sl@0: iPositions = new(ELeave) CArrayFixFlat(1); sl@0: for (i=0; iAppendL(stream.ReadInt16L()); sl@0: } sl@0: sl@0: //then the advance sl@0: iAdvance.iX = stream.ReadInt16L(); sl@0: iAdvance.iY = stream.ReadInt16L(); sl@0: sl@0: //and finally the indices sl@0: iIndices = new(ELeave) CArrayFixFlat(1); sl@0: for (i=0; iAppendL(stream.ReadInt16L()); sl@0: } sl@0: sl@0: //and the character count sl@0: iCharacterCount = stream.ReadInt16L(); sl@0: sl@0: CleanupStack::PopAndDestroy(3); //buf, fs sl@0: } sl@0: sl@0: sl@0: