示例#1
0
bool QSymbianTypeFaceExtras::symbianFontTableApiAvailable()
{
    enum FontTableApiAvailability {
        Unknown,
        Available,
        Unavailable
    };
    static FontTableApiAvailability availability =
            QSysInfo::symbianVersion() < QSysInfo::SV_SF_3 ?
                Unavailable : Unknown;
    if (availability == Unknown) {
        // Actually, we should ask CFeatureDiscovery::IsFeatureSupportedL()
        // with FfFontTable here. But since at the time of writing, the
        // FfFontTable flag check either gave false positives or false
        // negatives. Here comes an implicit check via CFont::ExtendedFunction.
        QSymbianTGetFontTableParam fontTableParams = {
            MAKE_TAG('O', 'S', '/', '2'), 0, 0 };
        QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock);
        CFont *font;
        const TInt getFontErr = S60->screenDevice()->GetNearestFontInTwips(font, TFontSpec());
        Q_ASSERT(getFontErr == KErrNone);
        if (font->ExtendedFunction(QSymbianKFontGetFontTable, &fontTableParams) == KErrNone) {
            font->ExtendedFunction(QSymbianKFontReleaseFontTable, &fontTableParams);
            availability = Available;
        } else {
            availability = Unavailable;
        }
        S60->screenDevice()->ReleaseFont(font);
        lock.relock();
    }
    return availability == Available;
}
示例#2
0
/**
  @SYMTestCaseID GRAPHICS-BITGDI-0084
 
  @SYMDEF             

  @SYMTestCaseDesc tests the display modes
   
  @SYMTestPriority High

  @SYMTestStatus Implemented

  @SYMTestActions tests various graphic drawing and text drawing functions to all current screen modes
 
  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
*/
void CTParam::DoTestL(TDisplayMode aDispMode)
    {
	TRAPD(err,iDevice = CFbsScreenDevice::NewL(_L("scdv"),aDispMode));
	if (err == KErrNotSupported)
		return;
	iDevice->ChangeScreenDevice(NULL);
	iDevice->SetAutoUpdate(ETrue);
	User::LeaveIfError(iDevice->CreateContext(iContext));

	iDevice->SetScalingFactor(TPoint(15, 7), 3, 2, 1, 1);
	iContext->Activate(iDevice);

	CFbsFont* font = NULL;
	User::LeaveIfError(iDevice->GetNearestFontToDesignHeightInTwips(font,TFontSpec()));
	iContext->UseFont(font);
	iDevice->ReleaseFont(font);

	TInt ret = iBitmap.Load(_L("z:\\system\\data\\tbmp.mbm"),EMbmTbmpTbmp,EFalse); 
	User::LeaveIfError(ret);

	DoAnotherTestL();

	iBitmap.Reset();
	delete iContext;
	delete iDevice;
	}
示例#3
0
//
// Auxiliary Fn for Test Case ID CTGdi_TestDefetct_DEF045746
// This method draws the text represented by aText parameter on the window
// passed to it.
//
void CTGdi::DrawTextOnWindow(const TDesC& aText,CTWin* aWin)
	{
	aWin->Win()->BeginRedraw();
	TheGc->Activate(*aWin->Win());
	TheGc->Device()->GetNearestFontToDesignHeightInTwips(iFont,TFontSpec(_L("Arial"),250));
	TheGc->UseFont(iFont);
	TheGc->Clear();
	TheGc->DrawRect(TRect(aWin->Win()->Size()));
	TheGc->DrawText(aText,TPoint(iTextOffsetX,iTextOffsetY));
	TheGc->Device()->ReleaseFont(iFont);
	TheGc->Deactivate();
	aWin->Win()->EndRedraw();
	}
示例#4
0
void CButton::GetFontSize()
	{
	iFontName.FillZ(KMaxTypefaceNameLength);
	iScreen->TypefaceSupport(iTypefaceSupport, 0);
	iFontName = iTypefaceSupport.iTypeface.iName;
	// get font
	iFontSpec = TFontSpec(iFontName, 10*12);
	iFontSpec.iTypeface.SetIsProportional(ETrue);
	iScreen->GetNearestFontInTwips(iFont,iFontSpec);

	iSize=TSize(iFont->TextWidthInPixels(_L("Пропустить")),iFont->HeightInPixels()*2);
	__LOGSTR2("iSize.width: %d, iSize.height: %d",iSize.iWidth,iSize.iHeight);
	}
