sl@0
|
1 |
// Copyright (c) 2003-2009 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 |
/**
|
sl@0
|
17 |
@file
|
sl@0
|
18 |
@internalComponent
|
sl@0
|
19 |
*/
|
sl@0
|
20 |
|
sl@0
|
21 |
|
sl@0
|
22 |
#include <gdi.h>
|
sl@0
|
23 |
#include <openfont.h>
|
sl@0
|
24 |
#include "GlyphSel.h"
|
sl@0
|
25 |
#include "GDIPANIC.h"
|
sl@0
|
26 |
|
sl@0
|
27 |
|
sl@0
|
28 |
static const TText16 KLatinGlyph_SoftHyphen = 0x00AD;
|
sl@0
|
29 |
|
sl@0
|
30 |
|
sl@0
|
31 |
//
|
sl@0
|
32 |
//
|
sl@0
|
33 |
// TUtf32Iterator Class definition
|
sl@0
|
34 |
//
|
sl@0
|
35 |
//
|
sl@0
|
36 |
|
sl@0
|
37 |
|
sl@0
|
38 |
TUint TUtf32Iterator::UTF16ToTChar(const TText16* a)
|
sl@0
|
39 |
/**
|
sl@0
|
40 |
This routine takes an encoded UTF16 byte array and decodes the
|
sl@0
|
41 |
first character at the start of the array and returns it as a TChar.
|
sl@0
|
42 |
If the char is "not a char" character 0xFFFF results.
|
sl@0
|
43 |
@param a
|
sl@0
|
44 |
UTF16 byte array to be decoded.
|
sl@0
|
45 |
@param aPr
|
sl@0
|
46 |
Position pointer 'a' derived from, incremented if surragote pairs decoded.
|
sl@0
|
47 |
@return
|
sl@0
|
48 |
The character value in UTF32 format or 0xFFFF it not a character.
|
sl@0
|
49 |
*/
|
sl@0
|
50 |
{
|
sl@0
|
51 |
// Is next char a surrogate?
|
sl@0
|
52 |
if (0xD800 == (a[0] & 0xF800))
|
sl@0
|
53 |
{
|
sl@0
|
54 |
// Is it a high surrogate in the range D800..DBFF?
|
sl@0
|
55 |
if (0xD800 == (a[0] & 0xFC00))
|
sl@0
|
56 |
{
|
sl@0
|
57 |
// Its a high surrogate, is the next char a low surrogate?
|
sl@0
|
58 |
if (0xDC00 == (a[1] & 0xFC00))
|
sl@0
|
59 |
{
|
sl@0
|
60 |
// It's a low surrogate
|
sl@0
|
61 |
return ((a[0] - 0xd7f7) << 10) + a[1];
|
sl@0
|
62 |
}
|
sl@0
|
63 |
else
|
sl@0
|
64 |
return 0xFFFF;
|
sl@0
|
65 |
}
|
sl@0
|
66 |
else
|
sl@0
|
67 |
return 0xFFFF;
|
sl@0
|
68 |
}
|
sl@0
|
69 |
else
|
sl@0
|
70 |
return a[0];
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
|
sl@0
|
74 |
TUtf32Iterator::TUtf32Iterator(const TText16* aStart, const TText16* aEnd, TInt aStartingIndex)
|
sl@0
|
75 |
/**
|
sl@0
|
76 |
Construct iterator given UTF16 encoded byte array.
|
sl@0
|
77 |
@param aStart
|
sl@0
|
78 |
Start address of the array.
|
sl@0
|
79 |
@param aEnd
|
sl@0
|
80 |
Address of the byte just beyond the end of the array.
|
sl@0
|
81 |
@param aStartingIndex
|
sl@0
|
82 |
Optional UTF16 offset into the array to initialise the current position to.
|
sl@0
|
83 |
@panic EGdiPanic_InvalidInputParam
|
sl@0
|
84 |
Raised when array start if passed the array end.
|
sl@0
|
85 |
*/
|
sl@0
|
86 |
: iStart(aStart), iCurrent(aStart+aStartingIndex), iEnd(aEnd), iChar(0xffff)
|
sl@0
|
87 |
{
|
sl@0
|
88 |
GDI_ASSERT_DEBUG(iStart < iEnd, EGdiPanic_InvalidInputParam);
|
sl@0
|
89 |
|
sl@0
|
90 |
if (iCurrent > iEnd)
|
sl@0
|
91 |
iCurrent = iEnd;
|
sl@0
|
92 |
else if (iCurrent < iStart)
|
sl@0
|
93 |
iCurrent = iStart;
|
sl@0
|
94 |
else
|
sl@0
|
95 |
{
|
sl@0
|
96 |
// Sanatise array end checking for an unpaired surrogate value
|
sl@0
|
97 |
// so that UTF16ToTChar() does not read off the end of the array.
|
sl@0
|
98 |
if (0xD800 == (iEnd[-1] & 0xFC00))
|
sl@0
|
99 |
{
|
sl@0
|
100 |
if (iCurrent == iEnd-1)
|
sl@0
|
101 |
++iCurrent;
|
sl@0
|
102 |
else
|
sl@0
|
103 |
--iEnd;
|
sl@0
|
104 |
}
|
sl@0
|
105 |
|
sl@0
|
106 |
// Setup initial position UTF32 character value
|
sl@0
|
107 |
iChar = UTF16ToTChar(iCurrent);
|
sl@0
|
108 |
}
|
sl@0
|
109 |
}
|
sl@0
|
110 |
|
sl@0
|
111 |
|
sl@0
|
112 |
TChar TUtf32Iterator::Next()
|
sl@0
|
113 |
/**
|
sl@0
|
114 |
Moves the iterator forward to the next valid UTF32 character value.
|
sl@0
|
115 |
@return TChar The next character in the text towards the end.
|
sl@0
|
116 |
@panic EGdiPanic_OutOfText
|
sl@0
|
117 |
Raised when there is no next position to move to.
|
sl@0
|
118 |
*/
|
sl@0
|
119 |
{
|
sl@0
|
120 |
GDI_ASSERT_DEBUG(iCurrent < iEnd, EGdiPanic_OutOfText);
|
sl@0
|
121 |
|
sl@0
|
122 |
iCurrent += (iChar > 0xffff) ? 2 : 1;
|
sl@0
|
123 |
if (iCurrent < iEnd)
|
sl@0
|
124 |
iChar = UTF16ToTChar(iCurrent);
|
sl@0
|
125 |
else
|
sl@0
|
126 |
iChar = 0xFFFF;
|
sl@0
|
127 |
return iChar;
|
sl@0
|
128 |
}
|
sl@0
|
129 |
|
sl@0
|
130 |
|
sl@0
|
131 |
TChar TUtf32Iterator::Prev()
|
sl@0
|
132 |
/**
|
sl@0
|
133 |
Moves the iterator backwards to the next valid UTF32 character value.
|
sl@0
|
134 |
@return TChar The prev character in the text towards the start.
|
sl@0
|
135 |
@panic EGdiPanic_OutOfText Raised when there is no next position to move to.
|
sl@0
|
136 |
*/
|
sl@0
|
137 |
{
|
sl@0
|
138 |
GDI_ASSERT_DEBUG(iCurrent >= iStart, EGdiPanic_OutOfText);
|
sl@0
|
139 |
|
sl@0
|
140 |
--iCurrent;
|
sl@0
|
141 |
if (iCurrent >= iStart)
|
sl@0
|
142 |
iChar = UTF16ToTChar(iCurrent);
|
sl@0
|
143 |
else
|
sl@0
|
144 |
iChar = 0xFFFF;
|
sl@0
|
145 |
return iChar;
|
sl@0
|
146 |
}
|
sl@0
|
147 |
|
sl@0
|
148 |
|
sl@0
|
149 |
void TUtf32Iterator::SetPos(TInt aPos)
|
sl@0
|
150 |
/**
|
sl@0
|
151 |
Moves the iterator to the position specified by array start+offset.
|
sl@0
|
152 |
@param aPos
|
sl@0
|
153 |
UTF16 offset into the array to set the current position to.
|
sl@0
|
154 |
@panic EGdiPanic_OutOfText
|
sl@0
|
155 |
Raised when there is no next position to move to.
|
sl@0
|
156 |
*/
|
sl@0
|
157 |
{
|
sl@0
|
158 |
GDI_ASSERT_DEBUG(iStart+aPos <= iEnd, EGdiPanic_OutOfText);
|
sl@0
|
159 |
GDI_ASSERT_DEBUG(iStart+aPos >= iStart, EGdiPanic_OutOfText);
|
sl@0
|
160 |
|
sl@0
|
161 |
iCurrent = iStart+aPos;
|
sl@0
|
162 |
iChar = UTF16ToTChar(iCurrent);
|
sl@0
|
163 |
}
|
sl@0
|
164 |
|
sl@0
|
165 |
|
sl@0
|
166 |
TUint TUtf32Iterator::Get(TInt offset)
|
sl@0
|
167 |
/**
|
sl@0
|
168 |
Returns the UTF32 char value at the offset specified. 0xFFFF may be returned
|
sl@0
|
169 |
for unpaired surrogate and noncharacters. Does not change the current
|
sl@0
|
170 |
position.
|
sl@0
|
171 |
@param offset
|
sl@0
|
172 |
UTF16 offset from current iterator position to get UTF32 char form.
|
sl@0
|
173 |
@return TChar
|
sl@0
|
174 |
UTF32 char value found at the iterator+offset, or 0xFFFF in error.
|
sl@0
|
175 |
@panic EGdiPanic_OutOfText
|
sl@0
|
176 |
Raised when offset found to be outside the bounds of the original text array.
|
sl@0
|
177 |
*/
|
sl@0
|
178 |
{
|
sl@0
|
179 |
GDI_ASSERT_DEBUG(iCurrent+offset >= iStart, EGdiPanic_OutOfText);
|
sl@0
|
180 |
GDI_ASSERT_DEBUG(iCurrent+offset < iEnd, EGdiPanic_OutOfText);
|
sl@0
|
181 |
|
sl@0
|
182 |
return UTF16ToTChar(iCurrent+offset);
|
sl@0
|
183 |
}
|
sl@0
|
184 |
|
sl@0
|
185 |
|
sl@0
|
186 |
TChar TUtf32Iterator::GetThenNext()
|
sl@0
|
187 |
/**
|
sl@0
|
188 |
Return the UTF32 value at the current position.
|
sl@0
|
189 |
@return TChar
|
sl@0
|
190 |
UTF32 value currently pointed to by iterator.
|
sl@0
|
191 |
@panic EGdiPanic_EndOfText
|
sl@0
|
192 |
Raised when current iterator position is not valid.
|
sl@0
|
193 |
*/
|
sl@0
|
194 |
{
|
sl@0
|
195 |
GDI_ASSERT_DEBUG(iCurrent < iEnd, EGdiPanic_OutOfText);
|
sl@0
|
196 |
|
sl@0
|
197 |
TChar current(iChar);
|
sl@0
|
198 |
iCurrent += (iChar > 0xffff) ? 2 : 1;
|
sl@0
|
199 |
if (iCurrent < iEnd)
|
sl@0
|
200 |
iChar = UTF16ToTChar(iCurrent);
|
sl@0
|
201 |
else
|
sl@0
|
202 |
iChar = 0xFFFF;
|
sl@0
|
203 |
return current;
|
sl@0
|
204 |
}
|
sl@0
|
205 |
|
sl@0
|
206 |
|
sl@0
|
207 |
TChar TUtf32Iterator::GetThenPrev()
|
sl@0
|
208 |
/**
|
sl@0
|
209 |
Return the UTF32 value at the current position.
|
sl@0
|
210 |
@return TChar
|
sl@0
|
211 |
UTF32 value currently pointed to by iterator.
|
sl@0
|
212 |
@panic EGdiPanic_EndOfText
|
sl@0
|
213 |
Raised when current iterator position is not valid.
|
sl@0
|
214 |
*/
|
sl@0
|
215 |
{
|
sl@0
|
216 |
GDI_ASSERT_DEBUG(iCurrent >= iStart, EGdiPanic_OutOfText);
|
sl@0
|
217 |
|
sl@0
|
218 |
TChar current(iChar);
|
sl@0
|
219 |
--iCurrent;
|
sl@0
|
220 |
if (iCurrent >= iStart)
|
sl@0
|
221 |
iChar = UTF16ToTChar(iCurrent);
|
sl@0
|
222 |
else
|
sl@0
|
223 |
iChar = 0xFFFF;
|
sl@0
|
224 |
return current;
|
sl@0
|
225 |
}
|
sl@0
|
226 |
|
sl@0
|
227 |
|
sl@0
|
228 |
TInt TUtf32Iterator::LengthToStart() const
|
sl@0
|
229 |
/**
|
sl@0
|
230 |
Returns the number of TText16 codes between the start point and its
|
sl@0
|
231 |
current position.
|
sl@0
|
232 |
@return TInt
|
sl@0
|
233 |
Number of TText16 characters between array start and current iterator
|
sl@0
|
234 |
position.
|
sl@0
|
235 |
*/
|
sl@0
|
236 |
{
|
sl@0
|
237 |
return iCurrent-iStart;
|
sl@0
|
238 |
}
|
sl@0
|
239 |
|
sl@0
|
240 |
|
sl@0
|
241 |
TInt TUtf32Iterator::LengthToEnd() const
|
sl@0
|
242 |
/**
|
sl@0
|
243 |
Returns the number of remaining TText16 codes still ahead of the
|
sl@0
|
244 |
iterator.
|
sl@0
|
245 |
@return TInt
|
sl@0
|
246 |
Number of TText16 characters between array current iterator position
|
sl@0
|
247 |
and the end of the array.
|
sl@0
|
248 |
*/
|
sl@0
|
249 |
{
|
sl@0
|
250 |
return iEnd - iCurrent;
|
sl@0
|
251 |
}
|
sl@0
|
252 |
|
sl@0
|
253 |
const TText16* TUtf32Iterator::CurrentPosition() const
|
sl@0
|
254 |
{
|
sl@0
|
255 |
return iCurrent;
|
sl@0
|
256 |
}
|
sl@0
|
257 |
|
sl@0
|
258 |
void TUtf32Iterator::SetCurrentPosition(const TText16* a)
|
sl@0
|
259 |
{
|
sl@0
|
260 |
iCurrent = a;
|
sl@0
|
261 |
}
|
sl@0
|
262 |
|
sl@0
|
263 |
//
|
sl@0
|
264 |
//
|
sl@0
|
265 |
// TGlyphSelectionState Class definition
|
sl@0
|
266 |
//
|
sl@0
|
267 |
//
|
sl@0
|
268 |
|
sl@0
|
269 |
|
sl@0
|
270 |
/**
|
sl@0
|
271 |
The Unicode Combining Class values recognised by the
|
sl@0
|
272 |
GlyphSelUtils::CombineLastGlyphToBase method.
|
sl@0
|
273 |
@internalComponent
|
sl@0
|
274 |
*/
|
sl@0
|
275 |
enum TCombiningClass
|
sl@0
|
276 |
{
|
sl@0
|
277 |
EArabicFathatan = 27,
|
sl@0
|
278 |
EArabicDammatan = 28,
|
sl@0
|
279 |
EArabicKasratan = 29,
|
sl@0
|
280 |
EArabicFatha = 30,
|
sl@0
|
281 |
EArabicDamma = 31,
|
sl@0
|
282 |
EArabicKasra = 32,
|
sl@0
|
283 |
EArabicShadda = 33,
|
sl@0
|
284 |
EArabicSukun = 34,
|
sl@0
|
285 |
ECombineBelowLeftAttached = 200,
|
sl@0
|
286 |
ECombineBelowAttached = 202,
|
sl@0
|
287 |
ECombineBelowRightAttached = 204,
|
sl@0
|
288 |
ECombineLeftAttached = 208,
|
sl@0
|
289 |
ECombineRightAttached = 210,
|
sl@0
|
290 |
ECombineAboveLeftAttached = 212,
|
sl@0
|
291 |
ECombineAboveAttached = 214,
|
sl@0
|
292 |
ECombineAboveRightAttached = 216,
|
sl@0
|
293 |
ECombineBelowLeft = 218,
|
sl@0
|
294 |
ECombineBelow = 220,
|
sl@0
|
295 |
ECombineBelowRight = 222,
|
sl@0
|
296 |
ECombineLeft = 224,
|
sl@0
|
297 |
ECombineRight = 226,
|
sl@0
|
298 |
ECombineAboveLeft = 228,
|
sl@0
|
299 |
ECombineAbove = 230,
|
sl@0
|
300 |
ECombineAboveRight = 232
|
sl@0
|
301 |
};
|
sl@0
|
302 |
|
sl@0
|
303 |
|
sl@0
|
304 |
/**
|
sl@0
|
305 |
This method is called to attach (by adjusing its bounding box) the current end
|
sl@0
|
306 |
glyph in the output array of iParam to the base glyph bounding box based on
|
sl@0
|
307 |
the Unicode combining class of the character.
|
sl@0
|
308 |
@param aGss
|
sl@0
|
309 |
The general input/output glyph selection data for the routine.
|
sl@0
|
310 |
@param aGss.iOutput
|
sl@0
|
311 |
Input: Glyph cluster with last glyph an actual combining character. Output:
|
sl@0
|
312 |
Bounding box of last glyph adjusted according to char combining class.
|
sl@0
|
313 |
@param aFirstDiacritic
|
sl@0
|
314 |
Which character in the output array to treat as the first diacritic of the
|
sl@0
|
315 |
cluster. Usually 1, but can be more if the base class is a ligature.
|
sl@0
|
316 |
*/
|
sl@0
|
317 |
void TGlyphSelectionState::CombineLastGlyphToBase(const TRect& aBase, TInt aFirstDiacritic)
|
sl@0
|
318 |
{
|
sl@0
|
319 |
// Get the bounds of all the base characters.
|
sl@0
|
320 |
TRect base = aBase;
|
sl@0
|
321 |
int last = iParam.iOutputGlyphs-1;
|
sl@0
|
322 |
for (int i = aFirstDiacritic; i < last; i++)
|
sl@0
|
323 |
base.BoundingRect(iParam.iOutput[i].iBounds);
|
sl@0
|
324 |
|
sl@0
|
325 |
// Calculate the attachment points.
|
sl@0
|
326 |
TRect& r = iParam.iOutput[last].iBounds;
|
sl@0
|
327 |
int w = r.Width();
|
sl@0
|
328 |
int h = r.Height();
|
sl@0
|
329 |
int t = r.iTl.iY;
|
sl@0
|
330 |
int l = r.iTl.iX;
|
sl@0
|
331 |
int left = base.iTl.iX;
|
sl@0
|
332 |
int center = base.iTl.iX + (base.Width() - w) / 2;
|
sl@0
|
333 |
int right = base.iBr.iX - w;
|
sl@0
|
334 |
int below = base.iBr.iY;
|
sl@0
|
335 |
int above = base.iTl.iY - h;
|
sl@0
|
336 |
int left_of = left - w;
|
sl@0
|
337 |
int right_of = right + w;
|
sl@0
|
338 |
int xGap = 1;
|
sl@0
|
339 |
int yGap = iFont->HeightInPixels()/10;
|
sl@0
|
340 |
|
sl@0
|
341 |
// Select attachment based on combining class.
|
sl@0
|
342 |
switch (iCombCls)
|
sl@0
|
343 |
{
|
sl@0
|
344 |
case ECombineBelowLeftAttached:
|
sl@0
|
345 |
t = below;
|
sl@0
|
346 |
l = left;
|
sl@0
|
347 |
break;
|
sl@0
|
348 |
case ECombineBelowAttached:
|
sl@0
|
349 |
t = below;
|
sl@0
|
350 |
l = center;
|
sl@0
|
351 |
break;
|
sl@0
|
352 |
case ECombineBelowRightAttached:
|
sl@0
|
353 |
t = below;
|
sl@0
|
354 |
l = right;
|
sl@0
|
355 |
break;
|
sl@0
|
356 |
case ECombineLeftAttached:
|
sl@0
|
357 |
l = left_of;
|
sl@0
|
358 |
break;
|
sl@0
|
359 |
case ECombineRightAttached:
|
sl@0
|
360 |
l = right_of;
|
sl@0
|
361 |
break;
|
sl@0
|
362 |
case ECombineAboveLeftAttached:
|
sl@0
|
363 |
t = above;
|
sl@0
|
364 |
l = left;
|
sl@0
|
365 |
break;
|
sl@0
|
366 |
case ECombineAboveAttached:
|
sl@0
|
367 |
t = above;
|
sl@0
|
368 |
l = center;
|
sl@0
|
369 |
break;
|
sl@0
|
370 |
case ECombineAboveRightAttached:
|
sl@0
|
371 |
t = above;
|
sl@0
|
372 |
l = right;
|
sl@0
|
373 |
break;
|
sl@0
|
374 |
case ECombineBelowLeft:
|
sl@0
|
375 |
t = below + yGap;
|
sl@0
|
376 |
l = left;
|
sl@0
|
377 |
break;
|
sl@0
|
378 |
case ECombineBelow:
|
sl@0
|
379 |
case EArabicKasratan:
|
sl@0
|
380 |
case EArabicKasra:
|
sl@0
|
381 |
t = below + yGap;
|
sl@0
|
382 |
l = center;
|
sl@0
|
383 |
break;
|
sl@0
|
384 |
case ECombineBelowRight:
|
sl@0
|
385 |
t = below + yGap;
|
sl@0
|
386 |
l = right;
|
sl@0
|
387 |
break;
|
sl@0
|
388 |
case ECombineLeft:
|
sl@0
|
389 |
l = left_of - xGap;
|
sl@0
|
390 |
break;
|
sl@0
|
391 |
case ECombineRight:
|
sl@0
|
392 |
l = right_of + xGap;
|
sl@0
|
393 |
break;
|
sl@0
|
394 |
case ECombineAboveLeft:
|
sl@0
|
395 |
t = above - yGap;
|
sl@0
|
396 |
l = left;
|
sl@0
|
397 |
break;
|
sl@0
|
398 |
case ECombineAbove:
|
sl@0
|
399 |
case EArabicFathatan:
|
sl@0
|
400 |
case EArabicDammatan:
|
sl@0
|
401 |
case EArabicFatha:
|
sl@0
|
402 |
case EArabicDamma:
|
sl@0
|
403 |
case EArabicShadda:
|
sl@0
|
404 |
case EArabicSukun:
|
sl@0
|
405 |
t = above - yGap;
|
sl@0
|
406 |
l = center;
|
sl@0
|
407 |
break;
|
sl@0
|
408 |
case ECombineAboveRight:
|
sl@0
|
409 |
t = above - yGap;
|
sl@0
|
410 |
l = right;
|
sl@0
|
411 |
break;
|
sl@0
|
412 |
default:
|
sl@0
|
413 |
l = center;
|
sl@0
|
414 |
break;
|
sl@0
|
415 |
}
|
sl@0
|
416 |
|
sl@0
|
417 |
// Adjust the bounding box of the last glyph to fix position
|
sl@0
|
418 |
// based on the characters combining class. For speed, do directly.
|
sl@0
|
419 |
// r.SetRect(l,t,l + w,t + h);
|
sl@0
|
420 |
r.iTl.iX = l;
|
sl@0
|
421 |
r.iTl.iY = t;
|
sl@0
|
422 |
r.iBr.iX = l+w;
|
sl@0
|
423 |
r.iBr.iY = t+h;
|
sl@0
|
424 |
}
|
sl@0
|
425 |
|
sl@0
|
426 |
|
sl@0
|
427 |
TBool TGlyphSelectionState::AppendGlyphToCluster(TUint aCode)
|
sl@0
|
428 |
/**
|
sl@0
|
429 |
This common method is used by glyph selector classes to add a glyph to
|
sl@0
|
430 |
the end of the aGss.iParam output field filling in all the glyph info
|
sl@0
|
431 |
needed.
|
sl@0
|
432 |
@param aCode
|
sl@0
|
433 |
The Unicode character for which a glyph should be appended.
|
sl@0
|
434 |
@param aGss
|
sl@0
|
435 |
The general input/output glyph selection data for the routine.
|
sl@0
|
436 |
@return TBool
|
sl@0
|
437 |
ETrue when successful, EFalse when failure occurs e..g no char data, overflow
|
sl@0
|
438 |
*/
|
sl@0
|
439 |
{
|
sl@0
|
440 |
// Setup reference to next free glyph record we need to update.
|
sl@0
|
441 |
GDI_ASSERT_DEBUG(iParam.iOutputGlyphs < CFont::TPositionParam::EMaxOutputGlyphs,
|
sl@0
|
442 |
EGdiPanic_InvalidInputParam);
|
sl@0
|
443 |
|
sl@0
|
444 |
CFont::TPositionParam::TOutput* output = iParam.iOutput+iParam.iOutputGlyphs;
|
sl@0
|
445 |
|
sl@0
|
446 |
// Retrieve the glyph details from the Font. Essential to proceed, abort
|
sl@0
|
447 |
// if not available.
|
sl@0
|
448 |
TOpenFontCharMetrics metrics;
|
sl@0
|
449 |
if (iFont->GetCharacterData(aCode, metrics, output->iBitmap,
|
sl@0
|
450 |
output->iBitmapSize) == CFont::ENoCharacterData)
|
sl@0
|
451 |
return EFalse;
|
sl@0
|
452 |
|
sl@0
|
453 |
// Set code point of glyph in output record.
|
sl@0
|
454 |
output->iCode = aCode;
|
sl@0
|
455 |
|
sl@0
|
456 |
// Set the glyph's bounds in the output record and record pen advancement.
|
sl@0
|
457 |
if (iParam.iDirection == CFont::EVertical)
|
sl@0
|
458 |
{
|
sl@0
|
459 |
metrics.GetVertBounds(output->iBounds);
|
sl@0
|
460 |
iAdvance.iHeight = Max(iAdvance.iHeight, metrics.VertAdvance());
|
sl@0
|
461 |
}
|
sl@0
|
462 |
else
|
sl@0
|
463 |
{
|
sl@0
|
464 |
metrics.GetHorizBounds(output->iBounds);
|
sl@0
|
465 |
iAdvance.iWidth = Max(iAdvance.iWidth, metrics.HorizAdvance());
|
sl@0
|
466 |
}
|
sl@0
|
467 |
|
sl@0
|
468 |
// Next adjust the glyph's bounding box to offset it from the pen
|
sl@0
|
469 |
// position (origin of drawing). For speed increment attributes directly.
|
sl@0
|
470 |
// output->iBounds.Move(aGss.iParam.iPen);
|
sl@0
|
471 |
output->iBounds.iTl.iX += iParam.iPen.iX;
|
sl@0
|
472 |
output->iBounds.iBr.iX += iParam.iPen.iX;
|
sl@0
|
473 |
output->iBounds.iTl.iY += iParam.iPen.iY;
|
sl@0
|
474 |
output->iBounds.iBr.iY += iParam.iPen.iY;
|
sl@0
|
475 |
|
sl@0
|
476 |
// Before we exit with success, increment the glyph array counter.
|
sl@0
|
477 |
// for the new glyph we've added here.
|
sl@0
|
478 |
iParam.iOutputGlyphs++;
|
sl@0
|
479 |
return ETrue;
|
sl@0
|
480 |
}
|
sl@0
|
481 |
|
sl@0
|
482 |
|
sl@0
|
483 |
//
|
sl@0
|
484 |
//
|
sl@0
|
485 |
// GlyphSelector_SoftHyphen Class definition
|
sl@0
|
486 |
//
|
sl@0
|
487 |
//
|
sl@0
|
488 |
|
sl@0
|
489 |
TBool GlyphSelector_SoftHyphen::Process(TGlyphSelectionState& aGss, RShapeInfo&)
|
sl@0
|
490 |
/**
|
sl@0
|
491 |
@see GlyphSelUtils
|
sl@0
|
492 |
See this class for the method description.
|
sl@0
|
493 |
*/
|
sl@0
|
494 |
{
|
sl@0
|
495 |
aGss.iText.Next();
|
sl@0
|
496 |
if (!aGss.iText.AtEnd())
|
sl@0
|
497 |
{
|
sl@0
|
498 |
// Here we skip & don't output hyphen since its not at the end a line.
|
sl@0
|
499 |
aGss.iPen = TGlyphSelectionState::EPenAdvance_No;
|
sl@0
|
500 |
}
|
sl@0
|
501 |
else
|
sl@0
|
502 |
{
|
sl@0
|
503 |
// If we reach here we must output hyphen.
|
sl@0
|
504 |
if (!aGss.AppendGlyphToCluster(KLatinGlyph_SoftHyphen))
|
sl@0
|
505 |
return EFalse;
|
sl@0
|
506 |
|
sl@0
|
507 |
aGss.iPen = TGlyphSelectionState::EPenAdvance_Yes;
|
sl@0
|
508 |
}
|
sl@0
|
509 |
|
sl@0
|
510 |
// Logic to determine if we are now at the end of the glyph cluster.
|
sl@0
|
511 |
// Default logic, based on whether a combining mark follows or not.
|
sl@0
|
512 |
aGss.iClusterState =
|
sl@0
|
513 |
(!aGss.iText.AtEnd() &&
|
sl@0
|
514 |
((aGss.iText.Get().GetCategory() & 0xF0) == TChar::EMarkGroup)) ?
|
sl@0
|
515 |
TGlyphSelectionState::EGClusterNotComplete : TGlyphSelectionState::EGClusterComplete;
|
sl@0
|
516 |
|
sl@0
|
517 |
return ETrue;
|
sl@0
|
518 |
}
|
sl@0
|
519 |
|
sl@0
|
520 |
|
sl@0
|
521 |
//
|
sl@0
|
522 |
//
|
sl@0
|
523 |
// GlyphSelector_Default Class definition
|
sl@0
|
524 |
//
|
sl@0
|
525 |
//
|
sl@0
|
526 |
|
sl@0
|
527 |
|
sl@0
|
528 |
TBool GlyphSelector_Default::Process(TGlyphSelectionState& aGss, RShapeInfo&)
|
sl@0
|
529 |
/**
|
sl@0
|
530 |
@see GlyphSelUtils
|
sl@0
|
531 |
See this class for the method description.
|
sl@0
|
532 |
*/
|
sl@0
|
533 |
{
|
sl@0
|
534 |
|
sl@0
|
535 |
// In this method we always output the glyph.
|
sl@0
|
536 |
if (!aGss.AppendGlyphToCluster(aGss.iText.GetThenNext()))
|
sl@0
|
537 |
return EFalse;
|
sl@0
|
538 |
|
sl@0
|
539 |
// Adjust glyph's bounds further to position this character if it is a
|
sl@0
|
540 |
// combining mark
|
sl@0
|
541 |
if (aGss.IsCombiningClass())
|
sl@0
|
542 |
{
|
sl@0
|
543 |
aGss.iPen = TGlyphSelectionState::EPenAdvance_No;
|
sl@0
|
544 |
|
sl@0
|
545 |
TRect baseBounds(aGss.iParam.iOutput[0].iBounds);
|
sl@0
|
546 |
// Get first character in this glyph cluster. In this default process function, the iCode should
|
sl@0
|
547 |
// be Unicode Point Code.
|
sl@0
|
548 |
TChar startChar = TChar(aGss.iParam.iOutput[0].iCode);
|
sl@0
|
549 |
// Character index in the output array to treat as the first diacritic of the
|
sl@0
|
550 |
// cluster. It will be used as first character for combine to. usually 1, but when
|
sl@0
|
551 |
// the cluster starts with a combining mark, it should be set to 0.
|
sl@0
|
552 |
TInt indexOfFirstCombining = 1;
|
sl@0
|
553 |
TInt startCharCat = startChar.GetCategory() & 0xF0;
|
sl@0
|
554 |
|
sl@0
|
555 |
// if the first character in this cluster is a combining mark or a graphically empty character,
|
sl@0
|
556 |
// (such as a space Character0x0020), a fake bound, formed from the Ascent of the font, will be
|
sl@0
|
557 |
// used for combining
|
sl@0
|
558 |
if ((startCharCat == TChar::EMarkGroup) || baseBounds.Size() == TSize(0,0))
|
sl@0
|
559 |
{
|
sl@0
|
560 |
// Determine the height of the combining glyph.
|
sl@0
|
561 |
TInt glyphHeight = 0;
|
sl@0
|
562 |
if (aGss.iParam.iOutputGlyphs == 1)
|
sl@0
|
563 |
{
|
sl@0
|
564 |
glyphHeight = aGss.iParam.iOutput[0].iBitmapSize.iHeight;
|
sl@0
|
565 |
}
|
sl@0
|
566 |
else
|
sl@0
|
567 |
{
|
sl@0
|
568 |
glyphHeight = aGss.iParam.iOutput[1].iBitmapSize.iHeight;
|
sl@0
|
569 |
}
|
sl@0
|
570 |
// Adjust Y values to a ficticious but reasonable range for it to combine to using the glyph height to adjust correctly below the font ascent.
|
sl@0
|
571 |
baseBounds.iTl.iY = aGss.iParam.iPen.iY - aGss.iFont->AscentInPixels() + glyphHeight; //modest ascender
|
sl@0
|
572 |
baseBounds.iBr.iY = aGss.iParam.iPen.iY; //No descender
|
sl@0
|
573 |
}
|
sl@0
|
574 |
|
sl@0
|
575 |
if (startCharCat == TChar::EMarkGroup)
|
sl@0
|
576 |
indexOfFirstCombining = 0;
|
sl@0
|
577 |
|
sl@0
|
578 |
aGss.CombineLastGlyphToBase(baseBounds, indexOfFirstCombining);
|
sl@0
|
579 |
aGss.iGlyphPostCombine = TGlyphSelectionState::EGPostCombine_Yes;
|
sl@0
|
580 |
}
|
sl@0
|
581 |
else
|
sl@0
|
582 |
aGss.iPen = TGlyphSelectionState::EPenAdvance_Yes;
|
sl@0
|
583 |
|
sl@0
|
584 |
// Logic to determine if we are now at the end of the glyph cluster.
|
sl@0
|
585 |
// Default logic, based on whether a combining mark follows or not.
|
sl@0
|
586 |
aGss.iClusterState =
|
sl@0
|
587 |
(!aGss.iText.AtEnd() &&
|
sl@0
|
588 |
((aGss.iText.Get().GetCategory() & 0xF0) == TChar::EMarkGroup)) ?
|
sl@0
|
589 |
TGlyphSelectionState::EGClusterNotComplete : TGlyphSelectionState::EGClusterComplete;
|
sl@0
|
590 |
|
sl@0
|
591 |
return ETrue;
|
sl@0
|
592 |
}
|
sl@0
|
593 |
|