ICU 58.2 58.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

ParagraphLayout.h
Go to the documentation of this file.
1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 **********************************************************************
5 * Copyright (C) 2002-2014, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
8 */
9
10 #ifndef __PARAGRAPHLAYOUT_H
11
12 #define __PARAGRAPHLAYOUT_H
13
19 /*
20 * ParagraphLayout doesn't make much sense without
21 * BreakIterator...
22 */
23 #include "unicode/uscript.h"
24 #if ! UCONFIG_NO_BREAK_ITERATION
25
26 #include "layout/LETypes.h"
27 #include "layout/LEFontInstance.h"
28 #include "layout/LayoutEngine.h"
29 #include "unicode/ubidi.h"
30 #include "unicode/brkiter.h"
31
32 #include "layout/RunArrays.h"
33
34 U_NAMESPACE_BEGIN
35
53 class U_LAYOUTEX_API ParagraphLayout : public UObject
54 {
55 public:
56 class VisualRun;
57
69 class U_LAYOUTEX_API Line : public UObject
70 {
71 public:
80 ~Line();
81
89 inline le_int32 countRuns() const;
90
99 le_int32 getAscent() const;
100
109 le_int32 getDescent() const;
110
119 le_int32 getLeading() const;
120
130 le_int32 getWidth() const;
131
147 const VisualRun *getVisualRun(le_int32 runIndex) const;
148
154 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
155
161 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
162
163 private:
164
169 static const char fgClassID;
170
171 friend class ParagraphLayout;
172
173 le_int32 fAscent;
174 le_int32 fDescent;
175 le_int32 fLeading;
176
177 le_int32 fRunCount;
178 le_int32 fRunCapacity;
179
180 VisualRun **fRuns;
181
182 inline Line();
183 inline Line(const Line &other);
184 inline Line &operator=(const Line & /*other*/) { return *this; };
185
186 void computeMetrics();
187
188 void append(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
189 const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
190 };
191
207 class U_LAYOUTEX_API VisualRun : public UObject
208 {
209 public:
222 inline const LEFontInstance *getFont() const;
223
232 inline UBiDiDirection getDirection() const;
233
241 inline le_int32 getGlyphCount() const;
242
253 inline const LEGlyphID *getGlyphs() const;
254
268 inline const float *getPositions() const;
269
280 inline const le_int32 *getGlyphToCharMap() const;
281
290 inline le_int32 getAscent() const;
291
300 inline le_int32 getDescent() const;
301
310 inline le_int32 getLeading() const;
311
317 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
318
324 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
325
326 private:
327
332 static const char fgClassID;
333
334 const LEFontInstance *fFont;
335 const UBiDiDirection fDirection;
336
337 const le_int32 fGlyphCount;
338
339 const LEGlyphID *fGlyphs;
340 const float *fPositions;
341 const le_int32 *fGlyphToCharMap;
342
343 friend class Line;
344
345 inline VisualRun();
346 inline VisualRun(const VisualRun &other);
347 inline VisualRun &operator=(const VisualRun &/*other*/) { return *this; };
348
349 inline VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
350 const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
351
352 ~VisualRun();
353 };
354
398 ParagraphLayout(const LEUnicode chars[], le_int32 count,
399 const FontRuns *fontRuns,
400 const ValueRuns *levelRuns,
401 const ValueRuns *scriptRuns,
402 const LocaleRuns *localeRuns,
403 UBiDiLevel paragraphLevel, le_bool vertical,
404 LEErrorCode &status);
405
412 ~ParagraphLayout();
413
414 // Note: the following is #if 0'd out because there's no good
415 // way to implement it without either calling layoutEngineFactory()
416 // or duplicating the logic there...
417 #if 0
418
433 static le_bool isComplex(const LEUnicode chars[], le_int32 count, const FontRuns *fontRuns);
434 #else
435
447 static le_bool isComplex(const LEUnicode chars[], le_int32 count);
448
449 #endif
450
460 inline UBiDiLevel getParagraphLevel();
461
471 inline UBiDiDirection getTextDirection();
472
481 virtual le_int32 getAscent() const;
482
491 virtual le_int32 getDescent() const;
492
501 virtual le_int32 getLeading() const;
502
509 inline void reflow();
510
511 #ifndef U_HIDE_INTERNAL_API
512
521 inline le_bool isDone() const;
522 #endif /* U_HIDE_INTERNAL_API */
523
541 Line *nextLine(float width);
542
548 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
549
555 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
556
557 private:
558
559
564 static const char fgClassID;
565
566 struct StyleRunInfo
567 {
568 LayoutEngine *engine;
569 const LEFontInstance *font;
570 const Locale *locale;
571 LEGlyphID *glyphs;
572 float *positions;
573 UScriptCode script;
574 UBiDiLevel level;
575 le_int32 runBase;
576 le_int32 runLimit;
577 le_int32 glyphBase;
578 le_int32 glyphCount;
579 };
580
581 ParagraphLayout() {};
582 ParagraphLayout(const ParagraphLayout & /*other*/) : UObject( ){};
583 inline ParagraphLayout &operator=(const ParagraphLayout & /*other*/) { return *this; };
584
585 void computeLevels(UBiDiLevel paragraphLevel);
586
587 Line *computeVisualRuns();
588 void appendRun(Line *line, le_int32 run, le_int32 firstChar, le_int32 lastChar);
589
590 void computeScripts();
591
592 void computeLocales();
593
594 void computeSubFonts(const FontRuns *fontRuns, LEErrorCode &status);
595
596 void computeMetrics();
597
598 le_int32 getLanguageCode(const Locale *locale);
599
600 le_int32 getCharRun(le_int32 charIndex);
601
602 static le_bool isComplex(UScriptCode script);
603
604 le_int32 previousBreak(le_int32 charIndex);
605
606
607 const LEUnicode *fChars;
608 le_int32 fCharCount;
609
610 const FontRuns *fFontRuns;
611 const ValueRuns *fLevelRuns;
612 const ValueRuns *fScriptRuns;
613 const LocaleRuns *fLocaleRuns;
614
615 le_bool fVertical;
616 le_bool fClientLevels;
617 le_bool fClientScripts;
618 le_bool fClientLocales;
619
620 UBiDiLevel *fEmbeddingLevels;
621
622 le_int32 fAscent;
623 le_int32 fDescent;
624 le_int32 fLeading;
625
626 le_int32 *fGlyphToCharMap;
627 le_int32 *fCharToMinGlyphMap;
628 le_int32 *fCharToMaxGlyphMap;
629 float *fGlyphWidths;
630 le_int32 fGlyphCount;
631
632 UBiDi *fParaBidi;
633 UBiDi *fLineBidi;
634
635 le_int32 *fStyleRunLimits;
636 le_int32 *fStyleIndices;
637 StyleRunInfo *fStyleRunInfo;
638 le_int32 fStyleRunCount;
639
640 BreakIterator *fBreakIterator;
641 le_int32 fLineStart;
642 le_int32 fLineEnd;
643
644 le_int32 fFirstVisualRun;
645 le_int32 fLastVisualRun;
646 float fVisualRunLastX;
647 float fVisualRunLastY;
648 };
649
650 inline UBiDiLevel ParagraphLayout::getParagraphLevel()
651 {
652 return ubidi_getParaLevel(fParaBidi);
653 }
654
655 inline UBiDiDirection ParagraphLayout::getTextDirection()
656 {
657 return ubidi_getDirection(fParaBidi);
658 }
659
660 inline void ParagraphLayout::reflow()
661 {
662 fLineEnd = 0;
663 }
664
665 inline ParagraphLayout::Line::Line()
666 : UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
667 {
668 // nothing else to do
669 }
670
671 inline ParagraphLayout::Line::Line(const Line & /*other*/)
672 : UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
673 {
674 // nothing else to do
675 }
676
677 inline le_int32 ParagraphLayout::Line::countRuns() const
678 {
679 return fRunCount;
680 }
681
682 inline const LEFontInstance *ParagraphLayout::VisualRun::getFont() const
683 {
684 return fFont;
685 }
686
687 inline UBiDiDirection ParagraphLayout::VisualRun::getDirection() const
688 {
689 return fDirection;
690 }
691
692 inline le_int32 ParagraphLayout::VisualRun::getGlyphCount() const
693 {
694 return fGlyphCount;
695 }
696
697 inline const LEGlyphID *ParagraphLayout::VisualRun::getGlyphs() const
698 {
699 return fGlyphs;
700 }
701
702 inline const float *ParagraphLayout::VisualRun::getPositions() const
703 {
704 return fPositions;
705 }
706
707 inline const le_int32 *ParagraphLayout::VisualRun::getGlyphToCharMap() const
708 {
709 return fGlyphToCharMap;
710 }
711
712 inline le_int32 ParagraphLayout::VisualRun::getAscent() const
713 {
714 return fFont->getAscent();
715 }
716
717 inline le_int32 ParagraphLayout::VisualRun::getDescent() const
718 {
719 return fFont->getDescent();
720 }
721
722 inline le_int32 ParagraphLayout::VisualRun::getLeading() const
723 {
724 return fFont->getLeading();
725 }
726
727 inline ParagraphLayout::VisualRun::VisualRun()
728 : UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
729 {
730 // nothing
731 }
732
733 inline ParagraphLayout::VisualRun::VisualRun(const VisualRun &/*other*/)
734 : UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
735 {
736 // nothing
737 }
738
739 inline ParagraphLayout::VisualRun::VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
740 const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[])
741 : fFont(font), fDirection(direction), fGlyphCount(glyphCount),
742 fGlyphs(glyphs), fPositions(positions), fGlyphToCharMap(glyphToCharMap)
743 {
744 // nothing else needs to be done!
745 }
746
747 U_NAMESPACE_END
748 #endif
749 #endif
brkiter.h
C++ API: Break Iterator.
icu::ParagraphLayout::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU "poor man&#39;s RTTI", returns a UClassID for the actual class.
Definition: ParagraphLayout.h:555
icu::ParagraphLayout::Line::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man&#39;s RTTI", returns a UClassID for this class.
Definition: ParagraphLayout.h:154
ubidi.h
C API: Bidi algorithm.
icu::ParagraphLayout::VisualRun::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU "poor man&#39;s RTTI", returns a UClassID for the actual class.
Definition: ParagraphLayout.h:324
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:93
UScriptCode
UScriptCode
Constants for ISO 15924 script codes.
Definition: uscript.h:54
icu::ParagraphLayout::Line::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU "poor man&#39;s RTTI", returns a UClassID for the actual class.
Definition: ParagraphLayout.h:161
UBiDiLevel
uint8_t UBiDiLevel
UBiDiLevel is the type of the level values in this Bidi implementation.
Definition: ubidi.h:332
icu::ParagraphLayout::VisualRun::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man&#39;s RTTI", returns a UClassID for this class.
Definition: ParagraphLayout.h:317
icu::FontRuns
The FontRuns class associates pointers to LEFontInstance objects with runs of text.
Definition: RunArrays.h:272
icu::LocaleRuns
The LocaleRuns class associates pointers to Locale objects with runs of text.
Definition: RunArrays.h:409
icu::ParagraphLayout::VisualRun
This object represents a single visual run in a line of text in a paragraph.
Definition: ParagraphLayout.h:207
uscript.h
C API: Unicode Script Information.
UBiDiDirection
UBiDiDirection
UBiDiDirection values indicate the text direction.
Definition: ubidi.h:419
icu::ParagraphLayout::Line
This class represents a single line of text in a ParagraphLayout.
Definition: ParagraphLayout.h:69
ubidi_getDirection
UBiDiDirection ubidi_getDirection(const UBiDi *pBiDi)
Get the directionality of the text.
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
icu::BreakIterator
The BreakIterator class implements methods for finding the location of boundaries in text...
Definition: brkiter.h:102
NULL
#define NULL
Define NULL if necessary, to 0 for C++ and to ((void *)0) for C.
Definition: utypes.h:188
ubidi_getParaLevel
UBiDiLevel ubidi_getParaLevel(const UBiDi *pBiDi)
Get the paragraph level of the text.
icu::ParagraphLayout
ParagraphLayout.
Definition: ParagraphLayout.h:53
UBIDI_LTR
Left-to-right text.
Definition: ubidi.h:431
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UBiDi
struct UBiDi UBiDi
Definition: ubidi.h:476
U_LAYOUTEX_API
#define U_LAYOUTEX_API
Set to export library symbols from inside the layout extensions library, and to import them from outs...
Definition: utypes.h:362
RunArrays.h
C++ API: base class for building classes which represent data that is associated with runs of text...
icu::ValueRuns
The ValueRuns class associates integer values with runs of text.
Definition: RunArrays.h:548
icu::ParagraphLayout::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man&#39;s RTTI", returns a UClassID for this class.
Definition: ParagraphLayout.h:548
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:187