I am rendering a box with a number inside it using the following code:
void CContainer:rawNumberInBox(TInt aIndex, TBool aHighlight) const
{
CWindowGc& gc = SystemGc();
gc.SetPenSize(TSize(1, 1));
gc.SetPenColor(KRgbBlack);
gc.SetPenStyle(CGraphicsContext::ESolidPen);
gc.SetBrushColor(TRgb(230, 230, 230));
const CFont* font = AknLayoutUtils::FontFromId(EAknLogicalFontPrimaryFont);
gc.UseFont(font /* iEikonEnv->NormalFont()*/);
_LIT(KKeys, "123456789");
// draw the number
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
TInt baseline(iKeys[aIndex].Height() /2 + iEikonEnv->NormalFont()->AscentInPixels()/2);
gc.DrawText(KKeys().Mid(aIndex, 1), iKeys[aIndex], baseline, CGraphicsContext::ECenter);
gc.DiscardFont();
// draw the box
gc.SetBrushStyle(CGraphicsContext::ENullBrush);
TRect rect(iKeys[aIndex]);
if (aHighlight)
{
gc.SetPenSize(TSize(3, 3));
rect.Shrink(1, 1);
}
gc.DrawRect(rect);
}
This routine is called in two situations, from inside a CCoeControl:raw() situation and inside a DrawXXXNow() kind of routine, which looks like below, and which is called when the rect is pressed or not
void CContainer:rawXXXNow(TInt aIndex, TBool aHighlight) const
{
const TRect rect(iKeys[aIndex]);
Window().Invalidate(rect);
ActivateGc();
Window().BeginRedraw(rect);
DrawNumberInBox(aIndex, aHighlight);
Window().EndRedraw();
DeactivateGc();
}
On the N97 emulator, this results in a bold number being drawn, when called through Draw() and when called through the DrawXXXNow() routine.
However, on real devices (5800, N97) a bold number is only drawn when called through Draw(). When called through DrawXXXNow(), the number is not bold.
Is this a known bug in the platform, because the used font must be the same in both situation.
Also, the bug happens too the iEikonEnv->NormalFont() is used.
This problem can be circumvented by only calling DrawNow() on the control, but that is flicker-prone.

rawNumberInBox(TInt aIndex, TBool aHighlight) const



