00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "FontsGraphicsControl.h"
00017 #include <coemain.h>
00018
00019 CFontControl::CFontControl() {
00020
00021 iNumTypefaces = iCoeEnv->ScreenDevice()->NumTypefaces();
00022
00023 SetMaxPhases(iNumTypefaces);
00024 }
00025
00026 void CFontControl::UpdateModelL()
00027 {
00028
00029 iZoomFactor.SetGraphicsDeviceMap(iCoeEnv->ScreenDevice());
00030 iZoomFactor.SetZoomFactor(TZoomFactor::EZoomOneToOne);
00031 iDeviceMap = &iZoomFactor;
00032
00033
00034 TTypefaceSupport* myTypefaceSupport = new TTypefaceSupport;
00035 iCoeEnv->ScreenDevice()->TypefaceSupport(*myTypefaceSupport,Phase());
00036 iCurrentFont = myTypefaceSupport->iTypeface.iName.Des();
00037
00038
00039 _LIT(KFormat,"Typeface index=%d. Name=%S. Num heights=%d. (Num typefaces=%d)");
00040 TBuf<128> commentaryText;
00041 commentaryText.Format(KFormat,Phase(),&iCurrentFont,myTypefaceSupport->iNumHeights,iNumTypefaces);
00042 iGraphObserver->NotifyStatus(commentaryText);
00043 delete myTypefaceSupport;
00044 };
00045
00046 void CFontControl::Draw(const TRect& ) const
00047 {
00048
00049 CWindowGc& gc=SystemGc();
00050 gc.Clear();
00051
00052
00053 TRect screenRect=Rect();
00054
00055
00056 TFontSpec fontSpec(iCurrentFont,300);
00057
00058 CFont* screenFont;
00059 iDeviceMap->GetNearestFontInTwips(screenFont,fontSpec);
00060
00061 gc.UseFont(screenFont);
00062
00063
00064 TInt screenHeight=screenRect.Height();
00065
00066 TInt textHeight = screenFont->HeightInPixels();
00067
00068
00069 TInt exampleMargin = 0;
00070 TInt currentOffset = ((screenHeight+textHeight)/2) - (TInt)(textHeight*2.4);
00071
00072
00073 TBuf<50> buffer;
00074 TInt endPoint[6] = {64,96,138,182,216,255};
00075 TInt count = 32;
00076 for(TInt pass=0;pass<=5;pass++) {
00077 while (count<=endPoint[pass]) {
00078 buffer.Append((TUint)count);
00079 count++;
00080 }
00081
00082 gc.DrawText(buffer,screenRect,currentOffset,CGraphicsContext::ECenter,exampleMargin);
00083 currentOffset = currentOffset + (TInt)(textHeight*1.2);
00084 buffer.Zero();
00085 }
00086
00087
00088 gc.DiscardFont();
00089 iDeviceMap->ReleaseFont(screenFont);
00090 }