|
1 /* |
|
2 * Copyright (c) 2003 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: SVG Implementation header file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "SvgBitmapFontProvider.h" |
|
20 |
|
21 |
|
22 // --------------------------------------------------------------------------- |
|
23 // Two phase constructor for this class |
|
24 // |
|
25 // --------------------------------------------------------------------------- |
|
26 CSvgBitmapFontProvider* CSvgBitmapFontProvider::NewL( const TFontSpec& aFontSpec ) |
|
27 { |
|
28 CSvgBitmapFontProvider* self = NewLC( aFontSpec ); |
|
29 CleanupStack::Pop(); |
|
30 return self; |
|
31 } |
|
32 |
|
33 |
|
34 // -------------------------------------------------------------------------- |
|
35 // CSvgBitmapFontProvider* CSvgBitmapFontProvider::NewLC() |
|
36 // --------------------------------------------------------------------------- |
|
37 CSvgBitmapFontProvider* CSvgBitmapFontProvider::NewLC( const TFontSpec& aFontSpec ) |
|
38 { |
|
39 CSvgBitmapFontProvider* self = new ( ELeave ) CSvgBitmapFontProvider( aFontSpec ); |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL(); |
|
42 return self; |
|
43 } |
|
44 |
|
45 |
|
46 //---------------------------------------------------------------------------- |
|
47 // First Step of two phase construction for this class |
|
48 //---------------------------------------------------------------------------- |
|
49 CSvgBitmapFontProvider::CSvgBitmapFontProvider( const TFontSpec& aFontSpec ): |
|
50 iTypeFaceStore(NULL), |
|
51 iFontSpec(aFontSpec) |
|
52 { |
|
53 |
|
54 } |
|
55 |
|
56 // -------------------------------------------------------------------------- |
|
57 // CSvgBitmapFontProvider::ConstructL() |
|
58 // --------------------------------------------------------------------------- |
|
59 void CSvgBitmapFontProvider::ConstructL() |
|
60 { |
|
61 iTypeFaceStore = CFbsTypefaceStore::NewL(NULL); |
|
62 } |
|
63 |
|
64 // -------------------------------------------------------------------------- |
|
65 // CSvgBitmapFontProvider::ConstructL() |
|
66 // --------------------------------------------------------------------------- |
|
67 CSvgBitmapFontProvider::~CSvgBitmapFontProvider() |
|
68 { |
|
69 delete iTypeFaceStore ; |
|
70 } |
|
71 |
|
72 // -------------------------------------------------------------------------- |
|
73 // CSvgBitmapFontProvider::ReleaseFont(CFont* aFont) |
|
74 // --------------------------------------------------------------------------- |
|
75 void CSvgBitmapFontProvider::ReleaseFont(CFont* aFont) |
|
76 { |
|
77 iTypeFaceStore->ReleaseFont(aFont); |
|
78 } |
|
79 |
|
80 // -------------------------------------------------------------------------- |
|
81 // CSvgBitmapFontProvider::GetNearestFontToDesignHeightInTwips(CFont* aFont, TFontSpec aFontSpec) |
|
82 // --------------------------------------------------------------------------- |
|
83 TInt CSvgBitmapFontProvider::GetNearestFontToDesignHeightInTwips(CFont*& aFont, TFontSpec aFontSpec) |
|
84 { |
|
85 TName fontTypefaceName(aFontSpec.iTypeface.iName); |
|
86 |
|
87 TInt matchLength = fontTypefaceName.Length(); |
|
88 |
|
89 TInt typefaceCount = iTypeFaceStore->NumTypefaces(); |
|
90 TTypefaceSupport typefaceSupport; |
|
91 |
|
92 TInt i; |
|
93 for(i=0; i<typefaceCount; i++) |
|
94 { |
|
95 iTypeFaceStore->TypefaceSupport(typefaceSupport, i); |
|
96 TInt findResult = typefaceSupport.iTypeface.iName.Find(fontTypefaceName.Ptr(), matchLength); |
|
97 if(!findResult) |
|
98 { |
|
99 fontTypefaceName = typefaceSupport.iTypeface.iName; |
|
100 break; |
|
101 } |
|
102 } |
|
103 |
|
104 //If the element typeface couldn't find && didn't set the typeface name. |
|
105 if(( i == typefaceCount) && (iFontSpec.iTypeface.iName.Length())) |
|
106 { |
|
107 fontTypefaceName = iFontSpec.iTypeface.iName; |
|
108 } |
|
109 |
|
110 aFontSpec.iTypeface.iName = fontTypefaceName; |
|
111 return iTypeFaceStore->GetNearestFontToDesignHeightInTwips(aFont, aFontSpec); |
|
112 } |
|
113 |