00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __PARAGRAPHLAYOUT_H
00009
00010 #define __PARAGRAPHLAYOUT_H
00011
00017
00018
00019
00020
00021 #include "unicode/uscript.h"
00022 #if ! UCONFIG_NO_BREAK_ITERATION
00023
00024 #include "layout/LETypes.h"
00025 #include "layout/LEFontInstance.h"
00026 #include "layout/LayoutEngine.h"
00027 #include "unicode/ubidi.h"
00028 #include "unicode/brkiter.h"
00029
00030 #include "layout/RunArrays.h"
00031
00032 U_NAMESPACE_BEGIN
00033
00044 class U_LAYOUTEX_API ParagraphLayout : public UObject
00045 {
00046 public:
00047 class VisualRun;
00048
00060 class U_LAYOUTEX_API Line : public UObject
00061 {
00062 public:
00071 ~Line();
00072
00080 inline le_int32 countRuns() const;
00081
00090 le_int32 getAscent() const;
00091
00100 le_int32 getDescent() const;
00101
00110 le_int32 getLeading() const;
00111
00121 le_int32 getWidth() const;
00122
00138 const VisualRun *getVisualRun(le_int32 runIndex) const;
00139
00145 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00146
00152 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00153
00154 private:
00155
00160 static const char fgClassID;
00161
00162 friend class ParagraphLayout;
00163
00164 le_int32 fAscent;
00165 le_int32 fDescent;
00166 le_int32 fLeading;
00167
00168 le_int32 fRunCount;
00169 le_int32 fRunCapacity;
00170
00171 VisualRun **fRuns;
00172
00173 inline Line();
00174 inline Line(const Line &other);
00175 inline Line &operator=(const Line & ) { return *this; };
00176
00177 void computeMetrics();
00178
00179 void append(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
00180 const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
00181 };
00182
00198 class U_LAYOUTEX_API VisualRun : public UObject
00199 {
00200 public:
00213 inline const LEFontInstance *getFont() const;
00214
00223 inline UBiDiDirection getDirection() const;
00224
00232 inline le_int32 getGlyphCount() const;
00233
00244 inline const LEGlyphID *getGlyphs() const;
00245
00259 inline const float *getPositions() const;
00260
00271 inline const le_int32 *getGlyphToCharMap() const;
00272
00281 inline le_int32 getAscent() const;
00282
00291 inline le_int32 getDescent() const;
00292
00301 inline le_int32 getLeading() const;
00302
00308 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00309
00315 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00316
00317 private:
00318
00323 static const char fgClassID;
00324
00325 const LEFontInstance *fFont;
00326 const UBiDiDirection fDirection;
00327
00328 const le_int32 fGlyphCount;
00329
00330 const LEGlyphID *fGlyphs;
00331 const float *fPositions;
00332 const le_int32 *fGlyphToCharMap;
00333
00334 friend class Line;
00335
00336 inline VisualRun();
00337 inline VisualRun(const VisualRun &other);
00338 inline VisualRun &operator=(const VisualRun &) { return *this; };
00339
00340 inline VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
00341 const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
00342
00343 ~VisualRun();
00344 };
00345
00389 ParagraphLayout(const LEUnicode chars[], le_int32 count,
00390 const FontRuns *fontRuns,
00391 const ValueRuns *levelRuns,
00392 const ValueRuns *scriptRuns,
00393 const LocaleRuns *localeRuns,
00394 UBiDiLevel paragraphLevel, le_bool vertical,
00395 LEErrorCode &status);
00396
00403 ~ParagraphLayout();
00404
00405
00406
00407
00408 #if 0
00409
00424 static le_bool isComplex(const LEUnicode chars[], le_int32 count, const FontRuns *fontRuns);
00425 #else
00426
00438 static le_bool isComplex(const LEUnicode chars[], le_int32 count);
00439
00440 #endif
00441
00451 inline UBiDiLevel getParagraphLevel();
00452
00462 inline UBiDiDirection getTextDirection();
00463
00472 virtual le_int32 getAscent() const;
00473
00482 virtual le_int32 getDescent() const;
00483
00492 virtual le_int32 getLeading() const;
00493
00500 inline void reflow();
00501
00519 Line *nextLine(float width);
00520
00526 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00527
00533 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00534
00535 private:
00536
00537
00542 static const char fgClassID;
00543
00544 struct StyleRunInfo
00545 {
00546 LayoutEngine *engine;
00547 const LEFontInstance *font;
00548 const Locale *locale;
00549 LEGlyphID *glyphs;
00550 float *positions;
00551 UScriptCode script;
00552 UBiDiLevel level;
00553 le_int32 runBase;
00554 le_int32 runLimit;
00555 le_int32 glyphBase;
00556 le_int32 glyphCount;
00557 };
00558
00559 ParagraphLayout() {};
00560 ParagraphLayout(const ParagraphLayout & ) : UObject( ){};
00561 inline ParagraphLayout &operator=(const ParagraphLayout & ) { return *this; };
00562
00563 void computeLevels(UBiDiLevel paragraphLevel);
00564
00565 Line *computeVisualRuns();
00566 void appendRun(Line *line, le_int32 run, le_int32 firstChar, le_int32 lastChar);
00567
00568 void computeScripts();
00569
00570 void computeLocales();
00571
00572 void computeSubFonts(const FontRuns *fontRuns, LEErrorCode &status);
00573
00574 void computeMetrics();
00575
00576 le_int32 getLanguageCode(const Locale *locale);
00577
00578 le_int32 getCharRun(le_int32 charIndex);
00579
00580 static le_bool isComplex(UScriptCode script);
00581
00582 le_int32 previousBreak(le_int32 charIndex);
00583
00584
00585 const LEUnicode *fChars;
00586 le_int32 fCharCount;
00587
00588 const FontRuns *fFontRuns;
00589 const ValueRuns *fLevelRuns;
00590 const ValueRuns *fScriptRuns;
00591 const LocaleRuns *fLocaleRuns;
00592
00593 le_bool fVertical;
00594 le_bool fClientLevels;
00595 le_bool fClientScripts;
00596 le_bool fClientLocales;
00597
00598 UBiDiLevel *fEmbeddingLevels;
00599
00600 le_int32 fAscent;
00601 le_int32 fDescent;
00602 le_int32 fLeading;
00603
00604 le_int32 *fGlyphToCharMap;
00605 le_int32 *fCharToMinGlyphMap;
00606 le_int32 *fCharToMaxGlyphMap;
00607 float *fGlyphWidths;
00608 le_int32 fGlyphCount;
00609
00610 UBiDi *fParaBidi;
00611 UBiDi *fLineBidi;
00612
00613 le_int32 *fStyleRunLimits;
00614 le_int32 *fStyleIndices;
00615 StyleRunInfo *fStyleRunInfo;
00616 le_int32 fStyleRunCount;
00617
00618 BreakIterator *fBreakIterator;
00619 le_int32 fLineStart;
00620 le_int32 fLineEnd;
00621
00622 le_int32 fFirstVisualRun;
00623 le_int32 fLastVisualRun;
00624 float fVisualRunLastX;
00625 float fVisualRunLastY;
00626 };
00627
00628 inline UBiDiLevel ParagraphLayout::getParagraphLevel()
00629 {
00630 return ubidi_getParaLevel(fParaBidi);
00631 }
00632
00633 inline UBiDiDirection ParagraphLayout::getTextDirection()
00634 {
00635 return ubidi_getDirection(fParaBidi);
00636 }
00637
00638 inline void ParagraphLayout::reflow()
00639 {
00640 fLineEnd = 0;
00641 }
00642
00643 inline ParagraphLayout::Line::Line()
00644 : UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
00645 {
00646
00647 }
00648
00649 inline ParagraphLayout::Line::Line(const Line & )
00650 : UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
00651 {
00652
00653 }
00654
00655 inline le_int32 ParagraphLayout::Line::countRuns() const
00656 {
00657 return fRunCount;
00658 }
00659
00660 inline const LEFontInstance *ParagraphLayout::VisualRun::getFont() const
00661 {
00662 return fFont;
00663 }
00664
00665 inline UBiDiDirection ParagraphLayout::VisualRun::getDirection() const
00666 {
00667 return fDirection;
00668 }
00669
00670 inline le_int32 ParagraphLayout::VisualRun::getGlyphCount() const
00671 {
00672 return fGlyphCount;
00673 }
00674
00675 inline const LEGlyphID *ParagraphLayout::VisualRun::getGlyphs() const
00676 {
00677 return fGlyphs;
00678 }
00679
00680 inline const float *ParagraphLayout::VisualRun::getPositions() const
00681 {
00682 return fPositions;
00683 }
00684
00685 inline const le_int32 *ParagraphLayout::VisualRun::getGlyphToCharMap() const
00686 {
00687 return fGlyphToCharMap;
00688 }
00689
00690 inline le_int32 ParagraphLayout::VisualRun::getAscent() const
00691 {
00692 return fFont->getAscent();
00693 }
00694
00695 inline le_int32 ParagraphLayout::VisualRun::getDescent() const
00696 {
00697 return fFont->getDescent();
00698 }
00699
00700 inline le_int32 ParagraphLayout::VisualRun::getLeading() const
00701 {
00702 return fFont->getLeading();
00703 }
00704
00705 inline ParagraphLayout::VisualRun::VisualRun()
00706 : UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
00707 {
00708
00709 }
00710
00711 inline ParagraphLayout::VisualRun::VisualRun(const VisualRun &)
00712 : UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
00713 {
00714
00715 }
00716
00717 inline ParagraphLayout::VisualRun::VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
00718 const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[])
00719 : fFont(font), fDirection(direction), fGlyphCount(glyphCount),
00720 fGlyphs(glyphs), fPositions(positions), fGlyphToCharMap(glyphToCharMap)
00721 {
00722
00723 }
00724
00725 U_NAMESPACE_END
00726 #endif
00727 #endif