sl@0
|
1 |
// Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <gdi.h>
|
sl@0
|
17 |
#include <openfont.h>
|
sl@0
|
18 |
#include "GlyphSel.h"
|
sl@0
|
19 |
#include "FontThai.h"
|
sl@0
|
20 |
#include "FontArabic.h"
|
sl@0
|
21 |
#include "FontIndic.h"
|
sl@0
|
22 |
#include "GDIPANIC.h"
|
sl@0
|
23 |
#include "glyphsample.h"
|
sl@0
|
24 |
#include "gdiinline.inl"
|
sl@0
|
25 |
#include "gdistructs.h"
|
sl@0
|
26 |
#include "gdiconsts.h"
|
sl@0
|
27 |
#include "gdiplatapi.h"
|
sl@0
|
28 |
|
sl@0
|
29 |
/**
|
sl@0
|
30 |
Names holds the types & data associated with the glyph selection
|
sl@0
|
31 |
algorithm in CFont::GetCharacterPosition().
|
sl@0
|
32 |
@internalComponent
|
sl@0
|
33 |
*/
|
sl@0
|
34 |
namespace GlyphSelection
|
sl@0
|
35 |
{
|
sl@0
|
36 |
|
sl@0
|
37 |
typedef TBool (*ProcessFunc)(TGlyphSelectionState& aGss, RShapeInfo&);
|
sl@0
|
38 |
|
sl@0
|
39 |
/**
|
sl@0
|
40 |
This structure defines the fields present in each row of the GlyphTable
|
sl@0
|
41 |
datat table below.
|
sl@0
|
42 |
@internalComponent
|
sl@0
|
43 |
*/
|
sl@0
|
44 |
struct TTableEntry
|
sl@0
|
45 |
{
|
sl@0
|
46 |
TUint iLow;
|
sl@0
|
47 |
TUint iHigh;
|
sl@0
|
48 |
ProcessFunc iProcessFunc;
|
sl@0
|
49 |
};
|
sl@0
|
50 |
|
sl@0
|
51 |
/**
|
sl@0
|
52 |
This table encodes the Unicode character ranges and the glyph selector
|
sl@0
|
53 |
classes to be used for each character range when processing characters
|
sl@0
|
54 |
into glyph clusters in CFont::GetCharacterPosition().
|
sl@0
|
55 |
New glyph selection classes must make sure they are listed in this
|
sl@0
|
56 |
table to ensure they are invoked as required.
|
sl@0
|
57 |
A '0' iProcessFunc entry tells the algorithm to skip the character.
|
sl@0
|
58 |
@internalComponent
|
sl@0
|
59 |
*/
|
sl@0
|
60 |
static const TTableEntry Table[] =
|
sl@0
|
61 |
{
|
sl@0
|
62 |
// iLow, iHigh, iProcessFunc
|
sl@0
|
63 |
{ 0x0000, 0x00AC, GlyphSelector_Default::Process},
|
sl@0
|
64 |
{ 0x00AD, 0x00AD, GlyphSelector_SoftHyphen::Process},
|
sl@0
|
65 |
{ 0x00AE, 0x05FF, GlyphSelector_Default::Process},
|
sl@0
|
66 |
{ 0x0600, 0x06FF, GlyphSelector_Arabic::Process},
|
sl@0
|
67 |
{ 0x0700, 0x08FF, GlyphSelector_Default::Process},
|
sl@0
|
68 |
{ 0x0900, 0x0970, GlyphSelector_Devanagari::Process},
|
sl@0
|
69 |
{ 0x0980, 0x09FF, GlyphSelector_Bengali::Process},
|
sl@0
|
70 |
{ 0x0A00, 0x0A7F, GlyphSelector_Gurmukhi::Process},
|
sl@0
|
71 |
{ 0x0A80, 0x0AFF, GlyphSelector_Gujarati::Process},
|
sl@0
|
72 |
{ 0x0B80, 0x0BFF, GlyphSelector_Tamil::Process},
|
sl@0
|
73 |
{ 0x0C00, 0x0C7F, GlyphSelector_Telugu::Process},
|
sl@0
|
74 |
{ 0x0C80, 0x0CFF, GlyphSelector_Kannada::Process},
|
sl@0
|
75 |
{ 0x0D00, 0x0D7F, GlyphSelector_Malayalam::Process},
|
sl@0
|
76 |
{ 0x0D80, 0x0DFF, GlyphSelector_Default::Process},
|
sl@0
|
77 |
{ 0x0E00, 0x0E32, GlyphSelector_Thai::Process},
|
sl@0
|
78 |
{ 0x0E33, 0x0E33, GlyphSelector_ThaiSaraAm::Process},
|
sl@0
|
79 |
{ 0x0E34, 0x0E7F, GlyphSelector_Thai::Process},
|
sl@0
|
80 |
{ 0x0E80, 0x200B, GlyphSelector_Default::Process},
|
sl@0
|
81 |
{ 0x200C, 0x200F, 0},
|
sl@0
|
82 |
{ 0x2010, 0x2029, GlyphSelector_Default::Process},
|
sl@0
|
83 |
{ 0x202A, 0x202E, 0},
|
sl@0
|
84 |
{ 0x202F, 0xFFFD, GlyphSelector_Default::Process},
|
sl@0
|
85 |
{ 0xFFFE, 0xFFFF, 0},
|
sl@0
|
86 |
{ 0x10000, 0x10FFFF, GlyphSelector_Default::Process},
|
sl@0
|
87 |
{0xFFFFFFFF,0xFFFFFFFF, 0}
|
sl@0
|
88 |
};
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
/** Find appropriate processor function for the given character.
|
sl@0
|
92 |
@param aChar Character for processing.
|
sl@0
|
93 |
@return processor function or 0 if the character is to be skipped.
|
sl@0
|
94 |
@internalComponent */
|
sl@0
|
95 |
GlyphSelection::ProcessFunc CharacterToProcessFunction(TInt aChar)
|
sl@0
|
96 |
{
|
sl@0
|
97 |
for (const GlyphSelection::TTableEntry* glyphSel = GlyphSelection::Table;
|
sl@0
|
98 |
glyphSel->iLow != 0xFFFFFFFF; glyphSel++)
|
sl@0
|
99 |
{
|
sl@0
|
100 |
if ((glyphSel->iLow <= aChar) && (aChar <= glyphSel->iHigh))
|
sl@0
|
101 |
return glyphSel->iProcessFunc;
|
sl@0
|
102 |
}
|
sl@0
|
103 |
return 0;
|
sl@0
|
104 |
}
|
sl@0
|
105 |
|
sl@0
|
106 |
/**
|
sl@0
|
107 |
@internalTechnology For use by TFontStyle/TOpenFontSpec.
|
sl@0
|
108 |
*/
|
sl@0
|
109 |
EXPORT_C TBool FontEffect::IsEffectOn(TEffect aEffect, TUint32 aFontEffect)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
return aEffect & aFontEffect;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
|
sl@0
|
114 |
/**
|
sl@0
|
115 |
@internalTechnology For use by TFontStyle/TOpenFontSpec.
|
sl@0
|
116 |
*/
|
sl@0
|
117 |
EXPORT_C void FontEffect::SetEffect(TEffect aEffect, TBool aOn, TUint32& aFontEffect)
|
sl@0
|
118 |
{
|
sl@0
|
119 |
if (aOn)
|
sl@0
|
120 |
aFontEffect |= aEffect;
|
sl@0
|
121 |
else
|
sl@0
|
122 |
aFontEffect &= ~aEffect;
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
|
sl@0
|
126 |
//
|
sl@0
|
127 |
// TFontStyle
|
sl@0
|
128 |
//
|
sl@0
|
129 |
|
sl@0
|
130 |
/** Default C++ constructor. */
|
sl@0
|
131 |
EXPORT_C TFontStyle::TFontStyle():
|
sl@0
|
132 |
iFlags(0), iReserved1(0), iReserved2(0)
|
sl@0
|
133 |
{}
|
sl@0
|
134 |
|
sl@0
|
135 |
|
sl@0
|
136 |
/** Constructs a TFontStyle object with the specified attributes.
|
sl@0
|
137 |
@param aPost The posture attribute.
|
sl@0
|
138 |
@param aStrWgt The stroke weight attribute.
|
sl@0
|
139 |
@param aPrintPos The print position attribute. */
|
sl@0
|
140 |
EXPORT_C TFontStyle::TFontStyle(TFontPosture aPostr,TFontStrokeWeight aWgt,TFontPrintPosition aPos):
|
sl@0
|
141 |
iFlags(0), iReserved1(0), iReserved2(0)
|
sl@0
|
142 |
{
|
sl@0
|
143 |
if (aPostr == EPostureItalic)
|
sl@0
|
144 |
{
|
sl@0
|
145 |
iFlags |= EItalic;
|
sl@0
|
146 |
}
|
sl@0
|
147 |
if (aWgt == EStrokeWeightBold)
|
sl@0
|
148 |
{
|
sl@0
|
149 |
iFlags |= EBold;
|
sl@0
|
150 |
}
|
sl@0
|
151 |
if (aPos == EPrintPosSuperscript)
|
sl@0
|
152 |
{
|
sl@0
|
153 |
iFlags |= ESuper;
|
sl@0
|
154 |
}
|
sl@0
|
155 |
else if (aPos == EPrintPosSubscript)
|
sl@0
|
156 |
{
|
sl@0
|
157 |
iFlags |= ESub;
|
sl@0
|
158 |
}
|
sl@0
|
159 |
}
|
sl@0
|
160 |
|
sl@0
|
161 |
|
sl@0
|
162 |
EXPORT_C void TFontStyle::InternalizeL(RReadStream& aStream)
|
sl@0
|
163 |
/** Internalises a font style from a read stream.
|
sl@0
|
164 |
|
sl@0
|
165 |
The presence of this function means that the standard templated operator>>()
|
sl@0
|
166 |
(defined in s32strm.h) is available to internalise objects of this class.
|
sl@0
|
167 |
|
sl@0
|
168 |
@param aStream The stream from which the font style is to be internalised
|
sl@0
|
169 |
@leave KErrNoMemory If there is a problem reading from the stream.
|
sl@0
|
170 |
If internalisation causes an out of memory error. */
|
sl@0
|
171 |
{
|
sl@0
|
172 |
iFlags = aStream.ReadUint32L();
|
sl@0
|
173 |
}
|
sl@0
|
174 |
|
sl@0
|
175 |
|
sl@0
|
176 |
EXPORT_C void TFontStyle::ExternalizeL(RWriteStream& aStream) const
|
sl@0
|
177 |
/** Externalises the font style to a write stream.
|
sl@0
|
178 |
|
sl@0
|
179 |
The presence of this function means that the standard templated operator<<()
|
sl@0
|
180 |
(defined in s32strm.h) is available to externalise objects of this class.
|
sl@0
|
181 |
|
sl@0
|
182 |
@param aStream The stream to which the font style is to be externalised.
|
sl@0
|
183 |
@leave KErrNoMemory This function may leave, if the write action causes the
|
sl@0
|
184 |
stream's resources to be exhausted. */
|
sl@0
|
185 |
{
|
sl@0
|
186 |
aStream.WriteUint32L(iFlags);
|
sl@0
|
187 |
}
|
sl@0
|
188 |
|
sl@0
|
189 |
|
sl@0
|
190 |
EXPORT_C TFontPosture TFontStyle::Posture() const
|
sl@0
|
191 |
/** Gets the posture attribute.
|
sl@0
|
192 |
|
sl@0
|
193 |
@return The font style's posture. */
|
sl@0
|
194 |
{
|
sl@0
|
195 |
if(iFlags&EItalic) return(EPostureItalic);
|
sl@0
|
196 |
return(EPostureUpright);
|
sl@0
|
197 |
}
|
sl@0
|
198 |
|
sl@0
|
199 |
|
sl@0
|
200 |
EXPORT_C TFontStrokeWeight TFontStyle::StrokeWeight() const
|
sl@0
|
201 |
/** Gets the stroke weight attribute.
|
sl@0
|
202 |
|
sl@0
|
203 |
@return The font style's stroke weight. */
|
sl@0
|
204 |
{
|
sl@0
|
205 |
if(iFlags&EBold) return(EStrokeWeightBold);
|
sl@0
|
206 |
return(EStrokeWeightNormal);
|
sl@0
|
207 |
}
|
sl@0
|
208 |
|
sl@0
|
209 |
|
sl@0
|
210 |
EXPORT_C TFontPrintPosition TFontStyle::PrintPosition() const
|
sl@0
|
211 |
/** Gets the print position attribute.
|
sl@0
|
212 |
|
sl@0
|
213 |
@return The font style's print position. */
|
sl@0
|
214 |
{
|
sl@0
|
215 |
if((iFlags&ESuper) && !(iFlags&ESub)) return(EPrintPosSuperscript);
|
sl@0
|
216 |
else if((iFlags&ESub) && !(iFlags&ESuper)) return(EPrintPosSubscript);
|
sl@0
|
217 |
return(EPrintPosNormal);
|
sl@0
|
218 |
}
|
sl@0
|
219 |
|
sl@0
|
220 |
|
sl@0
|
221 |
EXPORT_C void TFontStyle::SetPosture(TFontPosture aPosture)
|
sl@0
|
222 |
/** Sets the posture attribute.
|
sl@0
|
223 |
|
sl@0
|
224 |
@param aPosture The posture to be set. */
|
sl@0
|
225 |
{
|
sl@0
|
226 |
if(aPosture==EPostureItalic) iFlags|=EItalic;
|
sl@0
|
227 |
else iFlags&=~EItalic;
|
sl@0
|
228 |
}
|
sl@0
|
229 |
|
sl@0
|
230 |
|
sl@0
|
231 |
EXPORT_C void TFontStyle::SetStrokeWeight(TFontStrokeWeight aStrokeWeight)
|
sl@0
|
232 |
/** Sets the stroke weight attribute.
|
sl@0
|
233 |
|
sl@0
|
234 |
@param aStrokeWeight The stroke weight to be set. */
|
sl@0
|
235 |
{
|
sl@0
|
236 |
if(aStrokeWeight==EStrokeWeightBold) iFlags|=EBold;
|
sl@0
|
237 |
else iFlags&=~EBold;
|
sl@0
|
238 |
}
|
sl@0
|
239 |
|
sl@0
|
240 |
|
sl@0
|
241 |
EXPORT_C void TFontStyle::SetPrintPosition(TFontPrintPosition aPrintPosition)
|
sl@0
|
242 |
/** Sets the print position attribute.
|
sl@0
|
243 |
|
sl@0
|
244 |
@param aPrintPosition The print position to be set. */
|
sl@0
|
245 |
{
|
sl@0
|
246 |
switch(aPrintPosition)
|
sl@0
|
247 |
{
|
sl@0
|
248 |
case EPrintPosSuperscript:
|
sl@0
|
249 |
{
|
sl@0
|
250 |
iFlags|=ESuper;
|
sl@0
|
251 |
iFlags&=~ESub;
|
sl@0
|
252 |
break;
|
sl@0
|
253 |
}
|
sl@0
|
254 |
case EPrintPosSubscript:
|
sl@0
|
255 |
{
|
sl@0
|
256 |
iFlags&=~ESuper;
|
sl@0
|
257 |
iFlags|=ESub;
|
sl@0
|
258 |
break;
|
sl@0
|
259 |
}
|
sl@0
|
260 |
default:
|
sl@0
|
261 |
{
|
sl@0
|
262 |
iFlags&=~ESuper;
|
sl@0
|
263 |
iFlags&=~ESub;
|
sl@0
|
264 |
}
|
sl@0
|
265 |
}
|
sl@0
|
266 |
}
|
sl@0
|
267 |
|
sl@0
|
268 |
/** Gets the font effects flags.
|
sl@0
|
269 |
@publishedAll
|
sl@0
|
270 |
@released
|
sl@0
|
271 |
@return The font effects flags.
|
sl@0
|
272 |
@see TFontStyle::SetEffects()
|
sl@0
|
273 |
*/
|
sl@0
|
274 |
EXPORT_C TUint32 TFontStyle::Effects() const
|
sl@0
|
275 |
{
|
sl@0
|
276 |
return 0xFFF0 & iFlags;
|
sl@0
|
277 |
}
|
sl@0
|
278 |
|
sl@0
|
279 |
/** Checks if a font effect is on.
|
sl@0
|
280 |
@publishedAll
|
sl@0
|
281 |
@released
|
sl@0
|
282 |
@return True represents the specified font effect is on, otherwise off.
|
sl@0
|
283 |
@param aEffect The font effect to be checked.
|
sl@0
|
284 |
@see TFontStyle::SetEffects()
|
sl@0
|
285 |
*/
|
sl@0
|
286 |
EXPORT_C TBool TFontStyle::IsEffectOn(FontEffect::TEffect aEffect) const
|
sl@0
|
287 |
{
|
sl@0
|
288 |
return FontEffect::IsEffectOn(aEffect, iFlags);
|
sl@0
|
289 |
}
|
sl@0
|
290 |
|
sl@0
|
291 |
/** Sets the font effects flags.
|
sl@0
|
292 |
@publishedAll
|
sl@0
|
293 |
@released
|
sl@0
|
294 |
@param aEffect The font effects flags to be set.
|
sl@0
|
295 |
@see TFontStyle::Effects()
|
sl@0
|
296 |
*/
|
sl@0
|
297 |
EXPORT_C void TFontStyle::SetEffects(TUint32 aEffects)
|
sl@0
|
298 |
{
|
sl@0
|
299 |
iFlags &= 0xFFFF000F;
|
sl@0
|
300 |
iFlags |= 0xFFF0 & aEffects;
|
sl@0
|
301 |
}
|
sl@0
|
302 |
|
sl@0
|
303 |
/** Sets a font effect to the given state.
|
sl@0
|
304 |
@publishedAll
|
sl@0
|
305 |
@released
|
sl@0
|
306 |
@param aEffect The font effect to be set.
|
sl@0
|
307 |
@param aOn True represents on, otherwise off.
|
sl@0
|
308 |
@see TFontStyle::IsEffectOn()
|
sl@0
|
309 |
*/
|
sl@0
|
310 |
EXPORT_C void TFontStyle::SetEffects(FontEffect::TEffect aEffect, TBool aOn)
|
sl@0
|
311 |
{
|
sl@0
|
312 |
FontEffect::SetEffect(aEffect, aOn, iFlags);
|
sl@0
|
313 |
}
|
sl@0
|
314 |
|
sl@0
|
315 |
/** Compares a font style for equality.
|
sl@0
|
316 |
@publishedAll
|
sl@0
|
317 |
@released
|
sl@0
|
318 |
@param aFontStyle The font style to be compared with this font style.
|
sl@0
|
319 |
@return ETrue, if this TFontStyle is equal to aFontStyle, EFalse, otherwise.
|
sl@0
|
320 |
*/
|
sl@0
|
321 |
EXPORT_C TBool TFontStyle::operator==(const TFontStyle& aFontStyle) const
|
sl@0
|
322 |
{
|
sl@0
|
323 |
return iFlags == aFontStyle.iFlags;
|
sl@0
|
324 |
}
|
sl@0
|
325 |
|
sl@0
|
326 |
//
|
sl@0
|
327 |
// TFontSpec
|
sl@0
|
328 |
//
|
sl@0
|
329 |
EXPORT_C TFontSpec::TFontSpec():
|
sl@0
|
330 |
iTypeface(),
|
sl@0
|
331 |
iHeight(0),
|
sl@0
|
332 |
iFontStyle()
|
sl@0
|
333 |
/** Default constructor.
|
sl@0
|
334 |
|
sl@0
|
335 |
The object's font style is set to the default: EPostureUpright, EStrokeWeightNormal,
|
sl@0
|
336 |
and EPrintPosNormal. */
|
sl@0
|
337 |
{}
|
sl@0
|
338 |
|
sl@0
|
339 |
|
sl@0
|
340 |
EXPORT_C TFontSpec::TFontSpec(const TDesC& aTypefaceName,TInt aHeight):
|
sl@0
|
341 |
iTypeface(),
|
sl@0
|
342 |
iHeight(aHeight),
|
sl@0
|
343 |
iFontStyle(EPostureUpright,EStrokeWeightNormal,EPrintPosNormal)
|
sl@0
|
344 |
/** Constructs a TFontSpec object with the specified typeface and height.
|
sl@0
|
345 |
|
sl@0
|
346 |
The object's font style is set to the default: EPostureUpright, EStrokeWeightNormal,
|
sl@0
|
347 |
and EPrintPosNormal.
|
sl@0
|
348 |
|
sl@0
|
349 |
@param aTypefaceName The name of the typeface (e.g. "Roman"). It should be no
|
sl@0
|
350 |
longer than KMaxTypefaceNameLength characters in length.
|
sl@0
|
351 |
@param aHeight The height of the typeface, in twips.
|
sl@0
|
352 |
@panic GDI 6, if aTypefaceName is more than KMaxTypefaceNameLength characters long.
|
sl@0
|
353 |
*/
|
sl@0
|
354 |
{
|
sl@0
|
355 |
iTypeface.SetName(aTypefaceName);
|
sl@0
|
356 |
}
|
sl@0
|
357 |
|
sl@0
|
358 |
|
sl@0
|
359 |
EXPORT_C TBool TFontSpec::operator==(const TFontSpec& aFontSpec) const
|
sl@0
|
360 |
/** Compares this font specification with another.
|
sl@0
|
361 |
@param aFontSpec The font specification to be compared with this one.
|
sl@0
|
362 |
@return ETrue, if the TFontSpecs are identical, EFalse otherwise.
|
sl@0
|
363 |
*/
|
sl@0
|
364 |
{
|
sl@0
|
365 |
return
|
sl@0
|
366 |
iHeight == aFontSpec.iHeight &&
|
sl@0
|
367 |
iFontStyle == aFontSpec.iFontStyle &&
|
sl@0
|
368 |
iTypeface == aFontSpec.iTypeface;
|
sl@0
|
369 |
}
|
sl@0
|
370 |
|
sl@0
|
371 |
|
sl@0
|
372 |
EXPORT_C void TFontSpec::InternalizeL(RReadStream& aStream)
|
sl@0
|
373 |
/** Internalises a font specification from a read stream.
|
sl@0
|
374 |
|
sl@0
|
375 |
The presence of this function means that the standard templated operator>>()
|
sl@0
|
376 |
(defined in s32strm.h) is available to internalise objects of this class.
|
sl@0
|
377 |
|
sl@0
|
378 |
@param aStream The stream from which the font specification is to be internalised.
|
sl@0
|
379 |
@leave KErrNoMemory If internalisation causes an out of memory error. */
|
sl@0
|
380 |
{
|
sl@0
|
381 |
iTypeface.InternalizeL(aStream);
|
sl@0
|
382 |
iHeight=aStream.ReadUint16L();
|
sl@0
|
383 |
iFontStyle.InternalizeL(aStream);
|
sl@0
|
384 |
}
|
sl@0
|
385 |
|
sl@0
|
386 |
|
sl@0
|
387 |
EXPORT_C void TFontSpec::ExternalizeL(RWriteStream& aStream) const
|
sl@0
|
388 |
/** Externalises the font specification to a write stream.
|
sl@0
|
389 |
|
sl@0
|
390 |
The presence of this function means that the standard templated operator<<()
|
sl@0
|
391 |
(defined in s32strm.h) is available to externalise objects of this class.
|
sl@0
|
392 |
|
sl@0
|
393 |
@param aStream The stream to which the font specification is to be externalised
|
sl@0
|
394 |
|
sl@0
|
395 |
@leave KErrNoMemory If the write action causes the stream's resources to be
|
sl@0
|
396 |
exhausted. */
|
sl@0
|
397 |
{
|
sl@0
|
398 |
iTypeface.ExternalizeL(aStream);
|
sl@0
|
399 |
aStream.WriteUint16L(iHeight);
|
sl@0
|
400 |
iFontStyle.ExternalizeL(aStream);
|
sl@0
|
401 |
}
|
sl@0
|
402 |
|
sl@0
|
403 |
EXPORT_C void TFontSpec::SetScriptTypeForMetrics(TLanguage aLanguage)
|
sl@0
|
404 |
/** Specifies the script with which font metrics calculation will be based on.
|
sl@0
|
405 |
@param aLanguage The language used to derive the required script.
|
sl@0
|
406 |
@publishedAll
|
sl@0
|
407 |
@released
|
sl@0
|
408 |
*/
|
sl@0
|
409 |
{
|
sl@0
|
410 |
iTypeface.SetScriptTypeForMetrics(aLanguage);
|
sl@0
|
411 |
}
|
sl@0
|
412 |
|
sl@0
|
413 |
EXPORT_C TInt TFontSpec::ScriptTypeForMetrics() const
|
sl@0
|
414 |
/** Returns the script with which font metrics calculation will be based on.
|
sl@0
|
415 |
@internalTechnology
|
sl@0
|
416 |
*/
|
sl@0
|
417 |
{
|
sl@0
|
418 |
return iTypeface.ScriptTypeForMetrics();
|
sl@0
|
419 |
}
|
sl@0
|
420 |
|
sl@0
|
421 |
//
|
sl@0
|
422 |
// TTypeface
|
sl@0
|
423 |
//
|
sl@0
|
424 |
static const TInt KTTypefaceBitsNumAttrib = 3;
|
sl@0
|
425 |
static const TInt KTTypefaceBitsNumScript = 4;
|
sl@0
|
426 |
static const TInt KTTypefaceMaskAttrib = (1 << KTTypefaceBitsNumAttrib) - 1;
|
sl@0
|
427 |
static const TInt KTTypefaceMaskScript = ((1 << KTTypefaceBitsNumScript) - 1) << KTTypefaceBitsNumAttrib;
|
sl@0
|
428 |
EXPORT_C TTypeface::TTypeface():
|
sl@0
|
429 |
iName(),
|
sl@0
|
430 |
iFlags(0)
|
sl@0
|
431 |
/** Default C++ constructor. */
|
sl@0
|
432 |
{}
|
sl@0
|
433 |
|
sl@0
|
434 |
/**
|
sl@0
|
435 |
@internalComponent
|
sl@0
|
436 |
*/
|
sl@0
|
437 |
void TTypeface::ResetAttributes()
|
sl@0
|
438 |
{
|
sl@0
|
439 |
iFlags &= KTTypefaceMaskScript;
|
sl@0
|
440 |
}
|
sl@0
|
441 |
|
sl@0
|
442 |
/**
|
sl@0
|
443 |
@internalComponent
|
sl@0
|
444 |
*/
|
sl@0
|
445 |
void TTypeface::ResetScriptType()
|
sl@0
|
446 |
{
|
sl@0
|
447 |
iFlags &= KTTypefaceMaskAttrib;
|
sl@0
|
448 |
}
|
sl@0
|
449 |
|
sl@0
|
450 |
EXPORT_C void TTypeface::InternalizeL(RReadStream& aStream)
|
sl@0
|
451 |
/** Internalises a typeface from a read stream.
|
sl@0
|
452 |
|
sl@0
|
453 |
The presence of this function means that the standard templated operator>>()
|
sl@0
|
454 |
(defined in s32strm.h) is available to internalise objects of this class.
|
sl@0
|
455 |
|
sl@0
|
456 |
@param aStream Stream from which the typeface is to be internalised. */
|
sl@0
|
457 |
{
|
sl@0
|
458 |
TBuf<KMaxTypefaceNameLength> tempname;
|
sl@0
|
459 |
aStream >> tempname;
|
sl@0
|
460 |
new(&iName) TBufC<KMaxTypefaceNameLength>(tempname);
|
sl@0
|
461 |
iFlags = aStream.ReadInt8L();
|
sl@0
|
462 |
}
|
sl@0
|
463 |
|
sl@0
|
464 |
|
sl@0
|
465 |
EXPORT_C void TTypeface::ExternalizeL(RWriteStream& aStream) const
|
sl@0
|
466 |
/** Externalises a typeface to a write stream.
|
sl@0
|
467 |
|
sl@0
|
468 |
The presence of this function means that the standard templated operator<<()
|
sl@0
|
469 |
(defined in s32strm.h) is available to externalise objects of this class.
|
sl@0
|
470 |
|
sl@0
|
471 |
@param aStream The stream to which the typeface is to be externalised. */
|
sl@0
|
472 |
{
|
sl@0
|
473 |
aStream << iName;
|
sl@0
|
474 |
aStream.WriteInt8L(static_cast<TInt8>(iFlags));
|
sl@0
|
475 |
}
|
sl@0
|
476 |
|
sl@0
|
477 |
|
sl@0
|
478 |
EXPORT_C TBool TTypeface::operator==(const TTypeface& aTypeface) const
|
sl@0
|
479 |
/** Compares two typefaces for equality.
|
sl@0
|
480 |
|
sl@0
|
481 |
@param aTypeface The typeface to be compared with.
|
sl@0
|
482 |
@return ETrue, if this TTypeface is equal to aTypeface, otherwise EFalse. */
|
sl@0
|
483 |
{
|
sl@0
|
484 |
return
|
sl@0
|
485 |
iFlags == aTypeface.iFlags &&
|
sl@0
|
486 |
iName == aTypeface.iName;
|
sl@0
|
487 |
}
|
sl@0
|
488 |
|
sl@0
|
489 |
EXPORT_C void TTypeface::SetAttributes(TInt aAttributes)
|
sl@0
|
490 |
/** Set the combination of attributes for this typeface.
|
sl@0
|
491 |
|
sl@0
|
492 |
@param aAttributes A bitmap defining the combination of attributes. */
|
sl@0
|
493 |
{
|
sl@0
|
494 |
ResetAttributes();
|
sl@0
|
495 |
iFlags |= KTTypefaceMaskAttrib & aAttributes & (EProportional | ESerif | ESymbol);
|
sl@0
|
496 |
}
|
sl@0
|
497 |
|
sl@0
|
498 |
|
sl@0
|
499 |
EXPORT_C void TTypeface::SetIsProportional(TBool aIsProportional)
|
sl@0
|
500 |
/** Sets the typeface's proportional attribute.
|
sl@0
|
501 |
|
sl@0
|
502 |
@param aIsProportional ETrue if the typeface is a proportional typeface, otherwise
|
sl@0
|
503 |
EFalse. */
|
sl@0
|
504 |
{
|
sl@0
|
505 |
if (aIsProportional)
|
sl@0
|
506 |
{
|
sl@0
|
507 |
iFlags |= EProportional;
|
sl@0
|
508 |
}
|
sl@0
|
509 |
else
|
sl@0
|
510 |
{
|
sl@0
|
511 |
iFlags &= ~EProportional;
|
sl@0
|
512 |
}
|
sl@0
|
513 |
}
|
sl@0
|
514 |
|
sl@0
|
515 |
|
sl@0
|
516 |
EXPORT_C void TTypeface::SetIsSerif(TBool aIsSerif)
|
sl@0
|
517 |
/** Sets the typeface's serif attribute.
|
sl@0
|
518 |
|
sl@0
|
519 |
@param aIsSerif ETrue if the typeface is a serif typeface, otherwise EFalse. */
|
sl@0
|
520 |
{
|
sl@0
|
521 |
if (aIsSerif)
|
sl@0
|
522 |
{
|
sl@0
|
523 |
iFlags |= ESerif;
|
sl@0
|
524 |
}
|
sl@0
|
525 |
else
|
sl@0
|
526 |
{
|
sl@0
|
527 |
iFlags &= ~ESerif;
|
sl@0
|
528 |
}
|
sl@0
|
529 |
}
|
sl@0
|
530 |
|
sl@0
|
531 |
|
sl@0
|
532 |
EXPORT_C void TTypeface::SetIsSymbol(TBool aIsSymbol)
|
sl@0
|
533 |
/** Sets the typeface's symbol attribute.
|
sl@0
|
534 |
|
sl@0
|
535 |
@param aIsSymbol ETrue if the typeface is a symbol typeface, otherwise EFalse. */
|
sl@0
|
536 |
{
|
sl@0
|
537 |
if (aIsSymbol)
|
sl@0
|
538 |
{
|
sl@0
|
539 |
iFlags |= ESymbol;
|
sl@0
|
540 |
}
|
sl@0
|
541 |
else
|
sl@0
|
542 |
{
|
sl@0
|
543 |
iFlags &= ~ESymbol;
|
sl@0
|
544 |
}
|
sl@0
|
545 |
}
|
sl@0
|
546 |
|
sl@0
|
547 |
|
sl@0
|
548 |
EXPORT_C TInt TTypeface::Attributes() const
|
sl@0
|
549 |
/** Gets the combination of attributes of the typeface.
|
sl@0
|
550 |
|
sl@0
|
551 |
@return The combination of attributes of the typeface. */
|
sl@0
|
552 |
{
|
sl@0
|
553 |
return KTTypefaceMaskAttrib & iFlags;
|
sl@0
|
554 |
}
|
sl@0
|
555 |
|
sl@0
|
556 |
|
sl@0
|
557 |
EXPORT_C TBool TTypeface::IsProportional() const
|
sl@0
|
558 |
/** Gets the typeface's proportional attribute.
|
sl@0
|
559 |
|
sl@0
|
560 |
@return ETrue if the typeface is proportional, EFalse otherwise. */
|
sl@0
|
561 |
{
|
sl@0
|
562 |
return KTTypefaceMaskAttrib & iFlags & EProportional;
|
sl@0
|
563 |
}
|
sl@0
|
564 |
|
sl@0
|
565 |
|
sl@0
|
566 |
EXPORT_C TBool TTypeface::IsSerif() const
|
sl@0
|
567 |
/** Gets the typeface's serif attribute.
|
sl@0
|
568 |
|
sl@0
|
569 |
@return ETrue if the typeface is a serif typeface, EFalse otherwise */
|
sl@0
|
570 |
{
|
sl@0
|
571 |
return KTTypefaceMaskAttrib & iFlags & ESerif;
|
sl@0
|
572 |
}
|
sl@0
|
573 |
|
sl@0
|
574 |
|
sl@0
|
575 |
EXPORT_C TBool TTypeface::IsSymbol() const
|
sl@0
|
576 |
/** Gets the typeface's symbol attribute.
|
sl@0
|
577 |
|
sl@0
|
578 |
@return ETrue if the typeface is a symbol typeface, EFalse otherwise */
|
sl@0
|
579 |
{
|
sl@0
|
580 |
return KTTypefaceMaskAttrib & iFlags & ESymbol;
|
sl@0
|
581 |
}
|
sl@0
|
582 |
|
sl@0
|
583 |
|
sl@0
|
584 |
/** Specifies the script with which font metrics calculation will be based on.
|
sl@0
|
585 |
@param aLanguage The language used to derive the required script.
|
sl@0
|
586 |
@internalTechnology
|
sl@0
|
587 |
*/
|
sl@0
|
588 |
EXPORT_C void TTypeface::SetScriptTypeForMetrics(TLanguage aLanguage)
|
sl@0
|
589 |
{
|
sl@0
|
590 |
SetScriptTypeForMetrics(GlyphSample::TLanguage2TScript(aLanguage));
|
sl@0
|
591 |
}
|
sl@0
|
592 |
|
sl@0
|
593 |
/** Specifies the script with which font metrics calculation will be based on.
|
sl@0
|
594 |
@param aScript The script.
|
sl@0
|
595 |
@internalTechnology
|
sl@0
|
596 |
*/
|
sl@0
|
597 |
EXPORT_C void TTypeface::SetScriptTypeForMetrics(TInt aScript)
|
sl@0
|
598 |
{
|
sl@0
|
599 |
ResetScriptType();
|
sl@0
|
600 |
iFlags |= KTTypefaceMaskScript & (aScript << KTTypefaceBitsNumAttrib);
|
sl@0
|
601 |
}
|
sl@0
|
602 |
|
sl@0
|
603 |
/** Gets the script with which font metrics calculation will be based on.
|
sl@0
|
604 |
@return The script.
|
sl@0
|
605 |
@internalTechnology
|
sl@0
|
606 |
*/
|
sl@0
|
607 |
EXPORT_C TInt TTypeface::ScriptTypeForMetrics() const
|
sl@0
|
608 |
{
|
sl@0
|
609 |
return (KTTypefaceMaskScript & iFlags) >> KTTypefaceBitsNumAttrib;
|
sl@0
|
610 |
}
|
sl@0
|
611 |
|
sl@0
|
612 |
/**
|
sl@0
|
613 |
Sets the name of the typeface. This method should be used rather than
|
sl@0
|
614 |
directly accessing the iName public member.
|
sl@0
|
615 |
@param aName The name of the typeface (e.g. "Roman"). It should be no
|
sl@0
|
616 |
longer than KMaxTypefaceNameLength characters in length.
|
sl@0
|
617 |
@panic GDI 6, if aName is more than KMaxTypefaceNameLength characters
|
sl@0
|
618 |
long.
|
sl@0
|
619 |
*/
|
sl@0
|
620 |
EXPORT_C void TTypeface::SetName(const TDesC& aName)
|
sl@0
|
621 |
{
|
sl@0
|
622 |
GDI_ASSERT_ALWAYS(aName.Length() <= KMaxTypefaceNameLength, EGdiPanic_TypefaceNameOverflow);
|
sl@0
|
623 |
iName=aName;
|
sl@0
|
624 |
}
|
sl@0
|
625 |
|
sl@0
|
626 |
/**
|
sl@0
|
627 |
Returns the name of the typeface.
|
sl@0
|
628 |
@return The name of the typeface.
|
sl@0
|
629 |
*/
|
sl@0
|
630 |
EXPORT_C const TDesC& TTypeface::Name() const
|
sl@0
|
631 |
{
|
sl@0
|
632 |
return iName;
|
sl@0
|
633 |
}
|
sl@0
|
634 |
|
sl@0
|
635 |
|
sl@0
|
636 |
//
|
sl@0
|
637 |
// CFont
|
sl@0
|
638 |
//
|
sl@0
|
639 |
|
sl@0
|
640 |
/** Default destructor. */
|
sl@0
|
641 |
EXPORT_C CFont::~CFont()
|
sl@0
|
642 |
{}
|
sl@0
|
643 |
|
sl@0
|
644 |
_LIT(KGdiZeroCharacter,"0");
|
sl@0
|
645 |
|
sl@0
|
646 |
/** Gets the width of the zero character of this font in pixels.
|
sl@0
|
647 |
|
sl@0
|
648 |
This function is provided as the "0" character is roughly the average width
|
sl@0
|
649 |
of the characters of any font.
|
sl@0
|
650 |
|
sl@0
|
651 |
@return The width of the "0" character, in pixels. */
|
sl@0
|
652 |
EXPORT_C TInt CFont::WidthZeroInPixels() const
|
sl@0
|
653 |
{
|
sl@0
|
654 |
return(TextWidthInPixels(KGdiZeroCharacter));
|
sl@0
|
655 |
}
|
sl@0
|
656 |
|
sl@0
|
657 |
|
sl@0
|
658 |
/** Gets the font descent in pixels.
|
sl@0
|
659 |
It is defined to be HeightInPixels() minus AscentInPixels().
|
sl@0
|
660 |
Note that this deprecated function is replaced by the new @c FontMaxDescent()
|
sl@0
|
661 |
or in some cases @c FontStandardDescent().
|
sl@0
|
662 |
|
sl@0
|
663 |
@return The font descent in pixels.
|
sl@0
|
664 |
@see FontStandardDescent()
|
sl@0
|
665 |
@see FontMaxDescent()
|
sl@0
|
666 |
@deprecated */
|
sl@0
|
667 |
EXPORT_C TInt CFont::DoDescentInPixels() const
|
sl@0
|
668 |
{
|
sl@0
|
669 |
return HeightInPixels() - AscentInPixels();
|
sl@0
|
670 |
}
|
sl@0
|
671 |
|
sl@0
|
672 |
|
sl@0
|
673 |
/** Checks to see if the pen position needs to be included in the bounds
|
sl@0
|
674 |
calculation for purposes of considering side-bearings in the line break point
|
sl@0
|
675 |
|
sl@0
|
676 |
@param aInput The input block. Contains the check flag and maxbounds.
|
sl@0
|
677 |
@param aPenPos The current value of the pen position.
|
sl@0
|
678 |
@param aBoundsBR Bottom-right bounds value.
|
sl@0
|
679 |
@param aBoundsTL Top-left bounds value.
|
sl@0
|
680 |
@return Whether or not MaxBounds has been exceeded
|
sl@0
|
681 |
*/
|
sl@0
|
682 |
LOCAL_C TBool BoundsExceeded(const CFont::TMeasureTextInput& aInput,
|
sl@0
|
683 |
const TInt& aPenPos, TInt& aBoundsBR, TInt& aBoundsTL)
|
sl@0
|
684 |
{
|
sl@0
|
685 |
if (aInput.iFlags & CFont::TMeasureTextInput::EFIncludePenPositionInBoundsCheck)
|
sl@0
|
686 |
{
|
sl@0
|
687 |
if (aInput.iFlags & CFont::TMeasureTextInput::EFVisualOrderRightToLeft)
|
sl@0
|
688 |
{
|
sl@0
|
689 |
aBoundsTL = Min(aBoundsTL, aPenPos);
|
sl@0
|
690 |
}
|
sl@0
|
691 |
else
|
sl@0
|
692 |
{
|
sl@0
|
693 |
aBoundsBR = Max(aBoundsBR, aPenPos);
|
sl@0
|
694 |
}
|
sl@0
|
695 |
}
|
sl@0
|
696 |
return (aBoundsBR - aBoundsTL > aInput.iMaxBounds);
|
sl@0
|
697 |
}
|
sl@0
|
698 |
|
sl@0
|
699 |
|
sl@0
|
700 |
/** Text measurement function.
|
sl@0
|
701 |
|
sl@0
|
702 |
This is a powerful text measurement function underlying all the
|
sl@0
|
703 |
other text measurement functions. It takes optional input and output
|
sl@0
|
704 |
parameter blocks, which may be null, and returns the advance
|
sl@0
|
705 |
width (change in pen position when drawn horizontally) of the text, or the advance
|
sl@0
|
706 |
height, if the text is drawn vertically.
|
sl@0
|
707 |
|
sl@0
|
708 |
Some of the functions that can be performed using this
|
sl@0
|
709 |
function are listed below. Many of them are used by the Text Views
|
sl@0
|
710 |
API to do its typographic layout.
|
sl@0
|
711 |
- Get the advance width or advance height (return value).
|
sl@0
|
712 |
The advance width is the amount by which the pen advances when drawing
|
sl@0
|
713 |
the text horizontally, while the advance height is the amount by which
|
sl@0
|
714 |
the pen advances when drawing the text vertically.
|
sl@0
|
715 |
- Measure some text in context, so that shaping behaviour
|
sl@0
|
716 |
(e.g. in Arabic) can be affected by what comes before and after the
|
sl@0
|
717 |
text. Do this using TMeasureTextInput::iStartInputChar and
|
sl@0
|
718 |
TMeasureTextInput::iEndInputChar to tell the function where to start and end
|
sl@0
|
719 |
in the supplied descriptor.
|
sl@0
|
720 |
- Determine how much text fits a given size by setting
|
sl@0
|
721 |
TMeasureTextInput::iMaxAdvance or TMeasureTextInput::iMaxBounds.
|
sl@0
|
722 |
- Specify letter spacing and word spacing using TMeasureTextInput::iCharJustNum,
|
sl@0
|
723 |
TMeasureTextInput::iCharJustExcess,
|
sl@0
|
724 |
TMeasureTextInput::iWordJustNum and
|
sl@0
|
725 |
TMeasureTextInput::iWordJustExcess.
|
sl@0
|
726 |
- Get the number of characters drawn in TMeasureTextOutput::iChars
|
sl@0
|
727 |
when applying the various constraints in TMeasureTextInput.
|
sl@0
|
728 |
- Get the number of glyphs drawn in TMeasureTextOutput::iGlyphs.
|
sl@0
|
729 |
- Get the number of groups (formed by ligation or diacritic placement) in
|
sl@0
|
730 |
TMeasureTextOutput::iGroups. Groups are units of cursor
|
sl@0
|
731 |
movement: the cursor hops over a character-plus-accent group or an
|
sl@0
|
732 |
Arabic or other ligature in one go.
|
sl@0
|
733 |
- Get the number of word spaces in TMeasureTextOutput::iSpaces.
|
sl@0
|
734 |
- Get the bounds of the inked-in pixels in TMeasureTextOutput::iBounds.
|
sl@0
|
735 |
- Get the size of the biggest glyph that would be drawn in TMeasureTextOutput::iMaxGlyphSize.
|
sl@0
|
736 |
|
sl@0
|
737 |
@param aText The text to be measured.
|
sl@0
|
738 |
@param aInput The input block. This may be NULL.
|
sl@0
|
739 |
@param aOutput The output block. This may be NULL.
|
sl@0
|
740 |
@return The advance width if the text is drawn horizontally or the advance
|
sl@0
|
741 |
height if the text is drawn vertically.
|
sl@0
|
742 |
|
sl@0
|
743 |
@panic GDI 1 In debug builds only, if TMeasureTextInput::iStartInputChar is negative.
|
sl@0
|
744 |
*/
|
sl@0
|
745 |
EXPORT_C TInt CFont::MeasureText(const TDesC& aText,const TMeasureTextInput* aInput,TMeasureTextOutput* aOutput) const
|
sl@0
|
746 |
{
|
sl@0
|
747 |
TMeasureTextInput input;
|
sl@0
|
748 |
if (aInput)
|
sl@0
|
749 |
input = *aInput;
|
sl@0
|
750 |
if (aOutput)
|
sl@0
|
751 |
{
|
sl@0
|
752 |
Mem::FillZ(aOutput,sizeof(*aOutput));
|
sl@0
|
753 |
aOutput->iChars = input.iStartInputChar;
|
sl@0
|
754 |
}
|
sl@0
|
755 |
TPositionParam param;
|
sl@0
|
756 |
param.iDirection = input.iDirection;
|
sl@0
|
757 |
|
sl@0
|
758 |
TBool vertical = param.iDirection == EVertical;
|
sl@0
|
759 |
TBool penMovesLeft = EFalse;
|
sl@0
|
760 |
if (input.iFlags & TMeasureTextInput::EFVisualOrderRightToLeft)
|
sl@0
|
761 |
{
|
sl@0
|
762 |
if (!vertical)
|
sl@0
|
763 |
penMovesLeft = ETrue;
|
sl@0
|
764 |
param.iFlags |= TPositionParam::EFLogicalOrder;
|
sl@0
|
765 |
}
|
sl@0
|
766 |
else if (!(input.iFlags & TMeasureTextInput::EFVisualOrder))
|
sl@0
|
767 |
param.iFlags |= TPositionParam::EFLogicalOrder;
|
sl@0
|
768 |
|
sl@0
|
769 |
|
sl@0
|
770 |
param.iText.Set(aText);
|
sl@0
|
771 |
|
sl@0
|
772 |
int advance = 0;
|
sl@0
|
773 |
int groups = 0;
|
sl@0
|
774 |
int spaces = 0;
|
sl@0
|
775 |
param.iPosInText = input.iStartInputChar;
|
sl@0
|
776 |
int end_char = Min(aText.Length(),input.iEndInputChar);
|
sl@0
|
777 |
TRect bounds;
|
sl@0
|
778 |
// Total advance if pen is moving left. Positive.
|
sl@0
|
779 |
TInt rightToLeftAdvance = 0;
|
sl@0
|
780 |
// Shaping information of the text
|
sl@0
|
781 |
RShapeInfo shapeInfo;
|
sl@0
|
782 |
while (param.iPosInText < end_char)
|
sl@0
|
783 |
{
|
sl@0
|
784 |
if (!GetCharacterPosition2(param, shapeInfo))
|
sl@0
|
785 |
{
|
sl@0
|
786 |
if (aOutput)
|
sl@0
|
787 |
aOutput->iChars = param.iPosInText;
|
sl@0
|
788 |
continue;
|
sl@0
|
789 |
}
|
sl@0
|
790 |
|
sl@0
|
791 |
int new_advance = vertical ? param.iPen.iY : param.iPen.iX;
|
sl@0
|
792 |
if (input.iCharJustExcess != 0)
|
sl@0
|
793 |
new_advance += CGraphicsContext::JustificationInPixels(input.iCharJustExcess,input.iCharJustNum,groups,1);
|
sl@0
|
794 |
groups++;
|
sl@0
|
795 |
// Allow justification to occur at spaces
|
sl@0
|
796 |
if (param.iOutput[0].iCode == 0x0020)
|
sl@0
|
797 |
{
|
sl@0
|
798 |
if (input.iWordJustExcess != 0)
|
sl@0
|
799 |
new_advance += CGraphicsContext::JustificationInPixels(input.iWordJustExcess,input.iWordJustNum,spaces,1);
|
sl@0
|
800 |
spaces++;
|
sl@0
|
801 |
}
|
sl@0
|
802 |
if (vertical)
|
sl@0
|
803 |
param.iPen.iY = new_advance;
|
sl@0
|
804 |
else
|
sl@0
|
805 |
param.iPen.iX = new_advance;
|
sl@0
|
806 |
|
sl@0
|
807 |
if (penMovesLeft)
|
sl@0
|
808 |
{
|
sl@0
|
809 |
// If the pen is moving left, we will begin each cluster at (0,0)
|
sl@0
|
810 |
// and shift the bounds to the right to compensate.
|
sl@0
|
811 |
bounds.iTl.iX += param.iPen.iX;
|
sl@0
|
812 |
bounds.iBr.iX += param.iPen.iX;
|
sl@0
|
813 |
bounds.iTl.iY += param.iPen.iY;
|
sl@0
|
814 |
bounds.iBr.iY += param.iPen.iY;
|
sl@0
|
815 |
rightToLeftAdvance += param.iPen.iX;
|
sl@0
|
816 |
new_advance = rightToLeftAdvance;
|
sl@0
|
817 |
param.iPen.iX = 0;
|
sl@0
|
818 |
param.iPen.iY = 0;
|
sl@0
|
819 |
}
|
sl@0
|
820 |
|
sl@0
|
821 |
if (aInput || aOutput)
|
sl@0
|
822 |
{
|
sl@0
|
823 |
const TPositionParam::TOutput* output = param.iOutput;
|
sl@0
|
824 |
for (int i = 0; i < param.iOutputGlyphs; i++, output++)
|
sl@0
|
825 |
{
|
sl@0
|
826 |
//if (!output->iBounds.IsEmpty()) -- optimized to:
|
sl@0
|
827 |
if (output->iBounds.iTl.iX != output->iBounds.iBr.iX
|
sl@0
|
828 |
|| output->iBounds.iTl.iY != output->iBounds.iBr.iY)
|
sl@0
|
829 |
{
|
sl@0
|
830 |
if (aOutput)
|
sl@0
|
831 |
{
|
sl@0
|
832 |
// increase iMaxGlyphSize if either dimension smaller than
|
sl@0
|
833 |
// current glyph
|
sl@0
|
834 |
TInt boundsDim = output->iBounds.iBr.iX - output->iBounds.iTl.iX;
|
sl@0
|
835 |
aOutput->iMaxGlyphSize.iWidth = aOutput->iMaxGlyphSize.iWidth < boundsDim?
|
sl@0
|
836 |
boundsDim : aOutput->iMaxGlyphSize.iWidth;
|
sl@0
|
837 |
boundsDim = output->iBounds.iBr.iY - output->iBounds.iTl.iY;
|
sl@0
|
838 |
aOutput->iMaxGlyphSize.iHeight = aOutput->iMaxGlyphSize.iHeight < boundsDim?
|
sl@0
|
839 |
boundsDim : aOutput->iMaxGlyphSize.iHeight;
|
sl@0
|
840 |
}
|
sl@0
|
841 |
//bounds.BoundingRect(output->iBounds); -- optimized to:
|
sl@0
|
842 |
if (output->iBounds.iTl.iX < bounds.iTl.iX)
|
sl@0
|
843 |
bounds.iTl.iX = output->iBounds.iTl.iX;
|
sl@0
|
844 |
if (bounds.iBr.iX < output->iBounds.iBr.iX)
|
sl@0
|
845 |
bounds.iBr.iX = output->iBounds.iBr.iX;
|
sl@0
|
846 |
if (output->iBounds.iTl.iY < bounds.iTl.iY)
|
sl@0
|
847 |
bounds.iTl.iY = output->iBounds.iTl.iY;
|
sl@0
|
848 |
if (bounds.iBr.iY < output->iBounds.iBr.iY)
|
sl@0
|
849 |
bounds.iBr.iY = output->iBounds.iBr.iY;
|
sl@0
|
850 |
}
|
sl@0
|
851 |
}
|
sl@0
|
852 |
|
sl@0
|
853 |
// Would any limits be exceeded by adding this group?
|
sl@0
|
854 |
if (param.iPosInText > end_char)
|
sl@0
|
855 |
break;
|
sl@0
|
856 |
if (new_advance > input.iMaxAdvance)
|
sl@0
|
857 |
break;
|
sl@0
|
858 |
if (vertical)
|
sl@0
|
859 |
{
|
sl@0
|
860 |
if (BoundsExceeded(input, param.iPen.iY, bounds.iBr.iY, bounds.iTl.iY))
|
sl@0
|
861 |
break;
|
sl@0
|
862 |
}
|
sl@0
|
863 |
else
|
sl@0
|
864 |
{
|
sl@0
|
865 |
if (BoundsExceeded(input, param.iPen.iX, bounds.iBr.iX, bounds.iTl.iX))
|
sl@0
|
866 |
break;
|
sl@0
|
867 |
}
|
sl@0
|
868 |
|
sl@0
|
869 |
if (aOutput)
|
sl@0
|
870 |
{
|
sl@0
|
871 |
aOutput->iChars = param.iPosInText; // should this not be aOutput->iChars = param.iPosInText - input.iShartInputChar;?
|
sl@0
|
872 |
aOutput->iGlyphs += param.iOutputGlyphs;
|
sl@0
|
873 |
aOutput->iGroups = groups;
|
sl@0
|
874 |
aOutput->iSpaces = spaces;
|
sl@0
|
875 |
aOutput->iBounds = bounds;
|
sl@0
|
876 |
}
|
sl@0
|
877 |
}
|
sl@0
|
878 |
|
sl@0
|
879 |
advance = new_advance;
|
sl@0
|
880 |
}
|
sl@0
|
881 |
if(shapeInfo.IsOpen())
|
sl@0
|
882 |
shapeInfo.Close();
|
sl@0
|
883 |
return advance;
|
sl@0
|
884 |
}
|
sl@0
|
885 |
|
sl@0
|
886 |
// These 3 functions should probably be moved to E32/Euser as part of TChar or
|
sl@0
|
887 |
// similar as there seem to be several local copies of similar functions in
|
sl@0
|
888 |
// various OS modules so we should remove duplication
|
sl@0
|
889 |
|
sl@0
|
890 |
TUint16 HighSurrogate(TUint aCode)
|
sl@0
|
891 |
{
|
sl@0
|
892 |
GDI_ASSERT_DEBUG(aCode > 0xFFFF, EGdiPanic_InvalidInputParam);
|
sl@0
|
893 |
return STATIC_CAST(TUint16, 0xD7C0 + (aCode >> 10));
|
sl@0
|
894 |
}
|
sl@0
|
895 |
|
sl@0
|
896 |
TUint16 LowSurrogate(TUint aCode)
|
sl@0
|
897 |
{
|
sl@0
|
898 |
GDI_ASSERT_DEBUG(aCode > 0xFFFF, EGdiPanic_InvalidInputParam);
|
sl@0
|
899 |
return STATIC_CAST(TUint16, 0xDC00 | (aCode & 0x3FF));
|
sl@0
|
900 |
}
|
sl@0
|
901 |
|
sl@0
|
902 |
TUint CombineSurrogates(TUint aHighSurrogate, TUint aLowSurrogate)
|
sl@0
|
903 |
{
|
sl@0
|
904 |
GDI_ASSERT_DEBUG((0xD800 == (aHighSurrogate & 0xF800)), EGdiPanic_InvalidInputParam);
|
sl@0
|
905 |
GDI_ASSERT_DEBUG((0xD800 == (aHighSurrogate & 0xFC00)), EGdiPanic_InvalidInputParam);
|
sl@0
|
906 |
GDI_ASSERT_DEBUG((0xDC00 == (aLowSurrogate & 0xFC00)), EGdiPanic_InvalidInputParam);
|
sl@0
|
907 |
return ((aHighSurrogate - 0xD7F7) << 10) + aLowSurrogate;
|
sl@0
|
908 |
}
|
sl@0
|
909 |
|
sl@0
|
910 |
|
sl@0
|
911 |
/** Overridable function innards of GetCharacterPosition and
|
sl@0
|
912 |
GetCharacterPosition2. It is generally not useful to override this function.
|
sl@0
|
913 |
@publishedAll
|
sl@0
|
914 |
@see GetCharacterPosition
|
sl@0
|
915 |
@see GetCharacterPosition2
|
sl@0
|
916 |
*/
|
sl@0
|
917 |
EXPORT_C TBool CFont::DoGetCharacterPosition(TPositionParam& aParam) const
|
sl@0
|
918 |
{
|
sl@0
|
919 |
RShapeInfo shapeInfo;
|
sl@0
|
920 |
TBool r = GetCharacterPosition2(aParam, shapeInfo);
|
sl@0
|
921 |
if (shapeInfo.IsOpen())
|
sl@0
|
922 |
shapeInfo.Close();
|
sl@0
|
923 |
return r;
|
sl@0
|
924 |
}
|
sl@0
|
925 |
|
sl@0
|
926 |
// Find the script (and hence the correct process function) that any punctuation or digit may belong to
|
sl@0
|
927 |
LOCAL_C GlyphSelection::ProcessFunc FindContextualProcessFunc(RShapeInfo& aShapeInfo, const TGlyphSelectionState aGss)
|
sl@0
|
928 |
{
|
sl@0
|
929 |
GlyphSelection::ProcessFunc processFunc = CharacterToProcessFunction(aGss.iCodeChar);
|
sl@0
|
930 |
GlyphSelection::ProcessFunc contextProcessFunc = (GlyphSelection::ProcessFunc)aShapeInfo.GetContext();
|
sl@0
|
931 |
|
sl@0
|
932 |
// If context or prevCode is NULL, use processFunc,
|
sl@0
|
933 |
// else use function of context or prevCode
|
sl@0
|
934 |
if ((aGss.iCodeChar.IsDigit() || aGss.iCodeChar.IsPunctuation()) && !QuoteOrBracketPair(aGss.iCodeChar) && processFunc!=GlyphSelector_SoftHyphen::Process)
|
sl@0
|
935 |
{
|
sl@0
|
936 |
// If context is not set, check the previous char for context.
|
sl@0
|
937 |
if (contextProcessFunc == NULL)
|
sl@0
|
938 |
{
|
sl@0
|
939 |
if (aGss.iParam.iPosInText > 0)
|
sl@0
|
940 |
{
|
sl@0
|
941 |
TChar prevCode = aGss.iText.Get(-1);
|
sl@0
|
942 |
GlyphSelection::ProcessFunc prevProcessFunc = CharacterToProcessFunction(prevCode);
|
sl@0
|
943 |
if (prevProcessFunc != NULL && (prevCode.IsAlpha() || prevProcessFunc != GlyphSelector_Default::Process))
|
sl@0
|
944 |
{
|
sl@0
|
945 |
aShapeInfo.SetContext((TAny *)prevProcessFunc);
|
sl@0
|
946 |
return prevProcessFunc;
|
sl@0
|
947 |
}
|
sl@0
|
948 |
}
|
sl@0
|
949 |
}
|
sl@0
|
950 |
else
|
sl@0
|
951 |
return contextProcessFunc;
|
sl@0
|
952 |
|
sl@0
|
953 |
return processFunc;
|
sl@0
|
954 |
}
|
sl@0
|
955 |
|
sl@0
|
956 |
// set the context with current processFunc only if current char is not ignored for context.
|
sl@0
|
957 |
if (processFunc != NULL && (aGss.iCodeChar.IsAlpha() || processFunc != GlyphSelector_Default::Process))
|
sl@0
|
958 |
aShapeInfo.SetContext((TAny *)processFunc);
|
sl@0
|
959 |
return processFunc;
|
sl@0
|
960 |
}
|
sl@0
|
961 |
|
sl@0
|
962 |
/** Takes Unicode text and produces the glyph cluster for the first character
|
sl@0
|
963 |
in that text plus any combining mark characters, or for the first indic
|
sl@0
|
964 |
syllable. It is responsible for contextual glyph selection, ligature creation
|
sl@0
|
965 |
and diacritic placement.
|
sl@0
|
966 |
|
sl@0
|
967 |
@param aParam
|
sl@0
|
968 |
The input/output parameter of the text/glyph data for the algorithm.
|
sl@0
|
969 |
@param aShapeInfo
|
sl@0
|
970 |
The function will cache "shaped" text (e.g. complex scripts such as
|
sl@0
|
971 |
Devanagari) here. aShapeInfo must be freshly-constructed or closed for each
|
sl@0
|
972 |
new piece of text in aParam.iText. If aParam.iText is unchanged between
|
sl@0
|
973 |
calls, aShapeInfo should be passed back in unchanged as well.
|
sl@0
|
974 |
@return
|
sl@0
|
975 |
ETrue if glyphs for supplied text have been produced, EFalse in failure.
|
sl@0
|
976 |
@see CFont::TPositionParam
|
sl@0
|
977 |
@publishedAll
|
sl@0
|
978 |
@released */
|
sl@0
|
979 |
EXPORT_C TBool CFont::GetCharacterPosition2(TPositionParam& aParam, RShapeInfo& aShapeInfo) const
|
sl@0
|
980 |
{
|
sl@0
|
981 |
GDI_ASSERT_DEBUG(aParam.iPosInText>=0, EGdiPanic_InvalidInputParam);
|
sl@0
|
982 |
GDI_ASSERT_DEBUG(aParam.iText.Ptr(), EGdiPanic_InvalidInputParam);
|
sl@0
|
983 |
|
sl@0
|
984 |
aParam.iOutputGlyphs = 0;
|
sl@0
|
985 |
TInt textLen = aParam.iText.Length();
|
sl@0
|
986 |
TBool outputOk = ETrue;
|
sl@0
|
987 |
TPoint penCopy = aParam.iPen;
|
sl@0
|
988 |
|
sl@0
|
989 |
// Verify input parameters are sane
|
sl@0
|
990 |
if (aParam.iPosInText >= textLen)
|
sl@0
|
991 |
return EFalse;
|
sl@0
|
992 |
|
sl@0
|
993 |
// Setup glyph selection algorithm data
|
sl@0
|
994 |
TUtf32Iterator textIter(aParam.iText.Ptr(), aParam.iText.Ptr()+textLen, aParam.iPosInText);
|
sl@0
|
995 |
if (textIter.AtEnd())
|
sl@0
|
996 |
{
|
sl@0
|
997 |
aParam.iPosInText = textIter.LengthToStart();
|
sl@0
|
998 |
return outputOk;
|
sl@0
|
999 |
}
|
sl@0
|
1000 |
|
sl@0
|
1001 |
// Process each character in the text in turn until we reach the end of
|
sl@0
|
1002 |
// the iterator, the next base (non-mark/combining) character or reach
|
sl@0
|
1003 |
// the limit in a glyph cluster.
|
sl@0
|
1004 |
GlyphSelection::ProcessFunc firstProcessFn = 0;
|
sl@0
|
1005 |
TGlyphSelectionState gss(textIter, this, aParam);
|
sl@0
|
1006 |
do
|
sl@0
|
1007 |
{
|
sl@0
|
1008 |
// Retrieve character info for processing.
|
sl@0
|
1009 |
gss.iCodePt = gss.iCodeChar = textIter.Get();
|
sl@0
|
1010 |
gss.iCombCls = gss.iCodeChar.GetCombiningClass();
|
sl@0
|
1011 |
gss.iCats = gss.iCodeChar.GetCategory();
|
sl@0
|
1012 |
gss.iClusterState = TGlyphSelectionState::EGClusterNotComplete;
|
sl@0
|
1013 |
gss.iPen = TGlyphSelectionState::EPenAdvance_No;
|
sl@0
|
1014 |
|
sl@0
|
1015 |
// Find the correct processesing function for the script being used.
|
sl@0
|
1016 |
// If gss.iCodePt is a strongly directional character, then simply map it in TTableEntry Table[]
|
sl@0
|
1017 |
// and use the returned process function pointer.
|
sl@0
|
1018 |
// If gss.iCodePt is a punctuation or a digit, then use a context character in the text (if
|
sl@0
|
1019 |
// available) to find the contextual script being rendered and use its process function pointer.
|
sl@0
|
1020 |
GlyphSelection::ProcessFunc processFn = FindContextualProcessFunc(aShapeInfo, gss);
|
sl@0
|
1021 |
|
sl@0
|
1022 |
if (!firstProcessFn)
|
sl@0
|
1023 |
firstProcessFn = processFn;
|
sl@0
|
1024 |
|
sl@0
|
1025 |
if (processFn)
|
sl@0
|
1026 |
{
|
sl@0
|
1027 |
if (firstProcessFn == processFn)
|
sl@0
|
1028 |
outputOk = processFn(gss, aShapeInfo);
|
sl@0
|
1029 |
else
|
sl@0
|
1030 |
break;
|
sl@0
|
1031 |
}
|
sl@0
|
1032 |
else
|
sl@0
|
1033 |
{
|
sl@0
|
1034 |
// Table entry blank, unicode char to be skipped
|
sl@0
|
1035 |
outputOk = ETrue;
|
sl@0
|
1036 |
textIter.Next();
|
sl@0
|
1037 |
gss.iClusterState =
|
sl@0
|
1038 |
(!textIter.AtEnd() &&
|
sl@0
|
1039 |
((textIter.Get().GetCategory() & 0xF0)
|
sl@0
|
1040 |
== TChar::EMarkGroup)) ?
|
sl@0
|
1041 |
TGlyphSelectionState::EGClusterNotComplete : TGlyphSelectionState::EGClusterComplete;
|
sl@0
|
1042 |
}
|
sl@0
|
1043 |
|
sl@0
|
1044 |
// Abort if no class was available to process the character or if
|
sl@0
|
1045 |
// processing failed.
|
sl@0
|
1046 |
if (!outputOk)
|
sl@0
|
1047 |
{
|
sl@0
|
1048 |
aParam.iPosInText = textIter.LengthToStart();
|
sl@0
|
1049 |
return outputOk;
|
sl@0
|
1050 |
}
|
sl@0
|
1051 |
|
sl@0
|
1052 |
// Did the glyph selector that processed the character want the
|
sl@0
|
1053 |
// pen to advance?
|
sl@0
|
1054 |
if (gss.iPen == TGlyphSelectionState::EPenAdvance_Yes)
|
sl@0
|
1055 |
{
|
sl@0
|
1056 |
aParam.iPen.iX += gss.iAdvance.iWidth;
|
sl@0
|
1057 |
aParam.iPen.iY += gss.iAdvance.iHeight;
|
sl@0
|
1058 |
gss.iPen = TGlyphSelectionState::EPenAdvance_No;
|
sl@0
|
1059 |
}
|
sl@0
|
1060 |
|
sl@0
|
1061 |
// Here we assume the Process() methods have advanced the iterator as
|
sl@0
|
1062 |
// they consume characters they handle so that it now points to the
|
sl@0
|
1063 |
// character to process next time around the loop.
|
sl@0
|
1064 |
}
|
sl@0
|
1065 |
while (!textIter.AtEnd() // We still have more text to process
|
sl@0
|
1066 |
&& (gss.iClusterState == TGlyphSelectionState::EGClusterNotComplete) // Glyph cluster !complete
|
sl@0
|
1067 |
&& (aParam.iOutputGlyphs < TPositionParam::EMaxOutputGlyphs)); // Room for another glyph entry
|
sl@0
|
1068 |
|
sl@0
|
1069 |
// If a complete glyph cluster has been identified then we should try to
|
sl@0
|
1070 |
// compose it as fully as possible. Obviously, if it only contains one
|
sl@0
|
1071 |
// character then it is already fully composed so we can ignore it.
|
sl@0
|
1072 |
// Skip this if any language-specific processing has taken place.
|
sl@0
|
1073 |
if (gss.iGlyphPostCombine == TGlyphSelectionState::EGPostCombine_Yes
|
sl@0
|
1074 |
&& gss.iClusterState == TGlyphSelectionState::EGClusterComplete)
|
sl@0
|
1075 |
{
|
sl@0
|
1076 |
// Leave room to handle surrogates - Decompose() outputs UTF-16
|
sl@0
|
1077 |
// The max that can come out of the previous stage is TPositionParam::EMaxOutputGlyphs
|
sl@0
|
1078 |
// long with only one base char at the start. Even if that base char decomposed to the
|
sl@0
|
1079 |
// max it could only be MaxOutputGlyphs long, giving a total of (2 * MaxOutputGlyphs)-1
|
sl@0
|
1080 |
// Conceivably the use of surrogates throughout could double that when converting to UTF-16
|
sl@0
|
1081 |
TBuf<TPositionParam::EMaxOutputGlyphs * 4> decomposeArray;
|
sl@0
|
1082 |
TBool success = ETrue;
|
sl@0
|
1083 |
// Go through the glyph cluster one char at a time
|
sl@0
|
1084 |
for (TInt i = 0; i < aParam.iOutputGlyphs; i++)
|
sl@0
|
1085 |
{
|
sl@0
|
1086 |
TChar singleChar(aParam.iOutput[i].iCode);
|
sl@0
|
1087 |
// If first character try to decompose it otherwise just take the character
|
sl@0
|
1088 |
TBool decomposed = EFalse;
|
sl@0
|
1089 |
TPtrC16 decomposition;
|
sl@0
|
1090 |
if (i == 0)
|
sl@0
|
1091 |
decomposed = singleChar.Decompose(decomposition);
|
sl@0
|
1092 |
if (decomposed)
|
sl@0
|
1093 |
{ // Pick up the sequence of characters
|
sl@0
|
1094 |
decomposeArray.Append(decomposition);
|
sl@0
|
1095 |
}
|
sl@0
|
1096 |
else
|
sl@0
|
1097 |
{ // Keep the original character
|
sl@0
|
1098 |
if (singleChar > 0xFFFF)
|
sl@0
|
1099 |
{ // Above the BMP so we need a surrogate pair for UTF-16
|
sl@0
|
1100 |
// This calculation really ought to go into a separate routine - probably part of TChar
|
sl@0
|
1101 |
decomposeArray.Append(HighSurrogate(singleChar));
|
sl@0
|
1102 |
decomposeArray.Append(LowSurrogate(singleChar));
|
sl@0
|
1103 |
}
|
sl@0
|
1104 |
else
|
sl@0
|
1105 |
{ // It's not a surrogate so we just need to cast it down (since it's safe)
|
sl@0
|
1106 |
decomposeArray.Append(singleChar);
|
sl@0
|
1107 |
}
|
sl@0
|
1108 |
}
|
sl@0
|
1109 |
// Guard against bad input overflowing the array and causing a panic
|
sl@0
|
1110 |
if (decomposeArray.Length() > (TPositionParam::EMaxOutputGlyphs * 4) - 2)
|
sl@0
|
1111 |
{ // too long to be a viable composition so don't try
|
sl@0
|
1112 |
success = EFalse;
|
sl@0
|
1113 |
break;
|
sl@0
|
1114 |
}
|
sl@0
|
1115 |
}
|
sl@0
|
1116 |
TUint composedChar = 0;
|
sl@0
|
1117 |
TOpenFontCharMetrics metrics;
|
sl@0
|
1118 |
TPositionParam::TOutput output;
|
sl@0
|
1119 |
TSize advance; // gets initialized to 0,0
|
sl@0
|
1120 |
if (success)
|
sl@0
|
1121 |
{
|
sl@0
|
1122 |
//Now try and compose the string to a single character
|
sl@0
|
1123 |
success = TChar::Compose(composedChar, decomposeArray);
|
sl@0
|
1124 |
}
|
sl@0
|
1125 |
if (success)
|
sl@0
|
1126 |
{
|
sl@0
|
1127 |
// if single char is not in font or can't get char metrics for it
|
sl@0
|
1128 |
// N.B. This will probably always return metrics because if the
|
sl@0
|
1129 |
// char is not in the font this will usually return the substitute
|
sl@0
|
1130 |
// "missing" glyph (and its metrics). There should be a function to
|
sl@0
|
1131 |
// really tell you if a glyph is in the font - but there isn't.
|
sl@0
|
1132 |
if (GetCharacterData(composedChar, metrics, output.iBitmap, output.iBitmapSize) == CFont::ENoCharacterData)
|
sl@0
|
1133 |
success = EFalse;
|
sl@0
|
1134 |
}
|
sl@0
|
1135 |
if (success)
|
sl@0
|
1136 |
{
|
sl@0
|
1137 |
// We should replace the glyph cluster made from multiple chars
|
sl@0
|
1138 |
// with the correct single char and fix up the rest of the output
|
sl@0
|
1139 |
// parameters as well
|
sl@0
|
1140 |
output.iCode = composedChar;
|
sl@0
|
1141 |
// Set the glyph's bounds and record pen advancement.
|
sl@0
|
1142 |
if (aParam.iDirection == CFont::EVertical)
|
sl@0
|
1143 |
{
|
sl@0
|
1144 |
metrics.GetVertBounds(output.iBounds);
|
sl@0
|
1145 |
advance.iHeight = metrics.VertAdvance();
|
sl@0
|
1146 |
}
|
sl@0
|
1147 |
else
|
sl@0
|
1148 |
{
|
sl@0
|
1149 |
metrics.GetHorizBounds(output.iBounds);
|
sl@0
|
1150 |
advance.iWidth = metrics.HorizAdvance();
|
sl@0
|
1151 |
}
|
sl@0
|
1152 |
// Adjust the glyph's bounding box to offset it from the pen
|
sl@0
|
1153 |
// position (origin of drawing). For speed increment directly.
|
sl@0
|
1154 |
output.iBounds.iTl.iX += penCopy.iX;
|
sl@0
|
1155 |
output.iBounds.iBr.iX += penCopy.iX;
|
sl@0
|
1156 |
output.iBounds.iTl.iY += penCopy.iY;
|
sl@0
|
1157 |
output.iBounds.iBr.iY += penCopy.iY;
|
sl@0
|
1158 |
// Set penCopy, the copy of aParam.iPen that we made
|
sl@0
|
1159 |
penCopy.iX += advance.iWidth;
|
sl@0
|
1160 |
penCopy.iY += advance.iHeight;
|
sl@0
|
1161 |
// Overwrite the original output parameters for the glyph cluster
|
sl@0
|
1162 |
// with the values for the single composed character
|
sl@0
|
1163 |
aParam.iOutput[0] = output;
|
sl@0
|
1164 |
aParam.iOutputGlyphs = 1;
|
sl@0
|
1165 |
aParam.iPen = penCopy;
|
sl@0
|
1166 |
}
|
sl@0
|
1167 |
}
|
sl@0
|
1168 |
|
sl@0
|
1169 |
// Exit routine with result and increment position in text to
|
sl@0
|
1170 |
// where we reached during processing to avoid any caller loops from
|
sl@0
|
1171 |
// infinite execution.
|
sl@0
|
1172 |
aParam.iPosInText = textIter.LengthToStart();
|
sl@0
|
1173 |
return outputOk;
|
sl@0
|
1174 |
}
|
sl@0
|
1175 |
|
sl@0
|
1176 |
/** Gets the character metrics for a character.
|
sl@0
|
1177 |
|
sl@0
|
1178 |
@param aCode The character code.
|
sl@0
|
1179 |
@param aMetrics On return, contains the character bitmap.
|
sl@0
|
1180 |
@param aBitmap On return, this points to NULL.
|
sl@0
|
1181 |
@param aBitmapSize On return, this has a size of (0,0).
|
sl@0
|
1182 |
@return ECharacterWidthOnly
|
sl@0
|
1183 |
*/
|
sl@0
|
1184 |
EXPORT_C CFont::TCharacterDataAvailability CFont::DoGetCharacterData(TUint aCode,TOpenFontCharMetrics& aMetrics,
|
sl@0
|
1185 |
const TUint8*& aBinaryData,TSize& aBitmapSize) const
|
sl@0
|
1186 |
{
|
sl@0
|
1187 |
int width = CharWidthInPixels(aCode);
|
sl@0
|
1188 |
aMetrics.SetHorizAdvance(width);
|
sl@0
|
1189 |
aBinaryData = NULL;
|
sl@0
|
1190 |
// For speed set to 0 directly rather than call SetSize()
|
sl@0
|
1191 |
aBitmapSize.iWidth = 0;
|
sl@0
|
1192 |
aBitmapSize.iHeight = 0;
|
sl@0
|
1193 |
|
sl@0
|
1194 |
/*
|
sl@0
|
1195 |
Set the other metrics using the width and font metrics.
|
sl@0
|
1196 |
This allows derived classes that don't override this function, like CInfoFont,
|
sl@0
|
1197 |
to give usable results for TextWidthInPixels and MeasureText.
|
sl@0
|
1198 |
*/
|
sl@0
|
1199 |
aMetrics.SetWidth(width);
|
sl@0
|
1200 |
int height = HeightInPixels();
|
sl@0
|
1201 |
aMetrics.SetHeight(height);
|
sl@0
|
1202 |
aMetrics.SetVertAdvance(height);
|
sl@0
|
1203 |
aMetrics.SetHorizBearingX(0);
|
sl@0
|
1204 |
aMetrics.SetHorizBearingY(AscentInPixels());
|
sl@0
|
1205 |
aMetrics.SetVertBearingX(0);
|
sl@0
|
1206 |
aMetrics.SetVertBearingY(0);
|
sl@0
|
1207 |
|
sl@0
|
1208 |
return CFont::ECharacterWidthOnly;
|
sl@0
|
1209 |
}
|
sl@0
|
1210 |
|
sl@0
|
1211 |
|
sl@0
|
1212 |
/** Determines if aLeftCharacter and aRightCharacter affect each other's
|
sl@0
|
1213 |
contextual glyph form if placed next to each other. If either character
|
sl@0
|
1214 |
is a combining character, EFalse will be returned, which is not generally
|
sl@0
|
1215 |
useful information. Pass in base characters ignoring intervening combining
|
sl@0
|
1216 |
characters.
|
sl@0
|
1217 |
@param aLeftCharacter Unicode code for the character that stands on the left.
|
sl@0
|
1218 |
@param aRightCharacter Unicode code for the character that stands on the right.
|
sl@0
|
1219 |
@return EFalse if the characters do not affect the contextual glyphs that are
|
sl@0
|
1220 |
be chosen when the two are rendered together, compared to being separated
|
sl@0
|
1221 |
(for example by a space). */
|
sl@0
|
1222 |
EXPORT_C TBool CFont::CharactersJoin(TInt aLeftCharacter, TInt aRightCharacter)
|
sl@0
|
1223 |
{
|
sl@0
|
1224 |
return GlyphSelector_Arabic::CharactersJoin(aLeftCharacter, aRightCharacter);
|
sl@0
|
1225 |
}
|
sl@0
|
1226 |
|
sl@0
|
1227 |
/** API extension system that enables the caller to access a particular API
|
sl@0
|
1228 |
extension function. N.B. Any overload of this function in a derived class
|
sl@0
|
1229 |
should call its immediate parent implementation for any extension function Uid
|
sl@0
|
1230 |
that it does not recognize and handle.
|
sl@0
|
1231 |
@param aInterfaceId UID of the required extension function
|
sl@0
|
1232 |
@param aParam Pointer to an arbitrary parameter block that can be used to
|
sl@0
|
1233 |
provide and/or return information to/from the particular extension function,
|
sl@0
|
1234 |
defaults to NULL.
|
sl@0
|
1235 |
@return Integer return value from extension function
|
sl@0
|
1236 |
@internalTechnology
|
sl@0
|
1237 |
@released
|
sl@0
|
1238 |
*/
|
sl@0
|
1239 |
EXPORT_C TInt CFont::DoExtendedFunction(TUid aFunctionId, TAny* /* aParam */) const
|
sl@0
|
1240 |
{
|
sl@0
|
1241 |
if (KFontCapitalAscent == aFunctionId ||
|
sl@0
|
1242 |
KFontMaxAscent == aFunctionId)
|
sl@0
|
1243 |
{
|
sl@0
|
1244 |
return AscentInPixels();
|
sl@0
|
1245 |
}
|
sl@0
|
1246 |
else if (KFontStandardDescent == aFunctionId ||
|
sl@0
|
1247 |
KFontMaxDescent == aFunctionId)
|
sl@0
|
1248 |
{
|
sl@0
|
1249 |
return DescentInPixels();
|
sl@0
|
1250 |
}
|
sl@0
|
1251 |
else if (KFontLineGap == aFunctionId)
|
sl@0
|
1252 |
{ // 1.2 of em height (rounded) is reasonable approximation of interline gap
|
sl@0
|
1253 |
return (HeightInPixels() * 12 + 5) / 10;
|
sl@0
|
1254 |
}
|
sl@0
|
1255 |
return KErrNotFound;
|
sl@0
|
1256 |
}
|
sl@0
|
1257 |
|
sl@0
|
1258 |
EXPORT_C TUid CFont::TypeUid() const
|
sl@0
|
1259 |
{
|
sl@0
|
1260 |
return DoTypeUid();
|
sl@0
|
1261 |
}
|
sl@0
|
1262 |
|
sl@0
|
1263 |
EXPORT_C TInt CFont::HeightInPixels() const
|
sl@0
|
1264 |
{
|
sl@0
|
1265 |
return DoHeightInPixels();
|
sl@0
|
1266 |
}
|
sl@0
|
1267 |
|
sl@0
|
1268 |
EXPORT_C TInt CFont::AscentInPixels() const
|
sl@0
|
1269 |
{
|
sl@0
|
1270 |
return DoAscentInPixels();
|
sl@0
|
1271 |
}
|
sl@0
|
1272 |
|
sl@0
|
1273 |
EXPORT_C TInt CFont::DescentInPixels() const
|
sl@0
|
1274 |
{
|
sl@0
|
1275 |
return DoDescentInPixels();
|
sl@0
|
1276 |
}
|
sl@0
|
1277 |
|
sl@0
|
1278 |
EXPORT_C TInt CFont::CharWidthInPixels(TChar aChar) const
|
sl@0
|
1279 |
{
|
sl@0
|
1280 |
return DoCharWidthInPixels(aChar);
|
sl@0
|
1281 |
}
|
sl@0
|
1282 |
|
sl@0
|
1283 |
EXPORT_C TInt CFont::TextWidthInPixels(const TDesC& aText) const
|
sl@0
|
1284 |
{
|
sl@0
|
1285 |
return DoTextWidthInPixels(aText);
|
sl@0
|
1286 |
}
|
sl@0
|
1287 |
|
sl@0
|
1288 |
EXPORT_C TInt CFont::BaselineOffsetInPixels() const
|
sl@0
|
1289 |
{
|
sl@0
|
1290 |
return DoBaselineOffsetInPixels();
|
sl@0
|
1291 |
}
|
sl@0
|
1292 |
|
sl@0
|
1293 |
EXPORT_C TInt CFont::TextCount(const TDesC& aText,TInt aWidthInPixels) const
|
sl@0
|
1294 |
{
|
sl@0
|
1295 |
return DoTextCount(aText, aWidthInPixels);
|
sl@0
|
1296 |
}
|
sl@0
|
1297 |
|
sl@0
|
1298 |
EXPORT_C TInt CFont::TextCount(const TDesC& aText, TInt aWidthInPixels, TInt& aExcessWidthInPixels) const
|
sl@0
|
1299 |
{
|
sl@0
|
1300 |
return DoTextCount(aText, aWidthInPixels, aExcessWidthInPixels);
|
sl@0
|
1301 |
}
|
sl@0
|
1302 |
|
sl@0
|
1303 |
EXPORT_C TInt CFont::MaxCharWidthInPixels() const
|
sl@0
|
1304 |
{
|
sl@0
|
1305 |
return DoMaxCharWidthInPixels();
|
sl@0
|
1306 |
}
|
sl@0
|
1307 |
|
sl@0
|
1308 |
EXPORT_C TInt CFont::MaxNormalCharWidthInPixels() const
|
sl@0
|
1309 |
{
|
sl@0
|
1310 |
return DoMaxNormalCharWidthInPixels();
|
sl@0
|
1311 |
}
|
sl@0
|
1312 |
|
sl@0
|
1313 |
EXPORT_C TFontSpec CFont::FontSpecInTwips() const
|
sl@0
|
1314 |
{
|
sl@0
|
1315 |
return DoFontSpecInTwips();
|
sl@0
|
1316 |
}
|
sl@0
|
1317 |
|
sl@0
|
1318 |
/** Gets the character metrics for a character.
|
sl@0
|
1319 |
|
sl@0
|
1320 |
@param aCode The character code.
|
sl@0
|
1321 |
@param aMetrics On return, contains the character bitmap.
|
sl@0
|
1322 |
@param aBitmap On return, this points to NULL.
|
sl@0
|
1323 |
@param aBitmapSize On return, this has a size of (0,0).
|
sl@0
|
1324 |
@return ECharacterWidthOnly
|
sl@0
|
1325 |
*/
|
sl@0
|
1326 |
EXPORT_C CFont::TCharacterDataAvailability CFont::GetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics, const TUint8*& aBitmap, TSize& aBitmapSize) const
|
sl@0
|
1327 |
{
|
sl@0
|
1328 |
return DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
|
sl@0
|
1329 |
}
|
sl@0
|
1330 |
|
sl@0
|
1331 |
/** Transforms one cluster of characters (base character plus combining marks,
|
sl@0
|
1332 |
ligature or indic syllable) into one cluster of glyphs together with their
|
sl@0
|
1333 |
positions. Repeated calls of this function (for the same input text) are
|
sl@0
|
1334 |
considerably slower than repeated calls of GetCharacterPosition2 for Indic text
|
sl@0
|
1335 |
(such as Hindi), as GetCharacterPosition2 can cache information between calls.
|
sl@0
|
1336 |
@param aParam Input and output parameters
|
sl@0
|
1337 |
@return True for success
|
sl@0
|
1338 |
@see GetCharacterPosition2
|
sl@0
|
1339 |
@publishedAll */
|
sl@0
|
1340 |
EXPORT_C TBool CFont::GetCharacterPosition(TPositionParam& aParam) const
|
sl@0
|
1341 |
{
|
sl@0
|
1342 |
return DoGetCharacterPosition(aParam);
|
sl@0
|
1343 |
}
|
sl@0
|
1344 |
|
sl@0
|
1345 |
/** Enables the caller to access a particular API
|
sl@0
|
1346 |
extension function. N.B. Any overload of this function in a derived class
|
sl@0
|
1347 |
should call its immediate parent implementation for any extension function UID
|
sl@0
|
1348 |
that it does not recognize and handle.
|
sl@0
|
1349 |
@param aFunctionId UID of the required extension function
|
sl@0
|
1350 |
@param aParam Pointer to an arbitrary parameter block that can be used to
|
sl@0
|
1351 |
provide and/or return information to/from the particular extension function,
|
sl@0
|
1352 |
defaults to NULL.
|
sl@0
|
1353 |
@return Integer return value from extension function
|
sl@0
|
1354 |
*/
|
sl@0
|
1355 |
EXPORT_C TInt CFont::ExtendedFunction(TUid aFunctionId, TAny* aParam) const
|
sl@0
|
1356 |
{
|
sl@0
|
1357 |
return DoExtendedFunction(aFunctionId, aParam);
|
sl@0
|
1358 |
}
|
sl@0
|
1359 |
|
sl@0
|
1360 |
EXPORT_C TInt CFont::TextWidthInPixels(const TDesC& aText,const TMeasureTextInput* aParam) const
|
sl@0
|
1361 |
{
|
sl@0
|
1362 |
TTextWidthInternal context;
|
sl@0
|
1363 |
TTextWidthInternal* contextPtr = &context;
|
sl@0
|
1364 |
contextPtr->iText.Set(aText);
|
sl@0
|
1365 |
contextPtr->iParam.iStartInputChar = aParam->iStartInputChar;
|
sl@0
|
1366 |
contextPtr->iParam.iEndInputChar = aParam->iEndInputChar;
|
sl@0
|
1367 |
return DoExtendedFunction(KTextInContextWidthInPixelsUid, (TAny*)contextPtr);
|
sl@0
|
1368 |
}
|
sl@0
|
1369 |
|
sl@0
|
1370 |
/**
|
sl@0
|
1371 |
Maps TLanguage to TScript.
|
sl@0
|
1372 |
|
sl@0
|
1373 |
EScriptOther represents languages not yet supported in KTScript2GlyphSample.
|
sl@0
|
1374 |
This array does not handle ELangNone and ELangMaximum to save storage space.
|
sl@0
|
1375 |
*/
|
sl@0
|
1376 |
const TInt GlyphSample::KTLanguage2TScript[] =
|
sl@0
|
1377 |
{
|
sl@0
|
1378 |
EScriptNone, // 00 ELangTest
|
sl@0
|
1379 |
EScriptLatin, // 01 ELangEnglish
|
sl@0
|
1380 |
EScriptLatin, // 02 ELangFrench
|
sl@0
|
1381 |
EScriptLatin, // 03 ELangGerman
|
sl@0
|
1382 |
EScriptLatin, // 04 ELangSpanish
|
sl@0
|
1383 |
EScriptLatin, // 05 ELangItalian
|
sl@0
|
1384 |
EScriptLatin, // 06 ELangSwedish
|
sl@0
|
1385 |
EScriptLatin, // 07 ELangDanish
|
sl@0
|
1386 |
EScriptLatin, // 08 ELangNorwegian
|
sl@0
|
1387 |
EScriptLatin, // 09 ELangFinnish
|
sl@0
|
1388 |
EScriptLatin, // 10 ELangAmerican
|
sl@0
|
1389 |
EScriptLatin, // 11 ELangSwissFrench
|
sl@0
|
1390 |
EScriptLatin, // 12 ELangSwissGerman
|
sl@0
|
1391 |
EScriptLatin, // 13 ELangPortuguese
|
sl@0
|
1392 |
EScriptLatin, // 14 ELangTurkish
|
sl@0
|
1393 |
EScriptLatin, // 15 ELangIcelandic
|
sl@0
|
1394 |
EScriptCyrillic, // 16 ELangRussian
|
sl@0
|
1395 |
EScriptLatin, // 17 ELangHungarian
|
sl@0
|
1396 |
EScriptLatin, // 18 ELangDutch
|
sl@0
|
1397 |
EScriptLatin, // 19 ELangBelgianFlemish
|
sl@0
|
1398 |
EScriptLatin, // 20 ELangAustralian
|
sl@0
|
1399 |
EScriptLatin, // 21 ELangBelgianFrench
|
sl@0
|
1400 |
EScriptLatin, // 22 ELangAustrian
|
sl@0
|
1401 |
EScriptLatin, // 23 ELangNewZealand
|
sl@0
|
1402 |
EScriptLatin, // 24 ELangInternationalFrench
|
sl@0
|
1403 |
EScriptLatin, // 25 ELangCzech
|
sl@0
|
1404 |
EScriptLatin, // 26 ELangSlovak
|
sl@0
|
1405 |
EScriptLatin, // 27 ELangPolish
|
sl@0
|
1406 |
EScriptLatin, // 28 ELangSlovenian
|
sl@0
|
1407 |
EScriptHanIdeographs, // 29 ELangTaiwanChinese
|
sl@0
|
1408 |
EScriptHanIdeographs, // 30 ELangHongKongChinese
|
sl@0
|
1409 |
EScriptHanIdeographs, // 31 ELangPrcChinese
|
sl@0
|
1410 |
EScriptHanIdeographs, // 32 ELangJapanese
|
sl@0
|
1411 |
EScriptThai, // 33 ELangThai
|
sl@0
|
1412 |
EScriptLatin, // 34 ELangAfrikaans
|
sl@0
|
1413 |
EScriptLatin, // 35 ELangAlbanian
|
sl@0
|
1414 |
EScriptOther, // 36 ELangAmharic
|
sl@0
|
1415 |
EScriptArabic, // 37 ELangArabic
|
sl@0
|
1416 |
EScriptOther, // 38 ELangArmenian
|
sl@0
|
1417 |
EScriptOther, // 39 ELangTagalog
|
sl@0
|
1418 |
EScriptCyrillic, // 40 ELangBelarussian
|
sl@0
|
1419 |
EScriptOther, // 41 ELangBengali
|
sl@0
|
1420 |
EScriptCyrillic, // 42 ELangBulgarian
|
sl@0
|
1421 |
EScriptOther, // 43 ELangBurmese
|
sl@0
|
1422 |
EScriptLatin, // 44 ELangCatalan
|
sl@0
|
1423 |
EScriptLatin, // 45 ELangCroatian
|
sl@0
|
1424 |
EScriptLatin, // 46 ELangCanadianEnglish
|
sl@0
|
1425 |
EScriptLatin, // 47 ELangInternationalEnglish
|
sl@0
|
1426 |
EScriptLatin, // 48 ELangSouthAfricanEnglish
|
sl@0
|
1427 |
EScriptLatin, // 49 ELangEstonian
|
sl@0
|
1428 |
EScriptArabic, // 50 ELangFarsi
|
sl@0
|
1429 |
EScriptLatin, // 51 ELangCanadianFrench
|
sl@0
|
1430 |
EScriptLatin, // 52 ELangScotsGaelic
|
sl@0
|
1431 |
EScriptOther, // 53 ELangGeorgian
|
sl@0
|
1432 |
EScriptGreek, // 54 ELangGreek
|
sl@0
|
1433 |
EScriptGreek, // 55 ELangCyprusGreek
|
sl@0
|
1434 |
EScriptOther, // 56 ELangGujarati
|
sl@0
|
1435 |
EScriptHebrew, // 57 ELangHebrew
|
sl@0
|
1436 |
EScriptDevanagari, // 58 ELangHindi
|
sl@0
|
1437 |
EScriptLatin, // 59 ELangIndonesian
|
sl@0
|
1438 |
EScriptLatin, // 60 ELangIrish
|
sl@0
|
1439 |
EScriptLatin, // 61 ELangSwissItalian
|
sl@0
|
1440 |
EScriptOther, // 62 ELangKannada
|
sl@0
|
1441 |
EScriptCyrillic, // 63 ELangKazakh
|
sl@0
|
1442 |
EScriptOther, // 64 ELangKhmer
|
sl@0
|
1443 |
EScriptHanIdeographs, // 65 ELangKorean
|
sl@0
|
1444 |
EScriptOther, // 66 ELangLao
|
sl@0
|
1445 |
EScriptLatin, // 67 ELangLatvian
|
sl@0
|
1446 |
EScriptLatin, // 68 ELangLithuanian
|
sl@0
|
1447 |
EScriptCyrillic, // 69 ELangMacedonian
|
sl@0
|
1448 |
EScriptLatin, // 70 ELangMalay
|
sl@0
|
1449 |
EScriptOther, // 71 ELangMalayalam
|
sl@0
|
1450 |
EScriptDevanagari, // 72 ELangMarathi
|
sl@0
|
1451 |
EScriptLatin, // 73 ELangMoldavian
|
sl@0
|
1452 |
EScriptOther, // 74 ELangMongolian
|
sl@0
|
1453 |
EScriptLatin, // 75 ELangNorwegianNynorsk
|
sl@0
|
1454 |
EScriptLatin, // 76 ELangBrazilianPortuguese
|
sl@0
|
1455 |
EScriptOther, // 77 ELangPunjabi
|
sl@0
|
1456 |
EScriptLatin, // 78 ELangRomanian
|
sl@0
|
1457 |
EScriptCyrillic, // 79 ELangSerbian
|
sl@0
|
1458 |
EScriptOther, // 80 ELangSinhalese
|
sl@0
|
1459 |
EScriptLatin, // 81 ELangSomali
|
sl@0
|
1460 |
EScriptLatin, // 82 ELangInternationalSpanish
|
sl@0
|
1461 |
EScriptLatin, // 83 ELangLatinAmericanSpanish
|
sl@0
|
1462 |
EScriptLatin, // 84 ELangSwahili
|
sl@0
|
1463 |
EScriptLatin, // 85 ELangFinlandSwedish
|
sl@0
|
1464 |
EScriptNone, // 86 ELangReserved1
|
sl@0
|
1465 |
EScriptOther, // 87 ELangTamil
|
sl@0
|
1466 |
EScriptOther, // 88 ELangTelugu
|
sl@0
|
1467 |
EScriptOther, // 89 ELangTibetan
|
sl@0
|
1468 |
EScriptOther, // 90 ELangTigrinya
|
sl@0
|
1469 |
EScriptLatin, // 91 ELangCyprusTurkish
|
sl@0
|
1470 |
EScriptCyrillic, // 92 ELangTurkmen
|
sl@0
|
1471 |
EScriptCyrillic, // 93 ELangUkrainian
|
sl@0
|
1472 |
EScriptArabic, // 94 ELangUrdu
|
sl@0
|
1473 |
EScriptNone, // 95 ELangReserved2
|
sl@0
|
1474 |
EScriptLatin, // 96 ELangVietnamese
|
sl@0
|
1475 |
EScriptLatin, // 97 ELangWelsh
|
sl@0
|
1476 |
EScriptLatin, // 98 ELangZulu
|
sl@0
|
1477 |
};
|
sl@0
|
1478 |
|
sl@0
|
1479 |
/**
|
sl@0
|
1480 |
Maps TScript to glyph samples.
|
sl@0
|
1481 |
|
sl@0
|
1482 |
The order of samples definition has to follow the script order in TScript.
|
sl@0
|
1483 |
|
sl@0
|
1484 |
Supported scripts Fonts used to experiment/determine glyph samples
|
sl@0
|
1485 |
|
sl@0
|
1486 |
Latin Arial, Times, Century
|
sl@0
|
1487 |
Greek Ditto
|
sl@0
|
1488 |
Cyrillic Ditto
|
sl@0
|
1489 |
Hebrew Aharoni, David, FrankRuehl, Levenim MT, Miriam, Narkisim, Rod
|
sl@0
|
1490 |
Arabic Andalus, Arabic Transparent, Simplified Arabic, Traditional Arabic
|
sl@0
|
1491 |
Devanagari Mangal
|
sl@0
|
1492 |
Thai Angsana New, Browallia, Cordia New, DilleniaUPC, EucrosiaUPC,
|
sl@0
|
1493 |
FreesiaUPC, IrisUPC, JasmineUPC, KodchiangUPC, LilyUPC
|
sl@0
|
1494 |
HanIdeographs Chinese : SimSun, SimHei (Simplified) / MingLiU (Traditional)
|
sl@0
|
1495 |
Japanese: MS Mincho, MS Gothic
|
sl@0
|
1496 |
Korean : Batang, Gulim
|
sl@0
|
1497 |
*/
|
sl@0
|
1498 |
const TText* const GlyphSample::KTScript2GlyphSample[] =
|
sl@0
|
1499 |
{
|
sl@0
|
1500 |
//
|
sl@0
|
1501 |
// 02 EScriptLatin
|
sl@0
|
1502 |
//
|
sl@0
|
1503 |
// 0x00C0 - Ascent : Capital letter A with grave (Latin-1 Supplement)
|
sl@0
|
1504 |
// 0x013A - Ascent : Small letter l with acute (Latin Extended A)
|
sl@0
|
1505 |
// 0x1EA2 - Ascent : Capital letter A with hook above (Latin Extended Additional)
|
sl@0
|
1506 |
// 0x00C7 - Descent: Capital letter C with cedilla (Latin-1 Supplement)
|
sl@0
|
1507 |
// 0x0163 - Descent: Small letter t with cedilla (Latin Extended A)
|
sl@0
|
1508 |
//
|
sl@0
|
1509 |
_S("\x00C0\x013A\x1EA2\x00C7\x0163"),
|
sl@0
|
1510 |
//
|
sl@0
|
1511 |
// 03 EScriptGreek
|
sl@0
|
1512 |
//
|
sl@0
|
1513 |
// 0x03AA - Ascent : Capital letter iota with dialytika
|
sl@0
|
1514 |
// 0x03AB - Ascent : Capital letter upsilon with dialytika
|
sl@0
|
1515 |
// 0x03AE - Descent: Small letter eta with tonos
|
sl@0
|
1516 |
// 0x03B2 - Descent: Small letter beta
|
sl@0
|
1517 |
// 0x03C8 - Descent: Small letter psi
|
sl@0
|
1518 |
//
|
sl@0
|
1519 |
_S("\x03AA\x03AB\x03AE\x03B2\x03C8"),
|
sl@0
|
1520 |
//
|
sl@0
|
1521 |
// 04 EScriptCyrillic
|
sl@0
|
1522 |
//
|
sl@0
|
1523 |
// 0x0403 - Ascent : Capital letter gje
|
sl@0
|
1524 |
// 0x0419 - Ascent : Capital letter short i
|
sl@0
|
1525 |
// 0x0440 - Descent: Small letter er
|
sl@0
|
1526 |
// 0x0452 - Descent: Small letter dje
|
sl@0
|
1527 |
// 0x0458 - Descent: Small letter je
|
sl@0
|
1528 |
//
|
sl@0
|
1529 |
_S("\x0403\x0419\x0440\x0452\x0458"),
|
sl@0
|
1530 |
//
|
sl@0
|
1531 |
// 05 EScriptHebrew
|
sl@0
|
1532 |
//
|
sl@0
|
1533 |
// 0x05BE - Ascent : Punctuation maqaf
|
sl@0
|
1534 |
// 0x05DC - Ascent : Letter lamed
|
sl@0
|
1535 |
// 0x05B0 - Descent: Point sheva
|
sl@0
|
1536 |
// 0x05BD - Descent: Point meteg
|
sl@0
|
1537 |
// 0x05E7 - Descent: Letter qof
|
sl@0
|
1538 |
//
|
sl@0
|
1539 |
_S("\x05BE\x05DC\x05B0\x05BD\x05E7"),
|
sl@0
|
1540 |
//
|
sl@0
|
1541 |
// 06 EScriptArabic
|
sl@0
|
1542 |
//
|
sl@0
|
1543 |
// 0x0670 - Ascent : Alef above (Arabic)
|
sl@0
|
1544 |
// 0x0671 - Ascent : Hamzat Wasl on Alef isolated form
|
sl@0
|
1545 |
// 0x064D - Descent: Kasratan (Arabic)
|
sl@0
|
1546 |
// 0xFB7B - Descent: Final form of 0686
|
sl@0
|
1547 |
// 0xFBF2 - Descent: Final form of 064A
|
sl@0
|
1548 |
//
|
sl@0
|
1549 |
//PDEF120737: EScriptArabic value has been changed for this defect & tested using the font file provided by client (i.e. kamelion arabic font).
|
sl@0
|
1550 |
//The client's font file can't be used for IPR reasons. Thus the test code to demonstrate this defect
|
sl@0
|
1551 |
//is not added. Also, there was no other font file available that reproduces this defect.
|
sl@0
|
1552 |
//
|
sl@0
|
1553 |
_S("\x0670\x0671\x064D\xFB7B\xFBF2"),
|
sl@0
|
1554 |
//
|
sl@0
|
1555 |
// 07 EScriptDevanagari
|
sl@0
|
1556 |
//
|
sl@0
|
1557 |
// 0x0914 - Ascent : Letter au
|
sl@0
|
1558 |
// 0x0951 - Ascent : Stress sign udatta
|
sl@0
|
1559 |
// 0x0941 - Descent: Vowel sign u
|
sl@0
|
1560 |
// 0x0944 - Descent: Vowel sign rr
|
sl@0
|
1561 |
// 0x0963 - Descent: Vowel sign vocalic ll
|
sl@0
|
1562 |
//
|
sl@0
|
1563 |
_S("\x0914\x0951\x0941\x0944\x0963"),
|
sl@0
|
1564 |
//
|
sl@0
|
1565 |
// 08 EScriptThai
|
sl@0
|
1566 |
//
|
sl@0
|
1567 |
// 0x0E49 - Ascent : Character mai tho
|
sl@0
|
1568 |
// 0x0E4B - Ascent : Character mai chattawa
|
sl@0
|
1569 |
// 0x0E0E - Descent: Character do chada
|
sl@0
|
1570 |
// 0x0E24 - Descent: Character ru
|
sl@0
|
1571 |
// 0x0E39 - Descent: Character sara uu
|
sl@0
|
1572 |
//
|
sl@0
|
1573 |
_S("\x0E49\x0E4B\x0E0E\x0E24\x0E39"),
|
sl@0
|
1574 |
//
|
sl@0
|
1575 |
// 09 EScriptHanIdeographs
|
sl@0
|
1576 |
//
|
sl@0
|
1577 |
// 0x1100 - Ascent/Descent: Korean
|
sl@0
|
1578 |
// 0x4E1C - Ascent/Descent: Chinese Simplified
|
sl@0
|
1579 |
// 0x5283 - Ascent/Descent: Japanese
|
sl@0
|
1580 |
// 0x758A - Ascent : Chinese Traditional
|
sl@0
|
1581 |
// 0x7BEA - Descent: Chinese Traditional
|
sl@0
|
1582 |
//
|
sl@0
|
1583 |
_S("\x1100\x4E1C\x5283\x758A\x7BEA"),
|
sl@0
|
1584 |
};
|
sl@0
|
1585 |
|
sl@0
|
1586 |
/**
|
sl@0
|
1587 |
Maps a TLanguage type to the TScript type.
|
sl@0
|
1588 |
@internalTechnology
|
sl@0
|
1589 |
@param aLanguage The language.
|
sl@0
|
1590 |
@return A TInt representing the script, or
|
sl@0
|
1591 |
EScriptNone if its not defined for aLanguage.
|
sl@0
|
1592 |
*/
|
sl@0
|
1593 |
EXPORT_C TInt GlyphSample::TLanguage2TScript(TLanguage aLanguage)
|
sl@0
|
1594 |
{
|
sl@0
|
1595 |
if (ELangNone == aLanguage || ELangMaximum == aLanguage || aLanguage >= (sizeof(KTLanguage2TScript)/sizeof(KTLanguage2TScript[0])))
|
sl@0
|
1596 |
{
|
sl@0
|
1597 |
return EScriptNone;
|
sl@0
|
1598 |
}
|
sl@0
|
1599 |
return KTLanguage2TScript[aLanguage];
|
sl@0
|
1600 |
}
|
sl@0
|
1601 |
|
sl@0
|
1602 |
/**
|
sl@0
|
1603 |
Maps a TScript type to some glyph samples which are stored as Unicode.
|
sl@0
|
1604 |
@internalTechnology
|
sl@0
|
1605 |
@param aScript The script.
|
sl@0
|
1606 |
@return A TPtrC pointing to the first glyph sample,
|
sl@0
|
1607 |
or empty if no samples is defined for aScript.
|
sl@0
|
1608 |
*/
|
sl@0
|
1609 |
EXPORT_C const TPtrC GlyphSample::TScript2GlyphSample(TInt aScript)
|
sl@0
|
1610 |
{
|
sl@0
|
1611 |
if (EScriptOther >= aScript)
|
sl@0
|
1612 |
{
|
sl@0
|
1613 |
return TPtrC();
|
sl@0
|
1614 |
}
|
sl@0
|
1615 |
// -3 to offset EScriptDefault, EScriptNone and EScriptOther
|
sl@0
|
1616 |
// being the first three elements in TScript.
|
sl@0
|
1617 |
return TPtrC(KTScript2GlyphSample[aScript - 3]);
|
sl@0
|
1618 |
}
|
sl@0
|
1619 |
|
sl@0
|
1620 |
|
sl@0
|
1621 |
EXPORT_C RFontTable::RFontTable():iTableContent(0), iLength(0),
|
sl@0
|
1622 |
iFont(NULL), iTag(0)
|
sl@0
|
1623 |
{
|
sl@0
|
1624 |
// a null constructor.
|
sl@0
|
1625 |
}
|
sl@0
|
1626 |
|
sl@0
|
1627 |
EXPORT_C TInt
|
sl@0
|
1628 |
RFontTable::Open(CFont& aFont, TUint32 aTag)
|
sl@0
|
1629 |
{
|
sl@0
|
1630 |
TGetFontTableParam param;
|
sl@0
|
1631 |
param.iTag = aTag;
|
sl@0
|
1632 |
|
sl@0
|
1633 |
// remember the parameters, to be used when releasing the font table.
|
sl@0
|
1634 |
iFont = &aFont;
|
sl@0
|
1635 |
iTag = aTag;
|
sl@0
|
1636 |
|
sl@0
|
1637 |
TInt ret = aFont.ExtendedFunction(KFontGetFontTable, (TAny *)¶m);
|
sl@0
|
1638 |
if (KErrNone == ret)
|
sl@0
|
1639 |
{
|
sl@0
|
1640 |
iTableContent = (TAny *)param.iContent;
|
sl@0
|
1641 |
iLength = param.iLength;
|
sl@0
|
1642 |
}
|
sl@0
|
1643 |
return ret;
|
sl@0
|
1644 |
}
|
sl@0
|
1645 |
|
sl@0
|
1646 |
EXPORT_C TInt
|
sl@0
|
1647 |
RFontTable::TableLength() const
|
sl@0
|
1648 |
{
|
sl@0
|
1649 |
return iLength;
|
sl@0
|
1650 |
}
|
sl@0
|
1651 |
|
sl@0
|
1652 |
EXPORT_C const TUint8*
|
sl@0
|
1653 |
RFontTable::TableContent() const
|
sl@0
|
1654 |
{
|
sl@0
|
1655 |
return (TUint8*)iTableContent;
|
sl@0
|
1656 |
}
|
sl@0
|
1657 |
|
sl@0
|
1658 |
EXPORT_C void
|
sl@0
|
1659 |
RFontTable::Close()
|
sl@0
|
1660 |
{
|
sl@0
|
1661 |
if (NULL != iFont)
|
sl@0
|
1662 |
{
|
sl@0
|
1663 |
(void)iFont->ExtendedFunction(KFontReleaseFontTable, (TAny *)&iTag);
|
sl@0
|
1664 |
}
|
sl@0
|
1665 |
iTableContent = 0;
|
sl@0
|
1666 |
iLength = 0;
|
sl@0
|
1667 |
iFont = NULL;
|
sl@0
|
1668 |
iTag = 0;
|
sl@0
|
1669 |
}
|
sl@0
|
1670 |
|
sl@0
|
1671 |
EXPORT_C
|
sl@0
|
1672 |
RGlyphOutlineIterator::RGlyphOutlineIterator():iOutlines(0), iLengths(0),
|
sl@0
|
1673 |
iCursor(-1), iCount(0), iFont(NULL), iCodes(NULL), iHinted(EFalse)
|
sl@0
|
1674 |
{
|
sl@0
|
1675 |
// a null constructor.
|
sl@0
|
1676 |
}
|
sl@0
|
1677 |
|
sl@0
|
1678 |
EXPORT_C TInt
|
sl@0
|
1679 |
RGlyphOutlineIterator::Open(CFont& aFont, const TUint* aCodes, TInt aCount, TBool aHinted)
|
sl@0
|
1680 |
{
|
sl@0
|
1681 |
if (NULL == aCodes || 0 == aCount)
|
sl@0
|
1682 |
{
|
sl@0
|
1683 |
return KErrArgument;
|
sl@0
|
1684 |
}
|
sl@0
|
1685 |
TGetGlyphOutlineParam param;
|
sl@0
|
1686 |
iLengths = (TInt *)User::Alloc(sizeof(TInt) * aCount);
|
sl@0
|
1687 |
if (NULL == iLengths)
|
sl@0
|
1688 |
{
|
sl@0
|
1689 |
return KErrNoMemory;
|
sl@0
|
1690 |
}
|
sl@0
|
1691 |
iOutlines = (TAny **)User::Alloc(sizeof(TAny *) * aCount);
|
sl@0
|
1692 |
if (NULL == iOutlines)
|
sl@0
|
1693 |
{
|
sl@0
|
1694 |
User::Free(iLengths);
|
sl@0
|
1695 |
iLengths = NULL;
|
sl@0
|
1696 |
return KErrNoMemory;
|
sl@0
|
1697 |
}
|
sl@0
|
1698 |
|
sl@0
|
1699 |
param.iLengths = iLengths;
|
sl@0
|
1700 |
param.iCount = aCount;
|
sl@0
|
1701 |
param.iCodes = aCodes;
|
sl@0
|
1702 |
param.iHinted = aHinted;
|
sl@0
|
1703 |
param.iOutlines = iOutlines;
|
sl@0
|
1704 |
|
sl@0
|
1705 |
/* information needed in Close() */
|
sl@0
|
1706 |
iCodes = (TUint *)User::Alloc(sizeof(TUint) * aCount);
|
sl@0
|
1707 |
if (NULL == iCodes)
|
sl@0
|
1708 |
{
|
sl@0
|
1709 |
User::Free(iLengths);
|
sl@0
|
1710 |
User::Free(iOutlines);
|
sl@0
|
1711 |
iLengths = NULL;
|
sl@0
|
1712 |
iOutlines = NULL;
|
sl@0
|
1713 |
return KErrNoMemory;
|
sl@0
|
1714 |
}
|
sl@0
|
1715 |
Mem::Copy(iCodes, aCodes, aCount*sizeof(TUint));
|
sl@0
|
1716 |
iFont = &aFont;
|
sl@0
|
1717 |
iHinted = aHinted;
|
sl@0
|
1718 |
iCount = aCount;
|
sl@0
|
1719 |
|
sl@0
|
1720 |
TInt ret = aFont.ExtendedFunction(KFontGetGlyphOutline, (TAny *)¶m);
|
sl@0
|
1721 |
if (KErrNone != ret)
|
sl@0
|
1722 |
{
|
sl@0
|
1723 |
User::Free(iLengths);
|
sl@0
|
1724 |
User::Free(iOutlines);
|
sl@0
|
1725 |
User::Free(iCodes);
|
sl@0
|
1726 |
iLengths = NULL;
|
sl@0
|
1727 |
iOutlines = NULL;
|
sl@0
|
1728 |
iCodes = NULL;
|
sl@0
|
1729 |
iFont = NULL;
|
sl@0
|
1730 |
}
|
sl@0
|
1731 |
else
|
sl@0
|
1732 |
{
|
sl@0
|
1733 |
iCursor = 0;
|
sl@0
|
1734 |
}
|
sl@0
|
1735 |
|
sl@0
|
1736 |
return ret;
|
sl@0
|
1737 |
}
|
sl@0
|
1738 |
|
sl@0
|
1739 |
EXPORT_C const TUint8*
|
sl@0
|
1740 |
RGlyphOutlineIterator::Outline() const
|
sl@0
|
1741 |
{
|
sl@0
|
1742 |
GDI_ASSERT_ALWAYS(iCursor >= 0, EGdiPanic_Unknown);
|
sl@0
|
1743 |
|
sl@0
|
1744 |
if (iLengths[iCursor] < 0)
|
sl@0
|
1745 |
{
|
sl@0
|
1746 |
return NULL;
|
sl@0
|
1747 |
}
|
sl@0
|
1748 |
else
|
sl@0
|
1749 |
{
|
sl@0
|
1750 |
return (const TUint8*)iOutlines[iCursor];
|
sl@0
|
1751 |
}
|
sl@0
|
1752 |
}
|
sl@0
|
1753 |
|
sl@0
|
1754 |
EXPORT_C TInt
|
sl@0
|
1755 |
RGlyphOutlineIterator::OutlineLength() const
|
sl@0
|
1756 |
{
|
sl@0
|
1757 |
GDI_ASSERT_ALWAYS(iCursor >= 0, EGdiPanic_Unknown);
|
sl@0
|
1758 |
|
sl@0
|
1759 |
if (iLengths[iCursor] < 0)
|
sl@0
|
1760 |
{
|
sl@0
|
1761 |
return KErrGeneral;
|
sl@0
|
1762 |
}
|
sl@0
|
1763 |
else
|
sl@0
|
1764 |
{
|
sl@0
|
1765 |
return iLengths[iCursor];
|
sl@0
|
1766 |
}
|
sl@0
|
1767 |
}
|
sl@0
|
1768 |
|
sl@0
|
1769 |
EXPORT_C TInt
|
sl@0
|
1770 |
RGlyphOutlineIterator::Next()
|
sl@0
|
1771 |
{
|
sl@0
|
1772 |
if (iCursor >= 0 && iCursor < iCount-1)
|
sl@0
|
1773 |
{
|
sl@0
|
1774 |
++iCursor;
|
sl@0
|
1775 |
return KErrNone;
|
sl@0
|
1776 |
}
|
sl@0
|
1777 |
else
|
sl@0
|
1778 |
{
|
sl@0
|
1779 |
iCursor = -1;
|
sl@0
|
1780 |
// if the iterator goes beyond the last element [when
|
sl@0
|
1781 |
// Next() returns KErrNotFound], the next call
|
sl@0
|
1782 |
// to Outline() or OutlineLength() will panic.
|
sl@0
|
1783 |
|
sl@0
|
1784 |
return KErrNotFound;
|
sl@0
|
1785 |
}
|
sl@0
|
1786 |
}
|
sl@0
|
1787 |
|
sl@0
|
1788 |
EXPORT_C void
|
sl@0
|
1789 |
RGlyphOutlineIterator::Close()
|
sl@0
|
1790 |
{
|
sl@0
|
1791 |
TReleaseGlyphOutlineParam param;
|
sl@0
|
1792 |
param.iCount = iCount;
|
sl@0
|
1793 |
param.iHinted = iHinted;
|
sl@0
|
1794 |
param.iCodes = iCodes;
|
sl@0
|
1795 |
|
sl@0
|
1796 |
if (NULL != iFont)
|
sl@0
|
1797 |
{
|
sl@0
|
1798 |
iFont->ExtendedFunction(KFontReleaseGlyphOutline, (TAny *)¶m);
|
sl@0
|
1799 |
}
|
sl@0
|
1800 |
|
sl@0
|
1801 |
iFont = NULL;
|
sl@0
|
1802 |
iCount = 0;
|
sl@0
|
1803 |
User::Free(iLengths);
|
sl@0
|
1804 |
iLengths = NULL;
|
sl@0
|
1805 |
iCursor = -1;
|
sl@0
|
1806 |
User::Free(iCodes);
|
sl@0
|
1807 |
iCodes = NULL;
|
sl@0
|
1808 |
User::Free(iOutlines);
|
sl@0
|
1809 |
iOutlines = NULL;
|
sl@0
|
1810 |
}
|