Update contrib.
1 // Copyright (c) 2003-2010 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__
21 //#include <textbase.h>
23 #include "ShapeInfo.h"
29 #ifndef __TEXTBASE_H__
30 #ifndef __GLYPHSEL_TEXTBASE_H__
31 #define __GLYPHSEL_TEXTBASE_H__
33 This enumeration holds the possible panic codes that may be raised
34 by the TextBase API on detecting an unrecoverable error. */
38 ETextBasePanic_Unknown = 0,
39 /** One or more of the input parameters to the interface were invalid */
40 ETextBasePanic_InvalidInputParam = 1,
41 /** Insufficient text for successful completion of the method */
42 ETextBasePanic_OutOfText = 2,
43 /** Internal failure. */
44 ETextBasePanic_Invariant = 3,
45 /** Reserved panic codes. Not to be used. */
46 ETextBasePanic_Reserved1 = 4,
47 ETextBasePanic_Reserved2 = 5,
48 /** Setting a typeface name that is too long */
49 ETextBasePanic_TypefaceNameOverflow = 6,
54 void TextBasePanic(TTextBasePanic aError);
56 class TGlyphSelectionState;
60 The Unicode char to use for glyph cluster without a base char
63 #define KUnicodeDottedCircle 0x25CC
67 // TUtf32Iterator Class declaration
73 Converts UTF16 encoded array of bytes into UTF32 characters,
74 ignoring non-characters and unpaired surrogates and
75 combining paired surrogates.
80 TUtf32Iterator(const TText16* aStart, const TText16* aEnd, TInt aOffset=0);
82 inline TBool AtEnd() const;
83 inline TBool BeforeStart() const;
86 void SetPos(TInt aOffset);
87 inline TChar Get() const;
88 TUint Get(TInt offset);
91 const TText16* CurrentPosition() const;
92 void SetCurrentPosition(const TText16*);
94 TInt LengthToStart() const;
95 TInt LengthToEnd() const;
98 TUint UTF16ToTChar(const TText16* a);
101 /** Start address of the UTF16 array */
102 const TText16* iStart;
103 /** Address of current position in array */
104 const TText16* iCurrent;
105 /** Address of the first entry past the end of the array */
108 /** UTF32 value of the character at the current iterator position */
115 // GlyphSelUtils Namespace declaration
120 namespace GlyphSelUtils
122 This namespace holds a collection of useful common utility
123 functions used in glyph selection. These functions are intended to be
124 used by the glyph selector classes.
128 inline TBool IsSurrogate(TText a)
130 return 0xD800 == (a & 0xF800);
133 inline TBool IsHighSurrogate(TText a)
135 return 0xD800 == (a & 0xFC00);
138 inline TBool IsLowSurrogate(TText a)
140 return 0xDC00 == (a & 0xFC00);
143 inline TChar PairSurrogates(TText aHigh, TText aLow)
145 return ((aHigh - 0xd7f7) << 10) + aLow;
148 inline TBool IsThaiCharacter(TUint code)
150 return ((code > 0x0E00 && code < 0x0E3B) ||
151 (code > 0x0E3E && code < 0x0E5C));
159 // TGlyphSelectionState Class declaration
164 class TGlyphSelectionState
166 This container class holds the data for glyph selection algorithm and is
167 used to pass this data around the algorithm methods.
174 Enum used in glyph selection code indicating if a pen advance is needed following
175 the processing of the current glyph.
182 enum TGlyphClusterStateOverride
184 These enumeration values are used by the glyph selector classes to indicated
185 back to the glyph selection algorithm when they find a cluster complete.
192 enum TGlyphPostCombine
194 These enumeration values are used by the glyph selector classes to decide whether
195 post combining is needed to combine the diacritic to the base character.
203 TGlyphSelectionState(TUtf32Iterator& aIter, const CFont* aFont, CFont::TPositionParam& aParam)
204 : iCodePt(0xFFFF), iCodeChar(0xFFFF), iCombCls(-1), iCats(0),
205 iText(aIter), iFont(aFont), iParam(aParam),
206 iClusterState(EGClusterNotComplete), iPen(EPenAdvance_No),
207 iAdvance(), iLigaturePortionsRemaining(0), iGlyphPostCombine(EGPostCombine_No) { };
209 TBool IsCombiningClass() { return (iCats & 0xF0) == TChar::EMarkGroup; }
210 void CombineLastGlyphToBase(const TRect& aBase, TInt aFirstDiacritic);
212 TBool AppendGlyphToCluster(TUint code);
215 /** The properties of the current character being processed */
221 /** The Unicode iterator to the text processed */
222 TUtf32Iterator& iText;
224 /** The font to select glyphs from */
227 /** The in/out parameter data to the glyph selection code from outside */
228 CFont::TPositionParam& iParam;
230 /** Result from the glyph selector class as to whether it thinks the
231 cluster is complete or incomplete.
233 TGlyphClusterStateOverride iClusterState;
235 /** These hold the possible pen advance and if it should be applied */
239 /** Can be used in any way or not at all by the processing function. It is
240 set to 0 on intitialisation. Suggested use is to pass information about
241 which part of a ligature is currently having diacritics attatched to it. */
242 TInt iLigaturePortionsRemaining;
243 /** Can be used in any way or not at all by the processing function. It is
244 not initialised. Suggested use is to record the position in the output
245 glyph array of the first diacritic on this portion of the ligature. */
246 TInt iLigaturePortionFirstMark;
249 Result from the glyph selector class as to whether it needs to
250 combine the diacritic with the base character.
252 TGlyphPostCombine iGlyphPostCombine;
258 // GlyphSelector_SoftHyphen Class declaration
262 class GlyphSelector_SoftHyphen
264 This glyph selector class processes the Unicode soft hyphen U+00AD
266 This is a discretionary hyphen, i.e. it is only rendered when required
267 and in Symbian OS that is when it is found at the end of a line.
273 static TBool Process(TGlyphSelectionState& aGss, RShapeInfo&);
279 // GlyphSelector_Default Class declaration
283 class GlyphSelector_Default
285 This is the default glyph selector class which has the behaviour of outputting
286 all glyphs it is invoked to process.
292 static TBool Process(TGlyphSelectionState& aGss, RShapeInfo&);
297 // TUtf32Iterator inline Function definitions.
301 inline TBool TUtf32Iterator::AtEnd() const
303 return iEnd == iCurrent;
306 inline TBool TUtf32Iterator::BeforeStart() const
308 return iStart > iCurrent;
311 inline TChar TUtf32Iterator::Get() const
313 __ASSERT_DEBUG(iCurrent >= iStart && iCurrent < iEnd, TextBasePanic(ETextBasePanic_OutOfText));
318 #endif // __GLYPHSEL_H__