Symbian: playing with fonts
This code snipped shows how to draw text using Symbian C++.
This article needs to be updated: If you found this article useful, please fix the problems below then delete the {{ArticleNeedsUpdate}} template from the article to remove this warning.
Reasons: hamishwillee (27 Sep 2012)
The article has no explanation or links to official documentation. It should be extended minimally to link to reference documentation for Symbian C++ and also have a brief explanation of the code.
Reasons: hamishwillee (27 Sep 2012)
The article has no explanation or links to official documentation. It should be extended minimally to link to reference documentation for Symbian C++ and also have a brief explanation of the code.
Article Metadata
LIBRARY: gdi.lib
Headers:
#include <COEFONT.H>
#include <COEFONTPROVIDER.H>
Code
void CTestAppContainer::Draw(const TRect& /*aRect*/) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
// Gets the control's extent
TRect drawRect(Rect());
// Clears the screen
gc.Clear(drawRect);
const CCoeFontProvider& fontProvider = FindFontProvider();
TCoeFont TFont15(15,TCoeFont::EBold,0);
const CFont& boldFont = fontProvider.Font(TFont15,AccumulatedZoom());
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.SetPenStyle(CGraphicsContext::ESolidPen);
gc.SetBrushColor(KRgbDarkGreen);
gc.SetPenColor(KRgbDarkGreen);
gc.UseFont(&boldFont);
gc.DrawText(_L("Test Font"),TPoint(100,100));
gc.DiscardFont();
}


(no comments yet)