00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __LAYOUTENGINE_H
00010 #define __LAYOUTENGINE_H
00011
00012 #include "LETypes.h"
00013 #include "LEFontInstance.h"
00014 #include "LEGlyphFilter.h"
00015
00016 #include "unicode/utypes.h"
00017
00018 #include <string.h>
00019
00020 #define ARRAY_COPY(dst, src, count) memcpy(dst, src, (count) * sizeof (src)[0])
00021
00060 class U_LAYOUT_API LayoutEngine
00061 {
00062 protected:
00066 le_int32 fGlyphCount;
00067
00071 LEGlyphID *fGlyphs;
00072
00077 le_int32 *fCharIndices;
00078
00084 float *fPositions;
00085
00091 LEFontInstance *fFontInstance;
00092
00098 le_int32 fScriptCode;
00099
00105 le_int32 fLanguageCode;
00106
00118 LayoutEngine(LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode);
00119
00125 LayoutEngine();
00126
00150 virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphID *&glyphs, le_int32 *&charIndices);
00151
00166 virtual void positionGlyphs(const LEGlyphID glyphs[], le_int32 glyphCount, float x, float y, float *&positions);
00167
00189 virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphID glyphs[], le_int32 glyphCount, float positions[])
00190 {
00191
00192 };
00193
00204 virtual const void *getFontTable(LETag tableTag)
00205 {
00206 return fFontInstance->getFontTable(tableTag);
00207 };
00208
00233 virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror, LEGlyphID *&glyphs, le_int32 *&charIndices);
00234
00247 static void adjustMarkGlyphs(const LEGlyphID glyphs[], le_int32 glyphCount, le_bool reverse, LEGlyphFilter *markFilter, float positions[]);
00248
00249 public:
00256 virtual ~LayoutEngine();
00257
00276 le_int32 layoutChars(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, float x, float y);
00277
00285 void getGlyphs(LEGlyphID glyphs[])
00286 {
00287 ARRAY_COPY(glyphs, fGlyphs, fGlyphCount);
00288 };
00289
00299 void getGlyphs(le_uint32 glyphs[], le_uint32 extraBits);
00300
00308 void getCharIndices(le_int32 charIndices[])
00309 {
00310 ARRAY_COPY(charIndices, fCharIndices, fGlyphCount);
00311 };
00312
00321 void getCharIndices(le_int32 charIndices[], le_int32 indexBase);
00322
00330 void getGlyphPositions(float positions[])
00331 {
00332 ARRAY_COPY(positions, fPositions, fGlyphCount * 2 + 2);
00333 };
00334
00343 float getGlyphXPosition(le_int32 glyphIndex)
00344 {
00345 return fPositions[glyphIndex * 2];
00346 };
00347
00353 virtual void reset();
00354
00366 static LayoutEngine *layoutEngineFactory(LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode);
00367
00368 };
00369
00370 #endif
00371