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, 2002 - 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 
00066 class U_LAYOUT_API LayoutEngine : public UObject {
00067 protected:
00073     le_int32 fGlyphCount;
00074 
00080     LEGlyphID *fGlyphs;
00081 
00088     le_int32 *fCharIndices;
00089 
00098     float *fPositions;
00099 
00107     const LEFontInstance *fFontInstance;
00108 
00116     le_int32 fScriptCode;
00117 
00125     le_int32 fLanguageCode;
00126 
00140     LayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode);
00141 
00149     LayoutEngine();
00150 
00177     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);
00178 
00195     virtual void positionGlyphs(const LEGlyphID glyphs[], le_int32 glyphCount, float x, float y, float *&positions, LEErrorCode &success);
00196 
00221     virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphID glyphs[], le_int32 glyphCount, float positions[], LEErrorCode &success)
00222     {
00223         if (LE_FAILURE(success)) {
00224             return;
00225         }
00226 
00227         if (chars == NULL || glyphs == NULL || positions == NULL || offset < 0 || count < 0) {
00228             success = LE_ILLEGAL_ARGUMENT_ERROR;
00229             return;
00230         }
00231 
00232         // default is no adjustments
00233         return;
00234     };
00235 
00248     virtual const void *getFontTable(LETag tableTag) const;
00249 
00277     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);
00278 
00294     static void adjustMarkGlyphs(const LEGlyphID glyphs[], le_int32 glyphCount, le_bool reverse, LEGlyphFilter *markFilter, float positions[], LEErrorCode &success);
00295 
00296 public:
00305     virtual ~LayoutEngine();
00306 
00328     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);
00329 
00339     le_int32 getGlyphCount() const
00340     {
00341         return fGlyphCount;
00342     };
00343 
00354     void getGlyphs(LEGlyphID glyphs[], LEErrorCode &success) const
00355     {
00356         if (LE_FAILURE(success)) {
00357             return;
00358         }
00359 
00360         if (glyphs == NULL) {
00361             success = LE_ILLEGAL_ARGUMENT_ERROR;
00362             return;
00363         }
00364 
00365         if (fGlyphs == NULL) {
00366             success = LE_NO_LAYOUT_ERROR;
00367         }
00368 
00369         LE_ARRAY_COPY(glyphs, fGlyphs, fGlyphCount);
00370     };
00371 
00384     virtual void getGlyphs(le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const;
00385 
00396     void getCharIndices(le_int32 charIndices[], LEErrorCode &success) const
00397     {
00398         if LE_FAILURE(success) {
00399             return;
00400         }
00401 
00402         if (charIndices == NULL) {
00403             success = LE_ILLEGAL_ARGUMENT_ERROR;
00404             return;
00405         }
00406 
00407         if (fCharIndices == NULL) {
00408             success = LE_NO_LAYOUT_ERROR;
00409             return;
00410         }
00411 
00412         LE_ARRAY_COPY(charIndices, fCharIndices, fGlyphCount);
00413     };
00414 
00426     void getCharIndices(le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const;
00427 
00439     void getGlyphPositions(float positions[], LEErrorCode &success) const
00440     {
00441         if LE_FAILURE(success) {
00442             return;
00443         }
00444 
00445         if (positions == NULL) {
00446             success = LE_ILLEGAL_ARGUMENT_ERROR;
00447             return;
00448         }
00449 
00450         if (fPositions == NULL) {
00451             success = LE_NO_LAYOUT_ERROR;
00452             return;
00453         }
00454 
00455         LE_ARRAY_COPY(positions, fPositions, fGlyphCount * 2 + 2);
00456     };
00457 
00472     void getGlyphPosition(le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const
00473     {
00474         if (LE_FAILURE(success)) {
00475             return;
00476         }
00477 
00478         if (glyphIndex > fGlyphCount) {
00479             success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
00480             return;
00481         }
00482 
00483         if (fPositions == NULL) {
00484             success = LE_NO_LAYOUT_ERROR;
00485             return;
00486         }
00487 
00488         x = fPositions[glyphIndex * 2];
00489         y = fPositions[glyphIndex * 2 + 1];
00490     };
00491 
00499     virtual void reset();
00500 
00517     static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, LEErrorCode &success);
00518 
00524     virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00525 
00531     static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00532 
00533 private:
00534 
00539     static const char fgClassID;
00540 };
00541 
00542 U_NAMESPACE_END
00543 #endif
00544 

Generated on Thu Aug 15 14:13:25 2002 for ICU 2.2 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001