From: Paul Wisbey
Date: Fri, 20 Mar 2015 16:59:07 +0000 (-0700)
Subject: Merge "Layout Engine - Fix for multiline" into new_text
X-Git-Tag: dali_1.0.38~11^2~40
X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=428bd47c26043ccaabab1a64cbc7cbd7ce3c7427;hp=9dc0a8037eb3a78fa907767e9b6de1690ba28271
Merge "Layout Engine - Fix for multiline" into new_text
---
diff --git a/dali-toolkit/internal/text/bidirectional-support.cpp b/dali-toolkit/internal/text/bidirectional-support.cpp
index b9ff99a..6f74f19 100644
--- a/dali-toolkit/internal/text/bidirectional-support.cpp
+++ b/dali-toolkit/internal/text/bidirectional-support.cpp
@@ -220,7 +220,7 @@ void ReorderLines( const Vector& bidirectionalInf
// Reorders the line.
bidirectionalSupport.Reorder( paragraphInfo.bidirectionalInfoIndex,
- line.characterRun.characterIndex,
+ line.characterRun.characterIndex - paragraphInfo.characterRun.characterIndex,
line.characterRun.numberOfCharacters,
lineInfoRun.visualToLogicalMap );
diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp
index 460fb02..4e090e0 100644
--- a/dali-toolkit/internal/text/layouts/layout-engine.cpp
+++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp
@@ -219,33 +219,30 @@ struct LayoutEngine::Impl
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;
diff --git a/dali-toolkit/internal/text/shaper.cpp b/dali-toolkit/internal/text/shaper.cpp
index 55101eb..8e2eed1 100644
--- a/dali-toolkit/internal/text/shaper.cpp
+++ b/dali-toolkit/internal/text/shaper.cpp
@@ -131,11 +131,17 @@ void ShapeText( const Vector& text,
}
}
- // 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;
}
@@ -164,6 +170,18 @@ void ShapeText( const Vector& text,
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 )
{