|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of THuiFontManager. Handles the management |
|
15 * of Hitchcock UI Toolkit specific fonts. The implementation |
|
16 * consists only of Symbian / S60 specific implementation but |
|
17 * the interface is designed so that alternative platforms can be |
|
18 * utilized. |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 #include <uiacceltk/huifontmanager.h> |
|
25 #include <uiacceltk/HuiEnv.h> |
|
26 #include <coemain.h> |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // Creates the THuiFontManager. Sets parameters to default values. |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 EXPORT_C THuiFontManager::THuiFontManager() |
|
35 { |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // Destroys the THuiFontManager. Makes sure all allocated resources are freed. |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 EXPORT_C THuiFontManager::~THuiFontManager() |
|
43 { |
|
44 // Close the array of fonts |
|
45 iFonts.Close(); |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // Returns font specifications of all platform-supported fonts. |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C void THuiFontManager::EnumerateFontsL(RArray<THuiFontSpecification>& aArray) const |
|
53 { |
|
54 // Add all font specification objects into the output array. |
|
55 CWsScreenDevice* screenDevice = CHuiStatic::ScreenDevice(); |
|
56 TInt numSystemFonts = screenDevice->NumTypefaces(); |
|
57 for(TInt i = 0; i < numSystemFonts; ++i) |
|
58 { |
|
59 THuiFontSpecification fontSpecification; |
|
60 TTypefaceSupport typefaceSupport; |
|
61 |
|
62 // Retrieve the typeface support information from the system |
|
63 screenDevice->TypefaceSupport(typefaceSupport, i); |
|
64 |
|
65 // Retrieve the typeface family name from typeface support |
|
66 fontSpecification.SetTypefaceFamily(typefaceSupport.iTypeface.iName.Des()); |
|
67 |
|
68 // Append font specification to the array. |
|
69 aArray.AppendL(fontSpecification); |
|
70 } |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // Creates a new font instance. |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 EXPORT_C TInt THuiFontManager::CreateFontL(const THuiFontSpecification& aSpecification) |
|
78 { |
|
79 // Include the specified font into the array of fonts. |
|
80 iFonts.AppendL(aSpecification); |
|
81 |
|
82 // Return the unique ID of the font. |
|
83 return iFonts.Count() - 1; |
|
84 } |