Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

LayoutEngine.h

Go to the documentation of this file.
00001 
00002 /*
00003  * %W% %W%
00004  *
00005  * (C) Copyright IBM Corp. 1998, 1999, 2000, 2001 - All Rights Reserved
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 U_NAMESPACE_BEGIN
00019 
00020 class LEFontInstance;
00021 class LEGlyphFilter;
00022 
00064 class U_LAYOUT_API LayoutEngine
00065 {
00066 protected:
00070     le_int32 fGlyphCount;
00071 
00075     LEGlyphID *fGlyphs;
00076 
00081     le_int32 *fCharIndices;
00082 
00089     float *fPositions;
00090 
00096     const LEFontInstance *fFontInstance;
00097 
00103     le_int32 fScriptCode;
00104 
00110     le_int32 fLanguageCode;
00111 
00123     LayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode);
00124 
00130     LayoutEngine();
00131 
00156     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);
00157 
00172     virtual void positionGlyphs(const LEGlyphID glyphs[], le_int32 glyphCount, float x, float y, float *&positions, LEErrorCode &success);
00173 
00196     virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphID glyphs[], le_int32 glyphCount, float positions[], LEErrorCode &success)
00197     {
00198                 if (LE_FAILURE(success)) {
00199                         return;
00200                 }
00201 
00202                 if (chars == NULL || glyphs == NULL || positions == NULL || offset < 0 || count < 0) {
00203                         success = LE_ILLEGAL_ARGUMENT_ERROR;
00204                         return;
00205                 }
00206 
00207         // default is no adjustments
00208                 return;
00209     };
00210 
00221     virtual const void *getFontTable(LETag tableTag) const;
00222 
00248     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);
00249 
00263     static void adjustMarkGlyphs(const LEGlyphID glyphs[], le_int32 glyphCount, le_bool reverse, LEGlyphFilter *markFilter, float positions[], LEErrorCode &success);
00264 
00265 public:
00272     virtual ~LayoutEngine();
00273 
00293     virtual le_int32 layoutChars(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, float x, float y, LEErrorCode &success);
00294 
00302         le_int32 getGlyphCount() const
00303         {
00304                 return fGlyphCount;
00305         };
00306 
00315     void getGlyphs(LEGlyphID glyphs[], LEErrorCode &success) const
00316     {
00317                 if (LE_FAILURE(success)) {
00318                         return;
00319                 }
00320 
00321                 if (glyphs == NULL) {
00322                         success = LE_ILLEGAL_ARGUMENT_ERROR;
00323                         return;
00324                 }
00325 
00326                 if (fGlyphs == NULL) {
00327                         success = LE_NO_LAYOUT_ERROR;
00328                 }
00329 
00330         LE_ARRAY_COPY(glyphs, fGlyphs, fGlyphCount);
00331     };
00332 
00343     virtual void getGlyphs(le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const;
00344 
00353     void getCharIndices(le_int32 charIndices[], LEErrorCode &success) const
00354     {
00355                 if LE_FAILURE(success) {
00356                         return;
00357                 }
00358 
00359                 if (charIndices == NULL) {
00360                         success = LE_ILLEGAL_ARGUMENT_ERROR;
00361                         return;
00362                 }
00363 
00364                 if (fCharIndices == NULL) {
00365                         success = LE_NO_LAYOUT_ERROR;
00366                         return;
00367                 }
00368 
00369         LE_ARRAY_COPY(charIndices, fCharIndices, fGlyphCount);
00370     };
00371 
00381     void getCharIndices(le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const;
00382 
00392     void getGlyphPositions(float positions[], LEErrorCode &success) const
00393     {
00394                 if LE_FAILURE(success) {
00395                         return;
00396                 }
00397 
00398                 if (positions == NULL) {
00399                         success = LE_ILLEGAL_ARGUMENT_ERROR;
00400                         return;
00401                 }
00402 
00403                 if (fPositions == NULL) {
00404                         success = LE_NO_LAYOUT_ERROR;
00405                         return;
00406                 }
00407 
00408         LE_ARRAY_COPY(positions, fPositions, fGlyphCount * 2 + 2);
00409     };
00410 
00424     void getGlyphPosition(le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const
00425     {
00426                 if (LE_FAILURE(success)) {
00427                         return;
00428                 }
00429 
00430                 if (glyphIndex > fGlyphCount) {
00431                         success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
00432                         return;
00433                 }
00434 
00435                 if (fPositions == NULL) {
00436                         success = LE_NO_LAYOUT_ERROR;
00437                         return;
00438                 }
00439 
00440         x = fPositions[glyphIndex * 2];
00441                 y = fPositions[glyphIndex * 2 + 1];
00442     };
00443 
00449     virtual void reset();
00450     
00465     static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, LEErrorCode &success);
00466     
00467 };
00468 
00469 U_NAMESPACE_END
00470 #endif
00471 

Generated on Tue Apr 9 11:30:05 2002 for ICU 2.1 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001