X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Flayouts%2Flayout-engine.cpp;h=4f9876c8cc45fd0d4a6e3c3c7a20720e4fe78c4d;hp=0c3d9df9d02bf945a8dfafe39eb1dc9f09ef7ca0;hb=68c69395e8cc9c980ce3e478cb224ac38286581e;hpb=8d03e750dd430e081ec17d298b593612ab45e841 diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index 0c3d9df..4f9876c 100755 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -1150,51 +1150,41 @@ struct Engine::Impl bool matchSystemLanguageDirection ) { line.alignmentOffset = 0.f; - bool isRTL = RTL == line.direction; + const bool isLineRTL = RTL == line.direction; + // Whether to swap the alignment. + // Swap if the line is RTL and is not required to match the direction of the system's language or if it's required to match the direction of the system's language and it's RTL. + bool isLayoutRTL = isLineRTL; float lineLength = line.width; - HorizontalAlignment::Type alignment = horizontalAlignment; // match align for system language direction if( matchSystemLanguageDirection ) { - isRTL = layoutDirection == LayoutDirection::RIGHT_TO_LEFT; + // Swap the alignment type if the line is right to left. + isLayoutRTL = layoutDirection == LayoutDirection::RIGHT_TO_LEFT; } - - // Swap the alignment type if the line is right to left. - if( isRTL ) - { - switch( alignment ) - { - case HorizontalAlignment::BEGIN: - { - alignment = HorizontalAlignment::END; - break; - } - case HorizontalAlignment::CENTER: - { - // Nothing to do. - break; - } - case HorizontalAlignment::END: - { - alignment = HorizontalAlignment::BEGIN; - break; - } - } - - } - // Calculate the horizontal line offset. - switch( alignment ) + switch( horizontalAlignment ) { case HorizontalAlignment::BEGIN: { - line.alignmentOffset = 0.f; + if( isLayoutRTL ) + { + if( isLineRTL ) + { + lineLength += line.extraLength; + } - if( isRTL ) + line.alignmentOffset = boxWidth - lineLength; + } + else { - // 'Remove' the white spaces at the end of the line (which are at the beginning in visual order) - line.alignmentOffset -= line.extraLength; + line.alignmentOffset = 0.f; + + if( isLineRTL ) + { + // 'Remove' the white spaces at the end of the line (which are at the beginning in visual order) + line.alignmentOffset -= line.extraLength; + } } break; } @@ -1202,7 +1192,7 @@ struct Engine::Impl { line.alignmentOffset = 0.5f * ( boxWidth - lineLength ); - if( isRTL ) + if( isLineRTL ) { line.alignmentOffset -= line.extraLength; } @@ -1212,12 +1202,25 @@ struct Engine::Impl } case HorizontalAlignment::END: { - if( isRTL ) + if( isLayoutRTL ) { - lineLength += line.extraLength; + line.alignmentOffset = 0.f; + + if( isLineRTL ) + { + // 'Remove' the white spaces at the end of the line (which are at the beginning in visual order) + line.alignmentOffset -= line.extraLength; + } } + else + { + if( isLineRTL ) + { + lineLength += line.extraLength; + } - line.alignmentOffset = boxWidth - lineLength; + line.alignmentOffset = boxWidth - lineLength; + } break; } }