X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Flayouts%2Flayout-engine.cpp;h=20b4de383c60d34f9c2e6f2c2de92b8a11b6c611;hb=5302f3d8e0e409242d2716078eca5a7b582fc8c8;hp=9d1b93d78630b8e20cda97d258b80a610b405441;hpb=bb0af65c5caa5658bae6068f9d81d27b38f67a50;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index 9d1b93d..20b4de3 100755 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -53,6 +53,11 @@ const float MAX_FLOAT = std::numeric_limits::max(); const bool RTL = true; const float LINE_SPACING= 0.f; +inline bool isEmptyLineAtLast( const Vector& lines, const Vector::Iterator& line ) +{ + return ( (*line).characterRun.numberOfCharacters == 0 && line + 1u == lines.End() ); +} + } //namespace /** @@ -224,7 +229,7 @@ struct Engine::Impl // The initial start point is zero. However it needs a correction according the 'x' bearing of the first glyph. // i.e. if the bearing of the first glyph is negative it may exceed the boundaries of the text area. // It needs to add as well space for the cursor if the text is in edit mode and extra space in case the text is outlined. - tmpLineLayout.penX = -glyphMetrics.xBearing + mCursorWidth + parameters.outlineWidth; + tmpLineLayout.penX = ( 0.f > glyphMetrics.xBearing ) ? -glyphMetrics.xBearing : 0.f + mCursorWidth + parameters.outlineWidth; // Initialize the advance of the previous glyph. tmpLineLayout.previousAdvance = 0.f; @@ -298,9 +303,9 @@ struct Engine::Impl } else { - tmpLineLayout.penX += tmpLineLayout.previousAdvance + tmpLineLayout.wsLengthEndOfLine; tmpLineLayout.previousAdvance = ( glyphMetrics.advance + parameters.interGlyphExtraAdvance ); - tmpLineLayout.length = tmpLineLayout.penX + glyphMetrics.xBearing + glyphMetrics.width; + tmpLineLayout.penX += tmpLineLayout.previousAdvance + tmpLineLayout.wsLengthEndOfLine; + tmpLineLayout.length = tmpLineLayout.penX; // Clear the white space length at the end of the line. tmpLineLayout.wsLengthEndOfLine = 0.f; @@ -391,7 +396,7 @@ struct Engine::Impl // so the penX position needs to be moved to the right. const GlyphInfo& glyph = *glyphsBuffer; - float penX = -glyph.xBearing + mCursorWidth + outlineWidth; + float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing : 0.f + mCursorWidth + outlineWidth; for( GlyphIndex i = 0u; i < numberOfGlyphs; ++i ) { @@ -985,7 +990,7 @@ struct Engine::Impl const CharacterIndex characterVisualIndex = bidiLine.characterRun.characterIndex + *bidiLine.visualToLogicalMap; const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + *( layoutParameters.charactersToGlyphsBuffer + characterVisualIndex ) ); - float penX = -glyph.xBearing + layoutParameters.outlineWidth + mCursorWidth; + float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing : 0.f + layoutParameters.outlineWidth + mCursorWidth; Vector2* glyphPositionsBuffer = glyphPositions.Begin(); @@ -1042,12 +1047,18 @@ struct Engine::Impl continue; } - if( line.characterRun.characterIndex >= lastCharacterPlusOne ) + if( line.characterRun.characterIndex > lastCharacterPlusOne ) { // Do not align lines beyond the last laid-out character. break; } + if( line.characterRun.characterIndex == lastCharacterPlusOne && !isEmptyLineAtLast( lines, it ) ) + { + // Do not align lines beyond the last laid-out character unless the line is last and empty. + break; + } + // Calculate the line's alignment offset accordingly with the align option, // the box width, line length, and the paragraph's direction. CalculateHorizontalAlignment( size.width,