fbs/fontandbitmapserver/tfbs/tfbsglyphdataoutlineshadow.cpp
author hgs
Fri, 16 Jul 2010 11:45:55 +0300
changeset 116 171fae344dd4
permissions -rw-r--r--
201026_3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
116
171fae344dd4 201026_3
hgs
parents:
diff changeset
     1
// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
171fae344dd4 201026_3
hgs
parents:
diff changeset
     2
// All rights reserved.
171fae344dd4 201026_3
hgs
parents:
diff changeset
     3
// This component and the accompanying materials are made available
171fae344dd4 201026_3
hgs
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
171fae344dd4 201026_3
hgs
parents:
diff changeset
     5
// which accompanies this distribution, and is available
171fae344dd4 201026_3
hgs
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
171fae344dd4 201026_3
hgs
parents:
diff changeset
     7
//
171fae344dd4 201026_3
hgs
parents:
diff changeset
     8
// Initial Contributors:
171fae344dd4 201026_3
hgs
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
171fae344dd4 201026_3
hgs
parents:
diff changeset
    10
//
171fae344dd4 201026_3
hgs
parents:
diff changeset
    11
// Contributors:
171fae344dd4 201026_3
hgs
parents:
diff changeset
    12
//
171fae344dd4 201026_3
hgs
parents:
diff changeset
    13
// Description:
171fae344dd4 201026_3
hgs
parents:
diff changeset
    14
//
171fae344dd4 201026_3
hgs
parents:
diff changeset
    15
171fae344dd4 201026_3
hgs
parents:
diff changeset
    16
/**
171fae344dd4 201026_3
hgs
parents:
diff changeset
    17
 @file
171fae344dd4 201026_3
hgs
parents:
diff changeset
    18
 @internalComponent - Internal Symbian test code
171fae344dd4 201026_3
hgs
parents:
diff changeset
    19
*/
171fae344dd4 201026_3
hgs
parents:
diff changeset
    20
171fae344dd4 201026_3
hgs
parents:
diff changeset
    21
#include <graphics/fbsglyphdataiterator.h>
171fae344dd4 201026_3
hgs
parents:
diff changeset
    22
#include <sgresource/sgimage.h>
171fae344dd4 201026_3
hgs
parents:
diff changeset
    23
171fae344dd4 201026_3
hgs
parents:
diff changeset
    24
#include "tfbsglyphdataoutlineshadow.h"
171fae344dd4 201026_3
hgs
parents:
diff changeset
    25
171fae344dd4 201026_3
hgs
parents:
diff changeset
    26
_LIT(KTypefaceName, "DejaVu Sans Condensed");
171fae344dd4 201026_3
hgs
parents:
diff changeset
    27
171fae344dd4 201026_3
hgs
parents:
diff changeset
    28
//Note: This test must be run with a rasterizer which supports EFourColourBlendGlyphBitmap (e.g. iType)
171fae344dd4 201026_3
hgs
parents:
diff changeset
    29
//otherwise the test will fail.
171fae344dd4 201026_3
hgs
parents:
diff changeset
    30
CTFbsGlyphDataOutlineAndShadow::CTFbsGlyphDataOutlineAndShadow(CTestStep* aStep) :
171fae344dd4 201026_3
hgs
parents:
diff changeset
    31
    CTGraphicsBase(aStep)
171fae344dd4 201026_3
hgs
parents:
diff changeset
    32
    {
171fae344dd4 201026_3
hgs
parents:
diff changeset
    33
    }
171fae344dd4 201026_3
hgs
parents:
diff changeset
    34
171fae344dd4 201026_3
hgs
parents:
diff changeset
    35
CTFbsGlyphDataOutlineAndShadow::~CTFbsGlyphDataOutlineAndShadow()
171fae344dd4 201026_3
hgs
parents:
diff changeset
    36
    {
171fae344dd4 201026_3
hgs
parents:
diff changeset
    37
    if (iTs)
171fae344dd4 201026_3
hgs
parents:
diff changeset
    38
       {
171fae344dd4 201026_3
hgs
parents:
diff changeset
    39
       iTs->ReleaseFont(iFont);
171fae344dd4 201026_3
hgs
parents:
diff changeset
    40
       delete iTs;
171fae344dd4 201026_3
hgs
parents:
diff changeset
    41
       }
171fae344dd4 201026_3
hgs
parents:
diff changeset
    42
    }
171fae344dd4 201026_3
hgs
parents:
diff changeset
    43
171fae344dd4 201026_3
hgs
parents:
diff changeset
    44
void CTFbsGlyphDataOutlineAndShadow::ConstructL()
171fae344dd4 201026_3
hgs
parents:
diff changeset
    45
    {
171fae344dd4 201026_3
hgs
parents:
diff changeset
    46
    iTs = (CFbsTypefaceStore*)CFbsTypefaceStore::NewL(NULL);
171fae344dd4 201026_3
hgs
parents:
diff changeset
    47
    TFontSpec fontSpec;
171fae344dd4 201026_3
hgs
parents:
diff changeset
    48
    fontSpec.iTypeface.iName = KTypefaceName;
171fae344dd4 201026_3
hgs
parents:
diff changeset
    49
    fontSpec.iHeight = 15;
171fae344dd4 201026_3
hgs
parents:
diff changeset
    50
    fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
171fae344dd4 201026_3
hgs
parents:
diff changeset
    51
    fontSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, EDropShadowOn);
