Update contrib.
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __GLYPHSEL_H__
17 #define __GLYPHSEL_H__
22 #include "ShapeInfo.h"
28 void Panic(TGdiPanic aError);
30 class TGlyphSelectionState;
34 The Unicode char to use for glyph cluster without a base char
37 #define KUnicodeDottedCircle 0x25CC
41 // TUtf32Iterator Class declaration
47 Converts UTF16 encoded array of bytes into UTF32 characters,
48 ignoring non-characters and unpaired surrogates and
49 combining paired surrogates.
54 TUtf32Iterator(const TText16* aStart, const TText16* aEnd, TInt aOffset=0);
56 inline TBool AtEnd() const;
57 inline TBool BeforeStart() const;
60 void SetPos(TInt aOffset);
61 inline TChar Get() const;
62 TUint Get(TInt offset);
65 const TText16* CurrentPosition() const;
66 void SetCurrentPosition(const TText16*);
68 TInt LengthToStart() const;
69 TInt LengthToEnd() const;
72 TUint UTF16ToTChar(const TText16* a);
75 /** Start address of the UTF16 array */
76 const TText16* iStart;
77 /** Address of current position in array */
78 const TText16* iCurrent;
79 /** Address of the first entry past the end of the array */
82 /** UTF32 value of the character at the current iterator position */
89 // GlyphSelUtils Namespace declaration
94 namespace GlyphSelUtils
96 This namespace holds a collection of useful common utility
97 functions used in glyph selection. These functions are intended to be
98 used by the glyph selector classes.
102 inline TBool IsSurrogate(TText a)
104 return 0xD800 == (a & 0xF800);
107 inline TBool IsHighSurrogate(TText a)
109 return 0xD800 == (a & 0xFC00);
112 inline TBool IsLowSurrogate(TText a)
114 return 0xDC00 == (a & 0xFC00);
117 inline TChar PairSurrogates(TText aHigh, TText aLow)
119 return ((aHigh - 0xd7f7) << 10) + aLow;
122 inline TBool IsThaiCharacter(TUint code)
124 return ((code > 0x0E00 && code < 0x0E3B) ||
125 (code > 0x0E3E && code < 0x0E5C));
133 // TGlyphSelectionState Class declaration
138 class TGlyphSelectionState
140 This container class holds the data for glyph selection algorithm and is
141 used to pass this data around the algorithm methods.
148 Enum used in glyph selection code indicating if a pen advance is needed following
149 the processing of the current glyph.
156 enum TGlyphClusterStateOverride
158 These enumeration values are used by the glyph selector classes to indicated
159 back to the glyph selection algorithm when they find a cluster complete.
166 enum TGlyphPostCombine
168 These enumeration values are used by the glyph selector classes to decide whether
169 post combining is needed to combine the diacritic to the base character.
177 TGlyphSelectionState(TUtf32Iterator& aIter, const CFont* aFont, CFont::TPositionParam& aParam)
178 : iCodePt(0xFFFF), iCodeChar(0xFFFF), iCombCls(-1), iCats(0),
179 iText(aIter), iFont(aFont), iParam(aParam),
180 iClusterState(EGClusterNotComplete), iPen(EPenAdvance_No),
181 iAdvance(), iLigaturePortionsRemaining(0), iGlyphPostCombine(EGPostCombine_No) { };
183 TBool IsCombiningClass() { return (iCats & 0xF0) == TChar::EMarkGroup; }
184 void CombineLastGlyphToBase(const TRect& aBase, TInt aFirstDiacritic);
186 TBool AppendGlyphToCluster(TUint code);
189 /** The properties of the current character being processed */
195 /** The Unicode iterator to the text processed */
196 TUtf32Iterator& iText;
198 /** The font to select glyphs from */
201 /** The in/out parameter data to the glyph selection code from outside */
202 CFont::TPositionParam& iParam;
204 /** Result from the glyph selector class as to whether it thinks the
205 cluster is complete or incomplete.
207 TGlyphClusterStateOverride iClusterState;
209 /** These hold the possible pen advance and if it should be applied */
213 /** Can be used in any way or not at all by the processing function. It is
214 set to 0 on intitialisation. Suggested use is to pass information about
215 which part of a ligature is currently having diacritics attatched to it. */
216 TInt iLigaturePortionsRemaining;
217 /** Can be used in any way or not at all by the processing function. It is
218 not initialised. Suggested use is to record the position in the output
219 glyph array of the first diacritic on this portion of the ligature. */
220 TInt iLigaturePortionFirstMark;
223 Result from the glyph selector class as to whether it needs to
224 combine the diacritic with the base character.
226 TGlyphPostCombine iGlyphPostCombine;
232 // GlyphSelector_SoftHyphen Class declaration
236 class GlyphSelector_SoftHyphen
238 This glyph selector class processes the Unicode soft hyphen U+00AD
240 This is a discretionary hyphen, i.e. it is only rendered when required
241 and in Symbian OS that is when it is found at the end of a line.
247 static TBool Process(TGlyphSelectionState& aGss, RShapeInfo&);
253 // GlyphSelector_Default Class declaration
257 class GlyphSelector_Default
259 This is the default glyph selector class which has the behaviour of outputting
260 all glyphs it is invoked to process.
266 static TBool Process(TGlyphSelectionState& aGss, RShapeInfo&);
271 // TUtf32Iterator inline Function definitions.
275 inline TBool TUtf32Iterator::AtEnd() const
277 return iEnd == iCurrent;
280 inline TBool TUtf32Iterator::BeforeStart() const
282 return iStart > iCurrent;
285 inline TChar TUtf32Iterator::Get() const
287 __ASSERT_DEBUG(iCurrent >= iStart && iCurrent < iEnd, Panic(EGdiPanic_OutOfText));
292 #endif // __GLYPHSEL_H__