示例#5
0
void CMyServer::GetFontSize()
	{
	iFontName.FillZ(KMaxTypefaceNameLength);
	iScreen->TypefaceSupport(iTypefaceSupport, 0);
	iFontName = iTypefaceSupport.iTypeface.iName;
	// get font
	iFontSpec = TFontSpec(iFontName, 10*iConfig.iHeight);
	iFontSpec.iTypeface.SetIsProportional(ETrue);
	iScreen->GetNearestFontInTwips(iFont,iFontSpec);
	if(iTitle.Length() > iDrawTextOld.Length())
		{
		iSize=TSize(iFont->TextWidthInPixels(iTitle),iFont->HeightInPixels()*4);//XXX:две строки
		}else{
			iSize=TSize(iFont->TextWidthInPixels(iDrawTextOld),iFont->HeightInPixels()*4);//XXX:две строки
		}
	__LOGSTR2("iSize.width: %d, iSize.height: %d",iSize.iWidth,iSize.iHeight);
	}
示例#6
0
TInt CleanupTestThread(TAny* aAny)
	{
	CTClean* theTest = (CTClean*) aAny;
	CTrapCleanup::New();
	RFbsSession::Connect();
	CFbsBitmapEx bmp1;
	CFbsBitmapEx bmp2;
	CFbsBitmapEx bmp3;
	TInt ret=bmp1.Create(TSize(10,10),EGray2);
	theTest->TEST(ret==KErrNone);
	ret=bmp2.Create(TSize(100,100),EGray16);
	theTest->TEST(ret==KErrNone);
	ret=bmp3.Duplicate(bmp2.Handle());
	theTest->TEST(ret==KErrNone);
	CFbsFontEx* fon1;
	CFbsFontEx* fon2;
	CFbsTypefaceStore* tfs=NULL;
	TRAP(ret,tfs=CFbsTypefaceStore::NewL(NULL));
	theTest->TEST(ret==KErrNone);
	ret=tfs->GetNearestFontToDesignHeightInPixels((CFont*&)fon1,TFontSpec(_L("Swiss"),12));
	theTest->TEST(ret==KErrNone);
	fon2=(CFbsFontEx*)User::Alloc(sizeof(CFbsFontEx));
	theTest->TEST(fon2!=NULL);
	new(fon2) CFbsFontEx;
	ret=fon2->Duplicate(fon1->Handle());
	theTest->TEST(ret==KErrNone);
	TInt rc=RFbsSession::GetSession()->ResourceCount();
	theTest->TEST(rc==5);
	TInt id;
#ifdef __WINS__
	ret=tfs->AddFile(_L("z:\\resource\\fonts\\eon14.gdr"),id);
#else
	ret=tfs->AddFile(_L("z:\\resource\\fonts\\eon.gdr"),id);
#endif
	theTest->TEST(ret==KErrNone);
	bmp2.LockHeap();
	RFbsSession::Disconnect();
	User::Panic(_L("CleanupTest"),KErrNone);
	return(KErrNone);
	}
示例#7
0
void CTScreenDevice::ConstructL()
	{
	//The following is just another test... it doesn't leave any resources for use by the test class AFAICT...
	RWsSession aSession;
	CWsScreenDevice *device1;
	CWsScreenDevice *device2;
	CWsScreenDevice *device3;

	aSession.Connect();
	device1=new(ELeave) CWsScreenDevice(aSession);
	device1->Construct(iTest->iScreenNumber);
	delete device1;
	device1=new(ELeave) CWsScreenDevice(aSession);
	device1->Construct(iTest->iScreenNumber);
	device2=new(ELeave) CWsScreenDevice(aSession);
	device2->Construct(iTest->iScreenNumber);
	device3=new(ELeave) CWsScreenDevice(aSession);
	device3->Construct(iTest->iScreenNumber);
	delete device3;
	CFbsFont *font;
	User::LeaveIfError(device1->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec()));
	RWindowGroup group(aSession);
	group.Construct(777);
	group.SetOwningWindowGroup(TheClient->iGroup->GroupWin()->Identifier());
	RWindow win(aSession);
	win.Construct(group,77);
	CWindowGc *gc=new(ELeave) CWindowGc(device1);
	gc->Construct();
	gc->Activate(win);
	gc->UseFont(font);
	device1->ReleaseFont(font);
	aSession.Flush();
	delete gc;
	win.Close();
	group.Close();
	delete device1;
	delete device2;
	aSession.Close();
	}
