sl@0: // Copyright (c) 2002-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: @file sl@0: @test sl@0: @internalComponent Internal Symbian test code sl@0: */ sl@0: sl@0: #include "TTYPES.H" sl@0: #include "TGraphicsContext.h" sl@0: sl@0: sl@0: sl@0: // Utility functions to show contents of test data using test.Printf sl@0: sl@0: extern void PrintTestData (const TDesC& aTitle , const TDesC16& aDataBuffer); sl@0: sl@0: extern void PrintTestData(const TDesC& aTitle, const TText16* aDataBuffer, const TInt aSize); sl@0: sl@0: sl@0: sl@0: sl@0: _LIT(KTestFontName, "Non Functional Test Font"); sl@0: sl@0: sl@0: CTestPalette2::~CTestPalette2() sl@0: { sl@0: iArray = 0; //avoid attempting to deallocate iArray in ~CPalette sl@0: iNumEntries = 0; sl@0: } sl@0: sl@0: // sl@0: // sl@0: // CTestGraphicsDevice sl@0: // sl@0: // sl@0: CTestGraphicsDevice* CTestGraphicsDevice::NewL(TSize aSizeInPixels) sl@0: { sl@0: CTestGraphicsDevice* theDevice = new (ELeave) CTestGraphicsDevice(aSizeInPixels); sl@0: CleanupStack::PushL(theDevice); sl@0: theDevice->iPalette = new (ELeave) CTestPalette2; sl@0: theDevice->iPalette->SetEntry(0, KRgbBlack); sl@0: theDevice->iPalette->SetEntry(1, KRgbWhite); sl@0: theDevice->iPalette->SetEntry(2, KRgbMagenta); sl@0: theDevice->iPalette->SetEntry(3, KRgbCyan); sl@0: sl@0: CleanupStack::Pop(theDevice); sl@0: return theDevice; sl@0: } sl@0: sl@0: CTestGraphicsDevice::CTestGraphicsDevice(TSize aSizeInPixels) sl@0: : iSize(aSizeInPixels), sl@0: iHorizontalTwipsToPixels(40), sl@0: iVerticalTwipsToPixels(40) sl@0: { sl@0: } sl@0: CTestGraphicsDevice::~CTestGraphicsDevice() sl@0: { sl@0: delete iPalette; sl@0: } sl@0: sl@0: void CTestGraphicsDevice::SetHorizontalTwipsToPixels(TInt aTwipsToPixels) sl@0: { sl@0: iHorizontalTwipsToPixels = aTwipsToPixels; sl@0: } sl@0: sl@0: void CTestGraphicsDevice::SetVerticalTwipsToPixels(TInt aTwipsToPixels) sl@0: { sl@0: iVerticalTwipsToPixels = aTwipsToPixels; sl@0: } sl@0: sl@0: TDisplayMode CTestGraphicsDevice::DisplayMode() const sl@0: { sl@0: return EColor16M; sl@0: } sl@0: sl@0: TSize CTestGraphicsDevice::SizeInPixels() const sl@0: { sl@0: return iSize; sl@0: } sl@0: sl@0: TSize CTestGraphicsDevice::SizeInTwips() const sl@0: { sl@0: return TSize(iSize.iWidth * iHorizontalTwipsToPixels, sl@0: iSize.iHeight * iVerticalTwipsToPixels); sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::CreateContext(CGraphicsContext*& aGC) sl@0: { sl@0: CGraphicsContext* r = new CTestGraphicsContext(this); sl@0: if (!r) sl@0: return KErrNoMemory; sl@0: aGC = r; sl@0: return KErrNone; sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::NumTypefaces() const sl@0: { sl@0: return 1; sl@0: } sl@0: sl@0: void CTestGraphicsDevice::TypefaceSupport(TTypefaceSupport& aTypefaceSupport, TInt aTypefaceIndex) const sl@0: { sl@0: // The only font we have at the moment is 10 pixels * 12 pixels for every character sl@0: __ASSERT_ALWAYS(aTypefaceIndex == 0, sl@0: CTestGraphicsContext::Panic(CTestGraphicsContext::ETypefaceIndexOutOfRange)); sl@0: aTypefaceSupport.iIsScalable = EFalse; sl@0: aTypefaceSupport.iMaxHeightInTwips = iVerticalTwipsToPixels * 12; sl@0: aTypefaceSupport.iMinHeightInTwips = iVerticalTwipsToPixels * 10; sl@0: aTypefaceSupport.iNumHeights = 1; sl@0: aTypefaceSupport.iTypeface.iName = KTestFontName; sl@0: aTypefaceSupport.iTypeface.SetIsProportional(ETrue); // a bit of a lie sl@0: aTypefaceSupport.iTypeface.SetIsSerif(EFalse); sl@0: aTypefaceSupport.iTypeface.SetIsSymbol(EFalse); sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::FontHeightInTwips(TInt aTypefaceIndex, TInt aHeightIndex) const sl@0: { sl@0: // The only font we have at the moment is 10 pixels * 12 pixels for every character sl@0: __ASSERT_ALWAYS(aTypefaceIndex == 0, sl@0: CTestGraphicsContext::Panic(CTestGraphicsContext::ETypefaceIndexOutOfRange)); sl@0: return iVerticalTwipsToPixels * FontHeightInPixels(aTypefaceIndex, aHeightIndex); sl@0: } sl@0: sl@0: void CTestGraphicsDevice::PaletteAttributes(TBool& aModifiable, TInt& aNumEntries) const sl@0: { sl@0: aModifiable = ETrue; sl@0: aNumEntries = 4; sl@0: } sl@0: sl@0: void CTestGraphicsDevice::SetPalette(CPalette* aPalette) sl@0: { sl@0: for (TInt i = 0; i != CTestPalette2::KNumEntries; ++i) sl@0: { sl@0: TRgb col = aPalette->GetEntry(i); sl@0: iPalette -> SetEntry(i, col); sl@0: } sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::GetPalette(CPalette*& aPalette) const sl@0: { sl@0: aPalette = const_cast(iPalette); sl@0: return KErrNone; sl@0: } sl@0: sl@0: void CTestGraphicsDevice::GetPixel(TRgb& aColor, const TPoint&) const sl@0: { sl@0: aColor = KRgbWhite; sl@0: } sl@0: sl@0: void CTestGraphicsDevice::GetScanLine(TDes8&, const TPoint&, TInt, TDisplayMode) const sl@0: { sl@0: __ASSERT_DEBUG(0, CTestGraphicsContext::Panic(CTestGraphicsContext::EUnimplemented)); sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::AddFile(const TDesC&, TInt&) sl@0: { sl@0: return KErrNotSupported; sl@0: } sl@0: sl@0: void CTestGraphicsDevice::RemoveFile(TInt) sl@0: { sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::GetNearestFontInPixels(CFont*& aFont, const TFontSpec& aFontSpec) sl@0: { sl@0: return GetNearestFontToDesignHeightInPixels(aFont, aFontSpec); sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::GetNearestFontToDesignHeightInPixels(CFont*& aFont, const TFontSpec& /*aFontSpec*/) sl@0: { sl@0: CTestFont* font = new CTestFont(); sl@0: if (!font) sl@0: return KErrNoMemory; sl@0: aFont = font; sl@0: return KErrNone; sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& /*aFontSpec*/, TInt /*aMaxHeight*/) sl@0: { sl@0: CTestFont* font = new CTestFont(); sl@0: if (!font) sl@0: return KErrNoMemory; sl@0: aFont = font; sl@0: return KErrNone; sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::FontHeightInPixels(TInt, TInt) const sl@0: { sl@0: return 12; sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::HorizontalTwipsToPixels(TInt aTwips) const sl@0: { sl@0: return aTwips / iHorizontalTwipsToPixels; sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::VerticalTwipsToPixels(TInt aTwips) const sl@0: { sl@0: return aTwips / iVerticalTwipsToPixels; sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::HorizontalPixelsToTwips(TInt aPixels) const sl@0: { sl@0: return aPixels * iHorizontalTwipsToPixels; sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::VerticalPixelsToTwips(TInt aPixels) const sl@0: { sl@0: return aPixels * iVerticalTwipsToPixels; sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec) sl@0: { sl@0: return GetNearestFontToDesignHeightInTwips(aFont, aFontSpec); sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec) sl@0: { sl@0: TFontSpec fontSpec = aFontSpec; sl@0: fontSpec.iHeight = VerticalTwipsToPixels(fontSpec.iHeight); sl@0: return GetNearestFontToDesignHeightInPixels(aFont, fontSpec); sl@0: } sl@0: sl@0: TInt CTestGraphicsDevice::GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight) sl@0: { sl@0: TFontSpec fontSpec = aFontSpec; sl@0: fontSpec.iHeight = VerticalTwipsToPixels(fontSpec.iHeight); sl@0: return GetNearestFontToMaxHeightInPixels(aFont, fontSpec, VerticalTwipsToPixels(aMaxHeight)); sl@0: } sl@0: sl@0: void CTestGraphicsDevice::ReleaseFont(CFont* aFont) sl@0: { sl@0: __ASSERT_ALWAYS(aFont->TypeUid() == TUid::Uid(12345), sl@0: CTestGraphicsContext::Panic(CTestGraphicsContext::EUnknownFont)); sl@0: delete static_cast(aFont); sl@0: } sl@0: sl@0: // sl@0: // sl@0: // CTestGraphicsContext sl@0: // sl@0: // sl@0: void CTestGraphicsContext::Panic(TInt aReason) sl@0: { sl@0: User::Panic(_L("CTestGC"), aReason); sl@0: } sl@0: sl@0: CTestGraphicsContext::CTestGraphicsContext(CTestGraphicsDevice* aGd) sl@0: : iGd(aGd), iDrawMode(EDrawModePEN), iPenSize(1,1) sl@0: { sl@0: } sl@0: sl@0: CTestGraphicsContext::~CTestGraphicsContext() sl@0: { sl@0: iLineArray.Reset(); sl@0: } sl@0: void CTestGraphicsContext::AddRectToDrawnArea(const TRect& aRect) sl@0: { sl@0: if (iDrawnArea.IsEmpty()) sl@0: iDrawnArea = aRect; sl@0: else sl@0: iDrawnArea.BoundingRect(aRect); sl@0: // only one condition at the moment sl@0: if (iDrawMode == EDrawModeXOR) sl@0: { sl@0: if (iAreaDrawnWithCondition.IsEmpty()) sl@0: iAreaDrawnWithCondition = aRect; sl@0: else sl@0: iAreaDrawnWithCondition.BoundingRect(aRect); sl@0: } sl@0: } sl@0: sl@0: void CTestGraphicsContext::AddPointToDrawnArea(const TPoint& aPoint) sl@0: { sl@0: AddRectToDrawnArea(TRect(aPoint, iPenSize)); sl@0: } sl@0: sl@0: CGraphicsDevice* CTestGraphicsContext::Device() const sl@0: { sl@0: return iGd; sl@0: } sl@0: sl@0: void CTestGraphicsContext::SetOrigin(const TPoint& aPos) sl@0: { sl@0: iOrigin = aPos; sl@0: } sl@0: sl@0: void CTestGraphicsContext::SetDrawMode(TDrawMode aDrawingMode) sl@0: { sl@0: iDrawMode = aDrawingMode; sl@0: } sl@0: sl@0: void CTestGraphicsContext::SetClippingRect(const TRect& /*aRect*/) sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::CancelClippingRect() sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::Reset() sl@0: { sl@0: iDrawMode = EDrawModePEN; sl@0: iFont = 0; sl@0: iPenSize.iWidth = 1; sl@0: iPenSize.iHeight = 1; sl@0: } sl@0: sl@0: void CTestGraphicsContext::UseFont(const CFont* aFont) sl@0: { sl@0: iFont = aFont; sl@0: } sl@0: sl@0: void CTestGraphicsContext::DiscardFont() sl@0: { sl@0: iFont = 0; sl@0: } sl@0: sl@0: void CTestGraphicsContext::SetUnderlineStyle(TFontUnderline /*UnderlineStyle*/) sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::SetStrikethroughStyle(TFontStrikethrough /*aStrikethroughStyle*/) sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::SetWordJustification(TInt /*aExcessWidth*/,TInt /*aNumGaps*/) sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::SetCharJustification(TInt /*aExcessWidth*/,TInt /*aNumChars*/) sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::SetPenColor(const TRgb& aColor) sl@0: { sl@0: CPalette* palette; sl@0: iGd->GetPalette(palette); sl@0: iPenColorIndex = palette->NearestIndex(aColor); sl@0: } sl@0: sl@0: void CTestGraphicsContext::SetPenStyle(TPenStyle /*aPenStyle*/) sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::SetPenSize(const TSize& aSize) sl@0: { sl@0: iPenSize = aSize; sl@0: } sl@0: sl@0: void CTestGraphicsContext::SetBrushColor(const TRgb& /*aColor*/) sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::SetBrushStyle(TBrushStyle /*aBrushStyle*/) sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::SetBrushOrigin(const TPoint& /*aOrigin*/) sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::UseBrushPattern(const CFbsBitmap* /*aBitmap*/) sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::DiscardBrushPattern() sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::MoveTo(const TPoint& aPoint) sl@0: { sl@0: iCurrentPos = iOrigin + aPoint; sl@0: } sl@0: sl@0: void CTestGraphicsContext::MoveBy(const TPoint& aVector) sl@0: { sl@0: iCurrentPos += aVector; sl@0: } sl@0: sl@0: void CTestGraphicsContext::Plot(const TPoint& aPoint) sl@0: { sl@0: iCurrentPos = iOrigin + aPoint; sl@0: AddPointToDrawnArea(iCurrentPos); sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawArc(const TRect& aRect,const TPoint& /*aStart*/,const TPoint& aEnd) sl@0: { sl@0: TRect r = aRect; sl@0: r.Move(iOrigin); sl@0: AddRectToDrawnArea(r); sl@0: iCurrentPos = iOrigin + aEnd; sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawLine(const TPoint& aPoint1,const TPoint& aPoint2) sl@0: { sl@0: AddPointToDrawnArea(iOrigin + aPoint1); sl@0: iCurrentPos = iOrigin + aPoint2; sl@0: AddPointToDrawnArea(iCurrentPos); sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawLineTo(const TPoint& aPoint) sl@0: { sl@0: AddPointToDrawnArea(iCurrentPos); sl@0: iCurrentPos = iOrigin + aPoint; sl@0: AddPointToDrawnArea(iCurrentPos); sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawLineBy(const TPoint& aVector) sl@0: { sl@0: AddPointToDrawnArea(iCurrentPos); sl@0: iCurrentPos += aVector; sl@0: AddPointToDrawnArea(iCurrentPos); sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawPolyLine(const CArrayFix* aPointList) sl@0: { sl@0: TInt num = aPointList->Count(); sl@0: while (num--) sl@0: { sl@0: iCurrentPos = iOrigin + (*aPointList)[num - 1]; sl@0: AddPointToDrawnArea(iCurrentPos); sl@0: } sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawPolyLine(const TPoint* aPointList,TInt aNumPoints) sl@0: { sl@0: while (aNumPoints--) sl@0: { sl@0: iCurrentPos = iOrigin + aPointList[aNumPoints - 1]; sl@0: AddPointToDrawnArea(iCurrentPos); sl@0: } sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawPie(const TRect& aRect, sl@0: const TPoint& /*aStart*/, const TPoint& aEnd) sl@0: { sl@0: TRect r = aRect; sl@0: r.Move(iOrigin); sl@0: AddRectToDrawnArea(r); sl@0: iCurrentPos = iOrigin + aEnd; sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawEllipse(const TRect& aRect) sl@0: { sl@0: TRect r = aRect; sl@0: r.Move(iOrigin); sl@0: AddRectToDrawnArea(r); sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawRect(const TRect& aRect) sl@0: { sl@0: TRect r = aRect; sl@0: r.Move(iOrigin); sl@0: AddRectToDrawnArea(r); sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawRoundRect(const TRect& aRect,const TSize& aCornerSize) sl@0: { sl@0: TRect r = aRect; sl@0: r.Move(iOrigin); sl@0: r.Grow(aCornerSize); sl@0: AddRectToDrawnArea(r); sl@0: } sl@0: sl@0: TInt CTestGraphicsContext::DrawPolygon(const CArrayFix* aPointList,TFillRule /*aFillRule*/) sl@0: { sl@0: TInt num = aPointList->Count(); sl@0: while (num--) sl@0: { sl@0: iCurrentPos = iOrigin + (*aPointList)[num - 1]; sl@0: AddPointToDrawnArea(iCurrentPos); sl@0: } sl@0: return KErrNone; sl@0: } sl@0: sl@0: TInt CTestGraphicsContext::DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule /*aFillRule*/) sl@0: { sl@0: while (aNumPoints--) sl@0: { sl@0: iCurrentPos = iOrigin + aPointList[aNumPoints - 1]; sl@0: AddPointToDrawnArea(iCurrentPos); sl@0: } sl@0: return KErrNone; sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawBitmap(const TPoint& /*aTopLeft*/,const CFbsBitmap* /*aSource*/) sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawBitmap(const TRect& /*aDestRect*/,const CFbsBitmap* /*aSource*/) sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawBitmap(const TRect& /*aDestRect*/,const CFbsBitmap* /*aSource*/,const TRect& /*aSourceRect*/) sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawBitmapMasked(const TRect& /*aDestRect*/,const CFbsBitmap* /*aBitmap*/,const TRect& /*aSourceRect*/,const CFbsBitmap* /*aMaskBitmap*/,TBool /*aInvertMask*/) sl@0: {} sl@0: sl@0: void CTestGraphicsContext::DrawBitmapMasked(const TRect& /*aDestRect*/,const CWsBitmap* /*aBitmap*/,const TRect& /*aSourceRect*/,const CWsBitmap* /*aMaskBitmap*/,TBool /*aInvertMask*/) sl@0: { sl@0: } sl@0: sl@0: void CTestGraphicsContext::MapColors(const TRect &/*aRect*/,const TRgb */*aColors*/,TInt /*aNumPairs*/,TBool /*aMapForwards*/) sl@0: {} sl@0: sl@0: TInt CTestGraphicsContext::SetClippingRegion(const TRegion &/*aRegion*/) sl@0: { sl@0: return KErrNone; sl@0: } sl@0: sl@0: void CTestGraphicsContext::CancelClippingRegion() sl@0: {} sl@0: sl@0: void CTestGraphicsContext::DrawTextVertical(const TDesC& /*aText*/,const TPoint& /*aPos*/,TBool /*aUp*/) sl@0: {} sl@0: sl@0: void CTestGraphicsContext::DrawTextVertical(const TDesC& /*aText*/,const TRect& /*aBox*/,TInt /*aBaselineOffset*/,TBool /*aUp*/,TTextAlign /*aVert*/,TInt /*aMargin*/) sl@0: {} sl@0: sl@0: /** sl@0: * sl@0: * DrawText - merely add line "drawn" to collection sl@0: * sl@0: */ sl@0: sl@0: sl@0: void CTestGraphicsContext::DrawText(const TDesC& aText,const TPoint& aPosition) sl@0: { sl@0: sl@0: #ifdef PRINT_DRAWTEXT_LINES sl@0: sl@0: _LIT(KDrawTextFormat, "DrawText called for position %d,%d:"); sl@0: _LIT(KDrawTextTitle, "Text being drawn"); sl@0: test.Printf(KDrawTextFormat, aPosition.iX, aPosition.iY); sl@0: PrintTestData(KDrawTextTitle, aText); sl@0: sl@0: #endif /* PRINT_DRAWTEXT_LINES */ sl@0: sl@0: TTestGCDisplayLine thisLine; sl@0: thisLine.Set(aPosition, aText); sl@0: iLineArray.Append(thisLine); sl@0: sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawText(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset, sl@0: TTextAlign /*aAlignment*/, TInt aLeftMargin) sl@0: { sl@0: TPoint pos(aBox.iBr.iX + aLeftMargin, aBox.iTl.iY + aBaselineOffset); sl@0: pos += iOrigin; sl@0: DrawText(aText, pos); sl@0: } sl@0: sl@0: void CTestGraphicsContext::DrawText(const TDesC& aText, const TPoint& aPosition, sl@0: const TDrawTextParam&) sl@0: { sl@0: DrawText(aText, aPosition); sl@0: } sl@0: sl@0: // sl@0: // sl@0: // CTestFont sl@0: // sl@0: // sl@0: TUid CTestFont::DoTypeUid() const sl@0: { sl@0: return TUid::Uid(12345); sl@0: } sl@0: sl@0: TInt CTestFont::DoHeightInPixels() const sl@0: { sl@0: return 12; sl@0: } sl@0: sl@0: TInt CTestFont::DoAscentInPixels() const sl@0: { sl@0: return 10; sl@0: } sl@0: sl@0: TInt CTestFont::DoCharWidthInPixels(TChar aChar) const sl@0: { sl@0: switch (aChar) sl@0: { sl@0: case 0x200C: sl@0: case 0x200D: sl@0: case 0x200E: sl@0: case 0x200F: sl@0: case 0x202A: sl@0: case 0x202B: sl@0: case 0x202C: sl@0: case 0x202D: sl@0: case 0x202E: sl@0: case 0xFFFF: sl@0: return 0; sl@0: default: sl@0: return 10; sl@0: } sl@0: } sl@0: sl@0: TInt CTestFont::DoTextWidthInPixels(const TDesC& aText) const sl@0: { sl@0: TInt total = 0; sl@0: const TText* p = aText.Ptr(); sl@0: const TText* end = p + aText.Length(); sl@0: for (;p != end; ++p) sl@0: total += CharWidthInPixels(*p); sl@0: return total; sl@0: } sl@0: sl@0: TInt CTestFont::DoBaselineOffsetInPixels() const sl@0: { sl@0: return 10; sl@0: } sl@0: sl@0: TInt CTestFont::DoTextCount(const TDesC& aText,TInt aWidthInPixels) const sl@0: { sl@0: TInt excess; sl@0: return DoTextCount(aText, aWidthInPixels, excess); sl@0: } sl@0: sl@0: TInt CTestFont::DoTextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const sl@0: { sl@0: aExcessWidthInPixels = aWidthInPixels; sl@0: const TText* start = aText.Ptr(); sl@0: const TText* end = start + aText.Length(); sl@0: const TText* p = start; sl@0: TInt width; sl@0: while (p != end sl@0: && (width = CharWidthInPixels(*p)) <= aExcessWidthInPixels) sl@0: { sl@0: aExcessWidthInPixels -= width; sl@0: ++p; sl@0: } sl@0: return p - start; sl@0: } sl@0: sl@0: TInt CTestFont::DoMaxCharWidthInPixels() const sl@0: { sl@0: return 10; sl@0: } sl@0: sl@0: TInt CTestFont::DoMaxNormalCharWidthInPixels() const sl@0: { sl@0: return 10; sl@0: } sl@0: sl@0: TFontSpec CTestFont::DoFontSpecInTwips() const sl@0: { sl@0: return TFontSpec(KTestFontName, 12); sl@0: } sl@0: sl@0: CFont::TCharacterDataAvailability sl@0: CTestFont::DoGetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics, sl@0: const TUint8*& aBitmap, TSize& aBitmapSize) const sl@0: { sl@0: TInt width; sl@0: switch (aCode) sl@0: { sl@0: case 0x001B: sl@0: // ESC character should cause this fault; no character data available. sl@0: return CFont::ENoCharacterData; sl@0: case 'W': sl@0: // We want 'W' to have side-bearings sl@0: CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize); sl@0: width = aMetrics.Width(); sl@0: aMetrics.SetHorizBearingX(-1); sl@0: aMetrics.SetWidth(width + 2); sl@0: return CFont::ECharacterWidthOnly ; sl@0: case 0x0648: sl@0: // Arabic Waw-- has massive left side-bearing sl@0: CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize); sl@0: width = aMetrics.Width(); sl@0: aMetrics.SetHorizBearingX(-5); sl@0: aMetrics.SetWidth(width + 5); sl@0: return CFont::ECharacterWidthOnly ; sl@0: case 'X': sl@0: // We want 'X' to have a left side-bearing only sl@0: CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize); sl@0: aMetrics.SetHorizBearingX(-1); sl@0: return CFont::ECharacterWidthOnly ; sl@0: case 0x05EA: sl@0: // We want Hebrew Tav to have a +ve left side-bearing sl@0: CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize); sl@0: aMetrics.SetHorizBearingX(1); sl@0: return CFont::ECharacterWidthOnly ; sl@0: case 0x304B: sl@0: // We want Hiragana Ka to have a top end-bearing sl@0: CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize); sl@0: aMetrics.SetVertBearingY(-1); sl@0: return CFont::EAllCharacterData ; sl@0: case 0x0020: sl@0: CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize); sl@0: aMetrics.SetWidth(0); sl@0: aMetrics.SetHeight(0); sl@0: aMetrics.SetVertAdvance(0); sl@0: return CFont::ECharacterWidthOnly ; sl@0: default: sl@0: return CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize); sl@0: } sl@0: }