00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __PARAGRAPHLAYOUT_H
00009
00010 #define __PARAGRAPHLAYOUT_H
00011
00012
00013
00014
00015
00016 #include "unicode/uscript.h"
00017 #if ! UCONFIG_NO_BREAK_ITERATION
00018
00019 #include "layout/LETypes.h"
00020 #include "layout/LEFontInstance.h"
00021 #include "layout/LayoutEngine.h"
00022 #include "unicode/ubidi.h"
00023 #include "unicode/brkiter.h"
00024
00025 #include "layout/RunArrays.h"
00026
00027 U_NAMESPACE_BEGIN
00028
00039 class U_LAYOUTEX_API ParagraphLayout : public UObject
00040 {
00041 public:
00042 class VisualRun;
00043
00055 class U_LAYOUTEX_API Line : public UObject
00056 {
00057 public:
00066 ~Line();
00067
00075 le_int32 countRuns() const;
00076
00085 le_int32 getAscent() const;
00086
00095 le_int32 getDescent() const;
00096
00105 le_int32 getLeading() const;
00106
00122 const VisualRun *getVisualRun(le_int32 runIndex) const;
00123
00129 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00130
00136 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00137
00138 private:
00139
00144 static const char fgClassID;
00145
00146 friend class ParagraphLayout;
00147
00148 le_int32 fAscent;
00149 le_int32 fDescent;
00150 le_int32 fLeading;
00151
00152 le_int32 fRunCount;
00153 le_int32 fRunCapacity;
00154
00155 VisualRun **fRuns;
00156
00157 Line();
00158 Line(const Line &other);
00159 Line &operator=(const Line & ) { return *this; };
00160
00161 void computeMetrics();
00162
00163 void append(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
00164 const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
00165 };
00166
00182 class U_LAYOUTEX_API VisualRun : public UObject
00183 {
00184 public:
00197 const LEFontInstance *getFont() const;
00198
00207 UBiDiDirection getDirection() const;
00208
00216 le_int32 getGlyphCount() const;
00217
00228 const LEGlyphID *getGlyphs() const;
00229
00243 const float *getPositions() const;
00244
00255 const le_int32 *getGlyphToCharMap() const;
00256
00265 le_int32 getAscent() const;
00266
00275 le_int32 getDescent() const;
00276
00285 le_int32 getLeading() const;
00286
00292 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00293
00299 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00300
00301 private:
00302
00307 static const char fgClassID;
00308
00309 const LEFontInstance *fFont;
00310 const UBiDiDirection fDirection;
00311
00312 const le_int32 fGlyphCount;
00313
00314 const LEGlyphID *fGlyphs;
00315 const float *fPositions;
00316 const le_int32 *fGlyphToCharMap;
00317
00318 friend class Line;
00319
00320 VisualRun();
00321 VisualRun(const VisualRun &other);
00322 VisualRun &operator=(const VisualRun &other) { return *this; };
00323
00324 VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
00325 const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
00326
00327 ~VisualRun();
00328 };
00329
00368 ParagraphLayout(const LEUnicode chars[], le_int32 count,
00369 const FontRuns *fontRuns,
00370 const ValueRuns *levelRuns,
00371 const ValueRuns *scriptRuns,
00372 const LocaleRuns *localeRuns,
00373 UBiDiLevel paragraphLevel, le_bool vertical);
00374
00381 ~ParagraphLayout();
00382
00383
00384
00385
00386 #if 0
00387
00402 static le_bool isComplex(const LEUnicode chars[], le_int32 count, const FontRuns *fontRuns);
00403 #else
00404
00416 static le_bool isComplex(const LEUnicode chars[], le_int32 count);
00417
00418 #endif
00419
00429 UBiDiLevel getParagraphLevel();
00430
00440 UBiDiDirection getTextDirection();
00441
00450 virtual le_int32 getAscent() const;
00451
00460 virtual le_int32 getDescent() const;
00461
00470 virtual le_int32 getLeading() const;
00471
00478 void reflow();
00479
00497 Line *nextLine(float width);
00498
00504 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00505
00511 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00512
00513 private:
00514
00515
00520 static const char fgClassID;
00521
00522 struct StyleRunInfo
00523 {
00524 LayoutEngine *engine;
00525 const LEFontInstance *font;
00526 const Locale *locale;
00527 LEGlyphID *glyphs;
00528 float *positions;
00529 UScriptCode script;
00530 UBiDiLevel level;
00531 le_int32 runBase;
00532 le_int32 runLimit;
00533 le_int32 glyphBase;
00534 le_int32 glyphCount;
00535 };
00536
00537 ParagraphLayout() {};
00538 ParagraphLayout(const ParagraphLayout & ) : UObject( ){};
00539 ParagraphLayout &operator=(const ParagraphLayout & ) { return *this; };
00540
00541 void computeLevels(UBiDiLevel paragraphLevel);
00542
00543 Line *computeVisualRuns();
00544 void appendRun(Line *line, le_int32 run, le_int32 firstChar, le_int32 lastChar);
00545
00546 void computeScripts();
00547
00548 void computeLocales();
00549
00550 void computeSubFonts(const FontRuns *fontRuns);
00551
00552 void computeMetrics();
00553
00554 le_int32 getLanguageCode(const Locale *locale);
00555
00556 le_int32 getCharRun(le_int32 charIndex);
00557
00558 static le_bool isComplex(UScriptCode script);
00559
00560 le_int32 previousBreak(le_int32 charIndex);
00561
00562
00563 const LEUnicode *fChars;
00564 le_int32 fCharCount;
00565
00566 const FontRuns *fFontRuns;
00567 const ValueRuns *fLevelRuns;
00568 const ValueRuns *fScriptRuns;
00569 const LocaleRuns *fLocaleRuns;
00570
00571 le_bool fVertical;
00572 le_bool fClientLevels;
00573 le_bool fClientScripts;
00574 le_bool fClientLocales;
00575
00576 UBiDiLevel *fEmbeddingLevels;
00577
00578 le_int32 fAscent;
00579 le_int32 fDescent;
00580 le_int32 fLeading;
00581
00582 le_int32 *fGlyphToCharMap;
00583 le_int32 *fCharToGlyphMap;
00584 float *fGlyphWidths;
00585 le_int32 fGlyphCount;
00586
00587 UBiDi *fParaBidi;
00588 UBiDi *fLineBidi;
00589
00590 le_int32 *fStyleRunLimits;
00591 le_int32 *fStyleIndices;
00592 StyleRunInfo *fStyleRunInfo;
00593 le_int32 fStyleRunCount;
00594
00595 BreakIterator *fBreakIterator;
00596 le_int32 fLineStart;
00597 le_int32 fLineEnd;
00598
00599 le_int32 fFirstVisualRun;
00600 le_int32 fLastVisualRun;
00601 float fVisualRunLastX;
00602 float fVisualRunLastY;
00603 };
00604
00605 inline UBiDiLevel ParagraphLayout::getParagraphLevel()
00606 {
00607 return ubidi_getParaLevel(fParaBidi);
00608 }
00609
00610 inline UBiDiDirection ParagraphLayout::getTextDirection()
00611 {
00612 return ubidi_getDirection(fParaBidi);
00613 }
00614
00615 inline void ParagraphLayout::reflow()
00616 {
00617 fLineEnd = 0;
00618 }
00619
00620 inline ParagraphLayout::Line::Line()
00621 : UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
00622 {
00623
00624 }
00625
00626 inline ParagraphLayout::Line::Line(const Line & )
00627 : UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
00628 {
00629
00630 }
00631
00632 inline le_int32 ParagraphLayout::Line::countRuns() const
00633 {
00634 return fRunCount;
00635 }
00636
00637 inline const LEFontInstance *ParagraphLayout::VisualRun::getFont() const
00638 {
00639 return fFont;
00640 }
00641
00642 inline UBiDiDirection ParagraphLayout::VisualRun::getDirection() const
00643 {
00644 return fDirection;
00645 }
00646
00647 inline le_int32 ParagraphLayout::VisualRun::getGlyphCount() const
00648 {
00649 return fGlyphCount;
00650 }
00651
00652 inline const LEGlyphID *ParagraphLayout::VisualRun::getGlyphs() const
00653 {
00654 return fGlyphs;
00655 }
00656
00657 inline const float *ParagraphLayout::VisualRun::getPositions() const
00658 {
00659 return fPositions;
00660 }
00661
00662 inline const le_int32 *ParagraphLayout::VisualRun::getGlyphToCharMap() const
00663 {
00664 return fGlyphToCharMap;
00665 }
00666
00667 inline le_int32 ParagraphLayout::VisualRun::getAscent() const
00668 {
00669 return fFont->getAscent();
00670 }
00671
00672 inline le_int32 ParagraphLayout::VisualRun::getDescent() const
00673 {
00674 return fFont->getDescent();
00675 }
00676
00677 inline le_int32 ParagraphLayout::VisualRun::getLeading() const
00678 {
00679 return fFont->getLeading();
00680 }
00681
00682 inline ParagraphLayout::VisualRun::VisualRun()
00683 : UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
00684 {
00685
00686 }
00687
00688 inline ParagraphLayout::VisualRun::VisualRun(const VisualRun &other)
00689 : UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
00690 {
00691
00692 }
00693
00694 inline ParagraphLayout::VisualRun::VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
00695 const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[])
00696 : fFont(font), fDirection(direction), fGlyphCount(glyphCount),
00697 fGlyphs(glyphs), fPositions(positions), fGlyphToCharMap(glyphToCharMap)
00698 {
00699
00700 }
00701
00702 inline ParagraphLayout::VisualRun::~VisualRun()
00703 {
00704 LE_DELETE_ARRAY(fGlyphToCharMap);
00705 LE_DELETE_ARRAY(fPositions);
00706 LE_DELETE_ARRAY(fGlyphs);
00707 }
00708
00709 U_NAMESPACE_END
00710 #endif
00711 #endif