171fae344dd4 201026_3
hgs
parents:
diff changeset
    52
    fontSpec.iFontStyle.SetEffects(FontEffect::EOutline, EOutlineOn);
171fae344dd4 201026_3
hgs
parents:
diff changeset
    53
    User::LeaveIfError(iTs->GetNearestFontToDesignHeightInPixels((CFont*&)iFont, fontSpec));
171fae344dd4 201026_3
hgs
parents:
diff changeset
    54
    //now check if the font is what we requested
171fae344dd4 201026_3
hgs
parents:
diff changeset
    55
    if(iFont->FontSpecInTwips().iFontStyle.BitmapType()!=EFourColourBlendGlyphBitmap)
171fae344dd4 201026_3
hgs
parents:
diff changeset
    56
        {
171fae344dd4 201026_3
hgs
parents:
diff changeset
    57
        WARN_PRINTF1(_L("Monotype font is not installed, run iType\\binaries\\ityperast.cmd to install it"));
171fae344dd4 201026_3
hgs
parents:
diff changeset
    58
        User::Leave(KErrNotSupported);
171fae344dd4 201026_3
hgs
parents:
diff changeset
    59
        }
171fae344dd4 201026_3
hgs
parents:
diff changeset
    60
    }
171fae344dd4 201026_3
hgs
parents:
diff changeset
    61
171fae344dd4 201026_3
hgs
parents:
diff changeset
    62
/**
171fae344dd4 201026_3
hgs
parents:
diff changeset
    63
@SYMTestCaseID      GRAPHICS-FBSERV-0646
171fae344dd4 201026_3
hgs
parents:
diff changeset
    64
@SYMTestPriority    High
171fae344dd4 201026_3
hgs
parents:
diff changeset
    65
@SYMTestType        UT
171fae344dd4 201026_3
hgs
parents:
diff changeset
    66
@SYMTestStatus      Implemented
171fae344dd4 201026_3
hgs
parents:
diff changeset
    67
@SYMPREQ            PREQ2678
171fae344dd4 201026_3
hgs
parents:
diff changeset
    68
171fae344dd4 201026_3
hgs
parents:
diff changeset
    69
@SYMTestCaseDesc
171fae344dd4 201026_3
hgs
parents:
diff changeset
    70
    To ensure that glyph iterator doesn't support outline-and-shadow font
171fae344dd4 201026_3
hgs
parents:
diff changeset
    71
@SYMTestActions
171fae344dd4 201026_3
hgs
parents:
diff changeset
    72
    i. Call RFbsGlyphDataIterator::Open() with an outline-and-shadow font.
171fae344dd4 201026_3
hgs
parents:
diff changeset
    73
171fae344dd4 201026_3
hgs
parents:
diff changeset
    74
@SYMTestExpectedResults
171fae344dd4 201026_3
hgs
parents:
diff changeset
    75
    RFbsGlyphDataIterator::Open() returns KErrNotSupported.
171fae344dd4 201026_3
hgs
parents:
diff changeset
    76
*/
171fae344dd4 201026_3
hgs
parents:
diff changeset
    77
void CTFbsGlyphDataOutlineAndShadow::RunTestCaseL(TInt /*aCurTestCase*/)
171fae344dd4 201026_3
hgs
parents:
diff changeset
    78
    {
171fae344dd4 201026_3
hgs
parents:
diff changeset
    79
    INFO_PRINTF1(_L("Ensure that glyph iterator doesn't support outline-and-shadow font"));
171fae344dd4 201026_3
hgs
parents:
diff changeset
    80
    ((CTFbsGlyphDataOutlineAndShadowStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0646"));
171fae344dd4 201026_3
hgs
parents:
diff changeset
    81
    RFbsGlyphDataIterator iter;
171fae344dd4 201026_3
hgs
parents:
diff changeset
    82
    const TUint glyphCode = 50;
171fae344dd4 201026_3
hgs
parents:
diff changeset
    83
    TInt err = iter.Open(*iFont, &glyphCode, 1);
171fae344dd4 201026_3
hgs
parents:
diff changeset
    84
    TESTE(err == KErrNotSupported, err);
171fae344dd4 201026_3
hgs
parents:
diff changeset
    85
    iter.Close();
171fae344dd4 201026_3
hgs
parents:
diff changeset
    86
171fae344dd4 201026_3
hgs
parents:
diff changeset
    87
    ((CTFbsGlyphDataOutlineAndShadowStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);//_L("GRAPHICS-FBSERV-0645"));
171fae344dd4 201026_3
hgs
parents:
diff changeset
    88
    ((CTFbsGlyphDataOutlineAndShadowStep*)iStep)->CloseTMSGraphicsStep();
171fae344dd4 201026_3
hgs
parents:
diff changeset
    89
    TestComplete();     
171fae344dd4 201026_3
hgs
parents:
diff changeset
    90
    ((CTFbsGlyphDataOutlineAndShadowStep*)iStep)->RecordTestResultL();
171fae344dd4 201026_3
hgs
parents:
diff changeset
    91
    }
171fae344dd4 201026_3
hgs
parents:
diff changeset
    92
171fae344dd4 201026_3
hgs
parents:
diff changeset
    93
__CONSTRUCT_STEP__(FbsGlyphDataOutlineAndShadow)