示例#8
0
TBool CDataWrapperBase::GetFontSpecFromConfig(const TDesC& aSectName,const TDesC& aKeyName,TFontSpec& aResult)
	{
	TBuf<KMaxTestExecuteCommandLength>	tempStore;


	TPtrC	name;
	tempStore.Format(KFormatEntryField, &aKeyName, &KTagFontSpecName);
	TBool	ret=GetStringFromConfig(aSectName, tempStore, name);

	TInt	height;
	tempStore.Format(KFormatEntryField, &aKeyName, &KTagFontSpecHeight);
	if ( !GetIntFromConfig(aSectName, tempStore, height) )
		{
		ret=EFalse;
		}

	if ( ret )
		{
		aResult=TFontSpec(name, height);
		}

	return ret;
	}
示例#9
0
void CTextWindow::Draw()
//This function is virtual and so cannot have an 'L' at the end of it's name
	{
	iGc->Clear();
	ResetPrintLine();
	switch(iDrawMode)
		{
	case EDrawModeWordJust:
		User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iTmpFont, TFontSpec(KTestFontTypefaceName,200)));
		iGc->UseFont(iTmpFont);
		DrawWordJustified(_L("Hello World"));
		DrawWordJustified(_L("One Two Three Four Five Six Seven"));
		DrawWordJustified(_L("AA    B        CC D"));
		DrawWordJustified(_L("ONEWORD"));
		iGc->DiscardFont();
		Client()->iScreen->ReleaseFont(iTmpFont);
		iTmpFont=NULL;
		break;
	case EDrawModeCharJust:
		User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iTmpFont, TFontSpec(KTestFontTypefaceName,200)));
		iGc->UseFont(iTmpFont);
		DrawCharJustified(_L("Hello World"));
		DrawCharJustified(_L("One Two Three Four Five Six Seven"));
		DrawCharJustified(_L("AA    B        CC D"));
		DrawCharJustified(_L("ONEWORD"));
		iGc->DiscardFont();
		Client()->iScreen->ReleaseFont(iTmpFont);
		iTmpFont=NULL;
		break;
	case EDrawModeFonts:
		{
		TTypefaceSupport typefaceSupport;
		Client()->iScreen->TypefaceSupport(typefaceSupport,iTypeFaceIndex);
		TBuf<0x40> title;
		TBuf16<KMaxTypefaceNameLength> tmpBuf;
		tmpBuf.Copy(typefaceSupport.iTypeface.iName);
		title.Append(tmpBuf);
		title.AppendFormat(TRefByValue<const TDesC>(_L(", Heights (Min=%d, Max=%d, Num=%d)")),typefaceSupport.iMinHeightInTwips,typefaceSupport.iMaxHeightInTwips,typefaceSupport.iNumHeights);
		PrintLine(iFont,title);
		PrintDivider();
		for (TInt tfHeight=0;tfHeight<typefaceSupport.iNumHeights;tfHeight++)
			{
			TFontSpec fspec(typefaceSupport.iTypeface.iName,Client()->iScreen->FontHeightInTwips(iTypeFaceIndex,tfHeight));
			PrintStylesL(_L("Normal, "), fspec, TFontStyle());
			PrintStylesL(_L("Bold, "), fspec, TFontStyle(EPostureUpright,EStrokeWeightBold,EPrintPosNormal));
			PrintStylesL(_L("Italic, "), fspec, TFontStyle(EPostureItalic,EStrokeWeightNormal,EPrintPosNormal));
			PrintStylesL(_L("Bold/italic, "), fspec, TFontStyle(EPostureItalic,EStrokeWeightBold,EPrintPosNormal));
			if (iYpos>Size().iHeight)
				break;
			}
		}
		break;
		}
	}