// Reorders the line.
bidirectionalSupport.Reorder( paragraphInfo.bidirectionalInfoIndex,
- line.characterRun.characterIndex,
+ line.characterRun.characterIndex - paragraphInfo.characterRun.characterIndex,
line.characterRun.numberOfCharacters,
lineInfoRun.visualToLogicalMap );
if( TextAbstraction::LINE_MUST_BREAK == lineBreakInfo )
{
- if( glyphIndex == lastGlyphIndex )
+ // Must break the line. Update the line layout and return.
+ lineLayout.numberOfCharacters += tmpLineLayout.numberOfCharacters;
+ lineLayout.numberOfGlyphs += tmpLineLayout.numberOfGlyphs;
+ lineLayout.length += tmpLineLayout.length;
+
+ if( 0.f < tmpLineLayout.length )
+ {
+ lineLayout.length += lineLayout.wsLengthEndOfLine;
+
+ lineLayout.wsLengthEndOfLine = tmpLineLayout.wsLengthEndOfLine;
+ }
+ else
{
- // Must break the line. Update the line layout and return.
- lineLayout.numberOfCharacters += tmpLineLayout.numberOfCharacters;
- lineLayout.numberOfGlyphs += tmpLineLayout.numberOfGlyphs;
- lineLayout.length += tmpLineLayout.length;
-
- if( 0.f < tmpLineLayout.length )
- {
- lineLayout.length += lineLayout.wsLengthEndOfLine;
-
- lineLayout.wsLengthEndOfLine = tmpLineLayout.wsLengthEndOfLine;
- }
- else
- {
- lineLayout.wsLengthEndOfLine += tmpLineLayout.wsLengthEndOfLine;
- }
-
- if( tmpLineLayout.height > lineLayout.height )
- {
- lineLayout.height = tmpLineLayout.height;
- }
-
- if( tmpLineLayout.ascender > lineLayout.ascender )
- {
- lineLayout.ascender = tmpLineLayout.ascender;
- }
+ lineLayout.wsLengthEndOfLine += tmpLineLayout.wsLengthEndOfLine;
+ }
+
+ if( tmpLineLayout.height > lineLayout.height )
+ {
+ lineLayout.height = tmpLineLayout.height;
+ }
+
+ if( tmpLineLayout.ascender > lineLayout.ascender )
+ {
+ lineLayout.ascender = tmpLineLayout.ascender;
}
tmpLineLayout.numberOfCharacters = 0u;
}
}
- // Check if the current index is a white space. Do not want to shape a \n.
+ // Check if the current index is a new paragraph character.
+ // A \n is going to be shaped in order to not to mess the conversion tables.
+ // After the \n character is shaped, the glyph is going to be reset to its
+ // default in order to not to get any metric or font index for it.
+ const bool isNewParagraph = TextAbstraction::IsNewParagraph( *( textBuffer + currentIndex ) );
+
// The last character is always a must-break even if it's not a \n.
Length numberOfCharactersToShape = currentIndex - previousIndex;
- if( mustBreak && !TextAbstraction::IsWhiteSpace( *( textBuffer + currentIndex ) ) )
+ if( mustBreak )
{
+ // Add one more character to shape.
++numberOfCharactersToShape;
}
shaping.GetGlyphs( glyphsBuffer + glyphIndex,
glyphToCharacterMapBuffer + glyphIndex );
+ if( isNewParagraph )
+ {
+ // TODO : This is a work around to avoid drawing a square in the
+ // place of a new line character.
+
+ // If the last character is a \n, it resets the glyph to the default
+ // to avoid getting any metric for it.
+ GlyphInfo& glyph = *( glyphsBuffer + glyphIndex + ( numberOfGlyphs - 1u ) );
+
+ glyph = GlyphInfo();
+ }
+
// Update indices.
if( 0u != glyphIndex )
{