00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __PARAGRAPHLAYOUT_H
00011
00012 #define __PARAGRAPHLAYOUT_H
00013
00019
00020
00021
00022
00023 #include "unicode/uscript.h"
00024 #if ! UCONFIG_NO_BREAK_ITERATION
00025
00026 #include "layout/LETypes.h"
00027 #include "layout/LEFontInstance.h"
00028 #include "layout/LayoutEngine.h"
00029 #include "unicode/ubidi.h"
00030 #include "unicode/brkiter.h"
00031
00032 #include "layout/RunArrays.h"
00033
00034 U_NAMESPACE_BEGIN
00035
00053 class U_LAYOUTEX_API ParagraphLayout : public UObject
00054 {
00055 public:
00056 class VisualRun;
00057
00069 class U_LAYOUTEX_API Line : public UObject
00070 {
00071 public:
00080 ~Line();
00081
00089 inline le_int32 countRuns() const;
00090
00099 le_int32 getAscent() const;
00100
00109 le_int32 getDescent() const;
00110
00119 le_int32 getLeading() const;
00120
00130 le_int32 getWidth() const;
00131
00147 const VisualRun *getVisualRun(le_int32 runIndex) const;
00148
00154 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00155
00161 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00162
00163 private:
00164
00169 static const char fgClassID;
00170
00171 friend class ParagraphLayout;
00172
00173 le_int32 fAscent;
00174 le_int32 fDescent;
00175 le_int32 fLeading;
00176
00177 le_int32 fRunCount;
00178 le_int32 fRunCapacity;
00179
00180 VisualRun **fRuns;
00181
00182 inline Line();
00183 inline Line(const Line &other);
00184 inline Line &operator=(const Line & ) { return *this; };
00185
00186 void computeMetrics();
00187
00188 void append(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
00189 const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
00190 };
00191
00207 class U_LAYOUTEX_API VisualRun : public UObject
00208 {
00209 public:
00222 inline const LEFontInstance *getFont() const;
00223
00232 inline UBiDiDirection getDirection() const;
00233
00241 inline le_int32 getGlyphCount() const;
00242
00253 inline const LEGlyphID *getGlyphs() const;
00254
00268 inline const float *getPositions() const;
00269
00280 inline const le_int32 *getGlyphToCharMap() const;
00281
00290 inline le_int32 getAscent() const;
00291
00300 inline le_int32 getDescent() const;
00301
00310 inline le_int32 getLeading() const;
00311
00317 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00318
00324 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00325
00326 private:
00327
00332 static const char fgClassID;
00333
00334 const LEFontInstance *fFont;
00335 const UBiDiDirection fDirection;
00336
00337 const le_int32 fGlyphCount;
00338
00339 const LEGlyphID *fGlyphs;
00340 const float *fPositions;
00341 const le_int32 *fGlyphToCharMap;
00342
00343 friend class Line;
00344
00345 inline VisualRun();
00346 inline VisualRun(const VisualRun &other);
00347 inline VisualRun &operator=(const VisualRun &) { return *this; };
00348
00349 inline VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
00350 const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
00351
00352 ~VisualRun();
00353 };
00354
00398 ParagraphLayout(const LEUnicode chars[], le_int32 count,
00399 const FontRuns *fontRuns,
00400 const ValueRuns *levelRuns,
00401 const ValueRuns *scriptRuns,
00402 const LocaleRuns *localeRuns,
00403 UBiDiLevel paragraphLevel, le_bool vertical,
00404 LEErrorCode &status);
00405
00412 ~ParagraphLayout();
00413
00414
00415
00416
00417 #if 0
00418
00433 static le_bool isComplex(const LEUnicode chars[], le_int32 count, const FontRuns *fontRuns);
00434 #else
00435
00447 static le_bool isComplex(const LEUnicode chars[], le_int32 count);
00448
00449 #endif
00450
00460 inline UBiDiLevel getParagraphLevel();
00461
00471 inline UBiDiDirection getTextDirection();
00472
00481 virtual le_int32 getAscent() const;
00482
00491 virtual le_int32 getDescent() const;
00492
00501 virtual le_int32 getLeading() const;
00502
00509 inline void reflow();
00510
00511 #ifndef U_HIDE_INTERNAL_API
00512
00521 inline le_bool isDone() const;
00522 #endif
00523
00541 Line *nextLine(float width);
00542
00548 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00549
00555 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00556
00557 private:
00558
00559
00564 static const char fgClassID;
00565
00566 struct StyleRunInfo
00567 {
00568 LayoutEngine *engine;
00569 const LEFontInstance *font;
00570 const Locale *locale;
00571 LEGlyphID *glyphs;
00572 float *positions;
00573 UScriptCode script;
00574 UBiDiLevel level;
00575 le_int32 runBase;
00576 le_int32 runLimit;
00577 le_int32 glyphBase;
00578 le_int32 glyphCount;
00579 };
00580
00581 ParagraphLayout() {};
00582 ParagraphLayout(const ParagraphLayout & ) : UObject( ){};
00583 inline ParagraphLayout &operator=(const ParagraphLayout & ) { return *this; };
00584
00585 void computeLevels(UBiDiLevel paragraphLevel);
00586
00587 Line *computeVisualRuns();
00588 void appendRun(Line *line, le_int32 run, le_int32 firstChar, le_int32 lastChar);
00589
00590 void computeScripts();
00591
00592 void computeLocales();
00593
00594 void computeSubFonts(const FontRuns *fontRuns, LEErrorCode &status);
00595
00596 void computeMetrics();
00597
00598 le_int32 getLanguageCode(const Locale *locale);
00599
00600 le_int32 getCharRun(le_int32 charIndex);
00601
00602 static le_bool isComplex(UScriptCode script);
00603
00604 le_int32 previousBreak(le_int32 charIndex);
00605
00606
00607 const LEUnicode *fChars;
00608 le_int32 fCharCount;
00609
00610 const FontRuns *fFontRuns;
00611 const ValueRuns *fLevelRuns;
00612 const ValueRuns *fScriptRuns;
00613 const LocaleRuns *fLocaleRuns;
00614
00615 le_bool fVertical;
00616 le_bool fClientLevels;
00617 le_bool fClientScripts;
00618 le_bool fClientLocales;
00619
00620 UBiDiLevel *fEmbeddingLevels;
00621
00622 le_int32 fAscent;
00623 le_int32 fDescent;
00624 le_int32 fLeading;
00625
00626 le_int32 *fGlyphToCharMap;
00627 le_int32 *fCharToMinGlyphMap;
00628 le_int32 *fCharToMaxGlyphMap;
00629 float *fGlyphWidths;
00630 le_int32 fGlyphCount;
00631
00632 UBiDi *fParaBidi;
00633 UBiDi *fLineBidi;
00634
00635 le_int32 *fStyleRunLimits;
00636 le_int32 *fStyleIndices;
00637 StyleRunInfo *fStyleRunInfo;
00638 le_int32 fStyleRunCount;
00639
00640 BreakIterator *fBreakIterator;
00641 le_int32 fLineStart;
00642 le_int32 fLineEnd;
00643
00644 le_int32 fFirstVisualRun;
00645 le_int32 fLastVisualRun;
00646 float fVisualRunLastX;
00647 float fVisualRunLastY;
00648 };
00649
00650 inline UBiDiLevel ParagraphLayout::getParagraphLevel()
00651 {
00652 return ubidi_getParaLevel(fParaBidi);
00653 }
00654
00655 inline UBiDiDirection ParagraphLayout::getTextDirection()
00656 {
00657 return ubidi_getDirection(fParaBidi);
00658 }
00659
00660 inline void ParagraphLayout::reflow()
00661 {
00662 fLineEnd = 0;
00663 }
00664
00665 inline ParagraphLayout::Line::Line()
00666 : UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
00667 {
00668
00669 }
00670
00671 inline ParagraphLayout::Line::Line(const Line & )
00672 : UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
00673 {
00674
00675 }
00676
00677 inline le_int32 ParagraphLayout::Line::countRuns() const
00678 {
00679 return fRunCount;
00680 }
00681
00682 inline const LEFontInstance *ParagraphLayout::VisualRun::getFont() const
00683 {
00684 return fFont;
00685 }
00686
00687 inline UBiDiDirection ParagraphLayout::VisualRun::getDirection() const
00688 {
00689 return fDirection;
00690 }
00691
00692 inline le_int32 ParagraphLayout::VisualRun::getGlyphCount() const
00693 {
00694 return fGlyphCount;
00695 }
00696
00697 inline const LEGlyphID *ParagraphLayout::VisualRun::getGlyphs() const
00698 {
00699 return fGlyphs;
00700 }
00701
00702 inline const float *ParagraphLayout::VisualRun::getPositions() const
00703 {
00704 return fPositions;
00705 }
00706
00707 inline const le_int32 *ParagraphLayout::VisualRun::getGlyphToCharMap() const
00708 {
00709 return fGlyphToCharMap;
00710 }
00711
00712 inline le_int32 ParagraphLayout::VisualRun::getAscent() const
00713 {
00714 return fFont->getAscent();
00715 }
00716
00717 inline le_int32 ParagraphLayout::VisualRun::getDescent() const
00718 {
00719 return fFont->getDescent();
00720 }
00721
00722 inline le_int32 ParagraphLayout::VisualRun::getLeading() const
00723 {
00724 return fFont->getLeading();
00725 }
00726
00727 inline ParagraphLayout::VisualRun::VisualRun()
00728 : UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
00729 {
00730
00731 }
00732
00733 inline ParagraphLayout::VisualRun::VisualRun(const VisualRun &)
00734 : UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
00735 {
00736
00737 }
00738
00739 inline ParagraphLayout::VisualRun::VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
00740 const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[])
00741 : fFont(font), fDirection(direction), fGlyphCount(glyphCount),
00742 fGlyphs(glyphs), fPositions(positions), fGlyphToCharMap(glyphToCharMap)
00743 {
00744
00745 }
00746
00747 U_NAMESPACE_END
00748 #endif
00749 #endif