00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __LAYOUTENGINE_H
00010 #define __LAYOUTENGINE_H
00011
00012 #ifndef __LETYPES_H
00013 #include "LETypes.h"
00014 #endif
00015
00016 #include <string.h>
00017
00018 class LEFontInstance;
00019 class LEGlyphFilter;
00020
00062 class U_LAYOUT_API LayoutEngine
00063 {
00064 protected:
00068 le_int32 fGlyphCount;
00069
00073 LEGlyphID *fGlyphs;
00074
00079 le_int32 *fCharIndices;
00080
00087 float *fPositions;
00088
00094 const LEFontInstance *fFontInstance;
00095
00101 le_int32 fScriptCode;
00102
00108 le_int32 fLanguageCode;
00109
00121 LayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode);
00122
00128 LayoutEngine();
00129
00154 virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphID *&glyphs, le_int32 *&charIndices, LEErrorCode &success);
00155
00170 virtual void positionGlyphs(const LEGlyphID glyphs[], le_int32 glyphCount, float x, float y, float *&positions, LEErrorCode &success);
00171
00194 virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphID glyphs[], le_int32 glyphCount, float positions[], LEErrorCode &success)
00195 {
00196 if (LE_FAILURE(success)) {
00197 return;
00198 }
00199
00200 if (chars == NULL || glyphs == NULL || positions == NULL || offset < 0 || count < 0) {
00201 success = LE_ILLEGAL_ARGUMENT_ERROR;
00202 return;
00203 }
00204
00205
00206 return;
00207 };
00208
00219 virtual const void *getFontTable(LETag tableTag) const;
00220
00246 virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror, LEGlyphID *&glyphs, le_int32 *&charIndices, LEErrorCode &success);
00247
00261 static void adjustMarkGlyphs(const LEGlyphID glyphs[], le_int32 glyphCount, le_bool reverse, LEGlyphFilter *markFilter, float positions[], LEErrorCode &success);
00262
00263 public:
00270 virtual ~LayoutEngine();
00271
00291 le_int32 layoutChars(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, float x, float y, LEErrorCode &success);
00292
00300 le_int32 getGlyphCount() const
00301 {
00302 return fGlyphCount;
00303 };
00304
00313 void getGlyphs(LEGlyphID glyphs[], LEErrorCode &success) const
00314 {
00315 if (LE_FAILURE(success)) {
00316 return;
00317 }
00318
00319 if (glyphs == NULL) {
00320 success = LE_ILLEGAL_ARGUMENT_ERROR;
00321 return;
00322 }
00323
00324 if (fGlyphs == NULL) {
00325 success = LE_NO_LAYOUT_ERROR;
00326 }
00327
00328 LE_ARRAY_COPY(glyphs, fGlyphs, fGlyphCount);
00329 };
00330
00341 void getGlyphs(le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const;
00342
00351 void getCharIndices(le_int32 charIndices[], LEErrorCode &success) const
00352 {
00353 if LE_FAILURE(success) {
00354 return;
00355 }
00356
00357 if (charIndices == NULL) {
00358 success = LE_ILLEGAL_ARGUMENT_ERROR;
00359 return;
00360 }
00361
00362 if (fCharIndices == NULL) {
00363 success = LE_NO_LAYOUT_ERROR;
00364 return;
00365 }
00366
00367 LE_ARRAY_COPY(charIndices, fCharIndices, fGlyphCount);
00368 };
00369
00379 void getCharIndices(le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const;
00380
00390 void getGlyphPositions(float positions[], LEErrorCode &success) const
00391 {
00392 if LE_FAILURE(success) {
00393 return;
00394 }
00395
00396 if (positions == NULL) {
00397 success = LE_ILLEGAL_ARGUMENT_ERROR;
00398 return;
00399 }
00400
00401 if (fPositions == NULL) {
00402 success = LE_NO_LAYOUT_ERROR;
00403 return;
00404 }
00405
00406 LE_ARRAY_COPY(positions, fPositions, fGlyphCount * 2 + 2);
00407 };
00408
00422 void getGlyphPosition(le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const
00423 {
00424 if (LE_FAILURE(success)) {
00425 return;
00426 }
00427
00428 if (glyphIndex > fGlyphCount) {
00429 success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
00430 return;
00431 }
00432
00433 if (fPositions == NULL) {
00434 success = LE_NO_LAYOUT_ERROR;
00435 return;
00436 }
00437
00438 x = fPositions[glyphIndex * 2];
00439 y = fPositions[glyphIndex * 2 + 1];
00440 };
00441
00447 virtual void reset();
00448
00463 static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, LEErrorCode &success);
00464
00465 };
00466
00467 #endif
00468