Symbian3/PDK/Source/GUID-72986B3C-047C-5411-8F15-BC9C65C3289C.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept xml:lang="en" id="GUID-72986B3C-047C-5411-8F15-BC9C65C3289C"><title>Using Typefaces </title><prolog><metadata><keywords/></metadata></prolog><conbody><p>Typefaces are stored in the Font Store. Each typeface in the store has an index number. </p> <p>You can examine the contents of the typeface store using functions in <xref href="GUID-B6AB1A2A-705C-3ABA-8BBB-C36F3319501F.dita"><apiname>CGraphicsDevice.</apiname></xref>  </p> <p>To find the number of typefaces available: </p> <codeblock id="GUID-DD17B13B-29E0-5584-B85E-639FD2BAB7DF" xml:space="preserve">
       
    13 // Find the number of typefaces
       
    14 TInt numTypefaces = iCoeEnv-&gt;ScreenDevice()-&gt;NumTypefaces();</codeblock> <p>You can find out about a type face using the <codeph>TypefaceSupport</codeph> function which returns a <xref href="GUID-39BEE3B2-6A44-33EC-8F93-31E633844086.dita"><apiname>TTypeFaceSupport</apiname></xref>. Each typeface can have a number of sizes or be scalable between a minimum and maximum size. </p> <codeblock id="GUID-B47975BF-3B7A-57B2-854E-1D59166A47A3" xml:space="preserve">
       
    15 class TTypefaceSupport
       
    16     {
       
    17 public:    
       
    18     TTypeface iTypeface  ;  // The name and attributes of the typeface.
       
    19     TInt iNumHeights;       // The number of distinct font heights available in the typeface. 
       
    20     TInt iMinHeightInTwips; // The typeface's minimum font height, in twips.
       
    21     TInt iMaxHeightInTwips; // The typeface's maximum font height, in twips. 
       
    22     TBool iIsScalable;      // ETrue if  scalable, otherwise EFalse. 
       
    23     };
       
    24     
       
    25 class TTypeface
       
    26     {
       
    27 public:
       
    28     enum
       
    29         {
       
    30         EProportional = 1, // (e.g. Swiss)
       
    31         ESerif = 2, // (e.g. Times )
       
    32         ESymbol = 4, // (e.g. Symbol )
       
    33         };
       
    34 public:
       
    35     ...
       
    36     IMPORT_C TBool IsProportional() const;
       
    37     IMPORT_C TBool IsSerif() const;
       
    38     IMPORT_C TBool IsSymbol() const;
       
    39 
       
    40     TBufC&lt;KMaxTypefaceNameLength&gt; iName;
       
    41     ....
       
    42     };
       
    43 </codeblock> <p>The code below illustrates a simple iteration through the typeface store (see also <xref href="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47.dita">selecting a font</xref>). </p> <codeblock id="GUID-368C7CBB-254E-5904-A3C5-51BB1FA94931" xml:space="preserve">...
       
    44     
       
    45 CGraphicsDevice* gDev = iCoeEnv-&gt;ScreenDevice() ;
       
    46 CWindowGc&amp; gc = SystemGc() ;
       
    47 TPoint textPosition ( 0 , 0 ) ; // Start position for drawing text.
       
    48     
       
    49 // display a list of typefaces - with each in its own typeface
       
    50 for ( index = 0 ; index &lt; numTypefaces ; index++ )
       
    51     {
       
    52     // get the next typeface
       
    53     TTypefaceSupport typeface ;
       
    54     gDev-&gt;TypefaceSupport( typeface, index ) ;
       
    55     TPtrC fontName = typeface.iTypeface.iName.Des() ;
       
    56     
       
    57     // use the typeface to get a font 
       
    58     TFontSpec fontSpec( fontName, 300 ) ; // 300 twips font height
       
    59     CFont* font ; 
       
    60     gDev-&gt;GetNearestFontToMaxHeightInTwips( font , fontSpec ) ;
       
    61     
       
    62     // use the font in the graphics context
       
    63     gc.UseFont( font ) ;
       
    64     
       
    65     // display the name of the font 
       
    66     textPosition.iTL.iY += font.iAscentInPixels ;
       
    67     gc.DrawText( fontName, textPosition ) ; // draw text on baseline
       
    68     textPosition.iTL.iY += ( font.iDescentInPixels + KWhiteSpaceBetweenLines ) ;
       
    69         
       
    70     // 
       
    71     gc.DiscardFont( font ) ;
       
    72     gDev-&gt;ReleaseFont( font ) ;
       
    73     
       
    74     }
       
    75 ...</codeblock> </conbody><related-links><link href="GUID-C1B080D9-9C6C-520B-B73E-4EB344B1FC5E.dita"><linktext>GDI Collection Overview</linktext> </link> <link href="GUID-90644B52-69D7-595C-95E3-D6F7A30C060D.dita"><linktext> Font and Text Services Collection
       
    76                 Overview</linktext> </link> <link href="GUID-71DADA82-3ABC-52D2-8360-33FAEB2E5DE9.dita"><linktext> Font and Bitmap Server
       
    77                 Component Overview </linktext> </link> <link href="GUID-416A3756-B5D5-5BCD-830E-2371C5F6B502.dita"><linktext>Font Store Component
       
    78                 Overview</linktext> </link> </related-links></concept>