diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/PDK/Source/GUID-72986B3C-047C-5411-8F15-BC9C65C3289C.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/PDK/Source/GUID-72986B3C-047C-5411-8F15-BC9C65C3289C.dita Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,78 @@ + + + + + +Using Typefaces

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 ) ; + + } +...
GDI Collection Overview Font and Text Services Collection + Overview Font and Bitmap Server + Component Overview Font Store Component + Overview
\ No newline at end of file