|
1 /* |
|
2 * Copyright (c) 2005 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: Series 60 layout font constructed from a font specification or a |
|
15 * combination of font specification plus typeface or typeface alias |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <eikdef.h> |
|
22 #include <eikenv.h> |
|
23 #include <aknenv.h> |
|
24 |
|
25 #include "AknPanic.h" |
|
26 #include "AknFontSpecificationLayoutFont.h" |
|
27 #include <AknFontSpecification.h> |
|
28 |
|
29 #include <AknFontProvider.h> |
|
30 #include <AknFontProviderSuppliedMetrics.h> |
|
31 |
|
32 // CONSTANTS |
|
33 |
|
34 enum TAknFontSpecificationLayoutFontFlags |
|
35 { |
|
36 EUseTypeface = 0 |
|
37 }; |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS =============================== |
|
40 |
|
41 CAknFontSpecificationLayoutFont* CAknFontSpecificationLayoutFont::NewL( |
|
42 CBitmapDevice& aScreenDevice, |
|
43 const TAknFontSpecification& aSpec ) |
|
44 { |
|
45 CAknFontSpecificationLayoutFont* self = |
|
46 new (ELeave) CAknFontSpecificationLayoutFont( aScreenDevice, aSpec); |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(); |
|
49 CleanupStack::Pop(); //self |
|
50 return self; |
|
51 } |
|
52 |
|
53 CAknFontSpecificationLayoutFont* CAknFontSpecificationLayoutFont::NewL( |
|
54 CBitmapDevice& aScreenDevice, |
|
55 const TTypeface& aTypeface, |
|
56 const TAknFontSpecification& aSpec ) |
|
57 { |
|
58 CAknFontSpecificationLayoutFont* self = |
|
59 new (ELeave) CAknFontSpecificationLayoutFont( aScreenDevice, aTypeface, aSpec); |
|
60 CleanupStack::PushL(self); |
|
61 self->ConstructL(); |
|
62 CleanupStack::Pop(); //self |
|
63 return self; |
|
64 } |
|
65 |
|
66 |
|
67 CAknFontSpecificationLayoutFont::~CAknFontSpecificationLayoutFont() |
|
68 { |
|
69 } |
|
70 |
|
71 void CAknFontSpecificationLayoutFont::ConstructL() |
|
72 { |
|
73 CAknLayoutFont::Update(); |
|
74 } |
|
75 |
|
76 /** |
|
77 * Implementation of the framework method for this class |
|
78 * |
|
79 */ |
|
80 CFbsFont* CAknFontSpecificationLayoutFont::SupplyFont() |
|
81 { |
|
82 TAknFontProviderSuppliedMetrics info; |
|
83 CFbsFont* font; |
|
84 // Use Font provisioning. |
|
85 if ( iFlags[EUseTypeface] ) |
|
86 { |
|
87 font = AknFontProvider::CreateFontFromTypefaceAndMetrics( BitmapDevice(), iTypeface, iSpec, info, iFontProviderId ); |
|
88 } |
|
89 else |
|
90 { |
|
91 // Use category matching. There is no ID |
|
92 font = AknFontProvider::CreateFontFromMetrics( BitmapDevice(), 0, iSpec, info, iFontProviderId ); |
|
93 } |
|
94 |
|
95 SetExcessAscent( info.ExcessAscent() ); |
|
96 SetExcessDescent( info.ExcessDescent() ); |
|
97 SetBottomShortfall( info.MaxDescentToTextPaneBottom() ); |
|
98 return font; |
|
99 } |
|
100 |
|
101 TAknTextDecorationMetrics CAknFontSpecificationLayoutFont::DoTextDecorationMetrics() const |
|
102 { |
|
103 return TAknTextDecorationMetrics( iSpec ); |
|
104 } |
|
105 |
|
106 TAknFontSpecification CAknFontSpecificationLayoutFont::DoFontSpecification() const |
|
107 { |
|
108 return TAknFontSpecification( iSpec ); |
|
109 } |
|
110 |
|
111 TInt CAknFontSpecificationLayoutFont::DoAscentForCharacter( TChar aCharacter ) const |
|
112 { |
|
113 TInt ascent = AscentInPixels(); |
|
114 |
|
115 if ( AknFontProvider::HasBaselineCorrection( iFontProviderId ) ) |
|
116 { |
|
117 TInt baselineLift; |
|
118 TInt denominatorIfFractional; |
|
119 TInt err = AknFontProvider::BaselineDeltaForCharacter( iFontProviderId, |
|
120 aCharacter, |
|
121 baselineLift, |
|
122 denominatorIfFractional ); |
|
123 if ( err == KErrNone ) |
|
124 { |
|
125 if ( denominatorIfFractional > 0) |
|
126 { |
|
127 ascent -= ( baselineLift * ascent ) / denominatorIfFractional; |
|
128 } |
|
129 else |
|
130 { |
|
131 ascent -= baselineLift; |
|
132 } |
|
133 } |
|
134 } |
|
135 __ASSERT_DEBUG( ascent > 0, Panic( EAknPanicInvalidValue ) ); |
|
136 return ascent; |
|
137 } |
|
138 |
|
139 /** |
|
140 * C++ Constructors. |
|
141 */ |
|
142 CAknFontSpecificationLayoutFont::CAknFontSpecificationLayoutFont( |
|
143 CBitmapDevice& aScreenDevice, |
|
144 const TTypeface& aTypeface, |
|
145 const TAknFontSpecification& aSpec ) : |
|
146 CAknLayoutFont(aScreenDevice), iSpec(aSpec), iTypeface(aTypeface) |
|
147 { |
|
148 // When constructed from typeface and metrics, the typeface information replaces the role of category |
|
149 // completely. Set it to "undefined" |
|
150 iSpec.SetFontCategory( EAknFontCategoryUndefined); |
|
151 iFlags.Set(EUseTypeface); |
|
152 |
|
153 // Keep versions of text pane height in step |
|
154 __ASSERT_ALWAYS(iSpec.Units() == TAknFontSpecification::EPixels, Panic(EAknPanicInconsistentUnits) ); |
|
155 SetTextPaneHeight( iSpec.TextPaneHeight() ); |
|
156 } |
|
157 |
|
158 CAknFontSpecificationLayoutFont::CAknFontSpecificationLayoutFont( |
|
159 CBitmapDevice& aScreenDevice, |
|
160 const TAknFontSpecification& aSpec) : |
|
161 CAknLayoutFont(aScreenDevice), iSpec(aSpec) |
|
162 { |
|
163 // Keep versions of text pane height in step |
|
164 __ASSERT_ALWAYS(iSpec.Units() == TAknFontSpecification::EPixels, Panic(EAknPanicInconsistentUnits) ); |
|
165 SetTextPaneHeight( iSpec.TextPaneHeight() ); |
|
166 } |
|
167 |
|
168 |
|
169 void CAknFontSpecificationLayoutFont::Reserved_1() |
|
170 {} |
|
171 |
|
172 |
|
173 // End of File |