+ Length alignIndex = alignStartIndex;
+ Length boundedParagraphRunIndex = 0u;
+
+ while(alignIndex <= alignEndIndex && boundedParagraphRunIndex < numberOfBoundedParagraphRuns)
+ {
+ //BP: BoundedParagraph
+ const BoundedParagraphRun& boundedParagraphRun = boundedParagraphRuns[boundedParagraphRunIndex];
+ const CharacterIndex& characterStartIndexBP = boundedParagraphRun.characterRun.characterIndex;
+ const Length& numberOfCharactersBP = boundedParagraphRun.characterRun.numberOfCharacters;
+ const CharacterIndex characterEndIndexBP = characterStartIndexBP + numberOfCharactersBP - 1u;
+
+ CharacterIndex decidedAlignStartIndex = alignIndex;
+ Length decidedAlignNumberOfCharacters = alignEndIndex - alignIndex + 1u;
+ Text::HorizontalAlignment::Type decidedHorizontalAlignment = impl.mModel->mHorizontalAlignment;
+
+ /*
+ * Shortcuts to explain indexes cases:
+ *
+ * AS: Alignment Start Index
+ * AE: Alignment End Index
+ * PS: Paragraph Start Index
+ * PE: Paragraph End Index
+ * B: BoundedParagraph Alignment
+ * M: Model Alignment
+ *
+ */
+
+ if(alignIndex < characterStartIndexBP && characterStartIndexBP <= alignEndIndex) /// AS.MMMMMM.PS--------AE
+ {
+ // Alignment from "Alignment Start Index" to index before "Paragraph Start Index" according to "Model Alignment"
+ decidedAlignStartIndex = alignIndex;
+ decidedAlignNumberOfCharacters = characterStartIndexBP - alignIndex;
+ decidedHorizontalAlignment = impl.mModel->mHorizontalAlignment;
+
+ // Need to re-heck the case of current bounded paragraph
+ alignIndex = characterStartIndexBP; // Shift AS to be PS
+ }
+ else if((characterStartIndexBP <= alignIndex && alignIndex <= characterEndIndexBP) || /// ---PS.BBBBBBB.AS.BBBBBBB.PE---
+ (characterStartIndexBP <= alignEndIndex && alignEndIndex <= characterEndIndexBP)) /// ---PS.BBBBBB.AE.BBBBBBB.PE---
+ {
+ // Alignment from "Paragraph Start Index" to "Paragraph End Index" according to "BoundedParagraph Alignment"
+ decidedAlignStartIndex = characterStartIndexBP;
+ decidedAlignNumberOfCharacters = numberOfCharactersBP;
+ decidedHorizontalAlignment = boundedParagraphRun.horizontalAlignmentDefined ? boundedParagraphRun.horizontalAlignment : impl.mModel->mHorizontalAlignment;
+
+ alignIndex = characterEndIndexBP + 1u; // Shift AS to be after PE direct
+ boundedParagraphRunIndex++; // Align then check the case of next bounded paragraph
+ }
+ else
+ {
+ boundedParagraphRunIndex++; // Check the case of next bounded paragraph
+ continue;
+ }
+
+ impl.mLayoutEngine.Align(size,
+ decidedAlignStartIndex,
+ decidedAlignNumberOfCharacters,
+ decidedHorizontalAlignment,
+ lines,
+ impl.mModel->mAlignmentOffset,
+ impl.mLayoutDirection,
+ (impl.mModel->mMatchLayoutDirection != DevelText::MatchLayoutDirection::CONTENTS));
+ }
+
+ //Align the remaining that is not aligned
+ if(alignIndex <= alignEndIndex)
+ {
+ impl.mLayoutEngine.Align(size,
+ alignIndex,
+ (alignEndIndex - alignIndex + 1u),
+ impl.mModel->mHorizontalAlignment,
+ lines,
+ impl.mModel->mAlignmentOffset,
+ impl.mLayoutDirection,
+ (impl.mModel->mMatchLayoutDirection != DevelText::MatchLayoutDirection::CONTENTS));
+ }