Typefaces are stored in the Font Store. Each typeface in the store has an index number.
You can examine the contents of the typeface store using functions in CGraphicsDevice.
To find the number of typefaces available:
// Find the number of typefaces TInt numTypefaces = iCoeEnv->ScreenDevice()->NumTypefaces();
You can find out about a type face using the TypefaceSupport function which returns a TTypeFaceSupport. Each typeface can have a number of sizes or be scalable between a minimum and maximum size.
class TTypefaceSupport { public: TTypeface iTypeface ; // The name and attributes of the typeface. TInt iNumHeights; // The number of distinct font heights available in the typeface. TInt iMinHeightInTwips; // The typeface's minimum font height, in twips. TInt iMaxHeightInTwips; // The typeface's maximum font height, in twips. TBool iIsScalable; // ETrue if scalable, otherwise EFalse. }; class TTypeface { public: enum { EProportional = 1, // (e.g. Swiss) ESerif = 2, // (e.g. Times ) ESymbol = 4, // (e.g. Symbol ) }; public: ... IMPORT_C TBool IsProportional() const; IMPORT_C TBool IsSerif() const; IMPORT_C TBool IsSymbol() const; TBufC<KMaxTypefaceNameLength> iName; .... };
The code below illustrates a simple iteration through the typeface store (see also selecting a font).
... CGraphicsDevice* gDev = iCoeEnv->ScreenDevice() ; CWindowGc& gc = SystemGc() ; TPoint textPosition ( 0 , 0 ) ; // Start position for drawing text. // display a list of typefaces - with each in its own typeface for ( index = 0 ; index < numTypefaces ; index++ ) { // get the next typeface TTypefaceSupport typeface ; gDev->TypefaceSupport( typeface, index ) ; TPtrC fontName = typeface.iTypeface.iName.Des() ; // use the typeface to get a font TFontSpec fontSpec( fontName, 300 ) ; // 300 twips font height CFont* font ; gDev->GetNearestFontToMaxHeightInTwips( font , fontSpec ) ; // use the font in the graphics context gc.UseFont( font ) ; // display the name of the font textPosition.iTL.iY += font.iAscentInPixels ; gc.DrawText( fontName, textPosition ) ; // draw text on baseline textPosition.iTL.iY += ( font.iDescentInPixels + KWhiteSpaceBetweenLines ) ; // gc.DiscardFont( font ) ; gDev->ReleaseFont( font ) ; } ...