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=fb63d9648392c8eadfce9c1b2e76178c546166c5;hp=f4ec1623be809169d3c35f375196d4e62a59535d;hb=dd0935960c1acaf63d2b4f560b39236b871135b7;hpb=57cc1ce84c5763ade6f18e30b6983f9faf5c173c diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index f4ec162..fb63d96 100755 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -52,7 +52,8 @@ namespace const float MAX_FLOAT = std::numeric_limits::max(); const CharacterDirection LTR = false; const CharacterDirection RTL = !LTR; -const float LINE_SPACING= 0.f; +const float LINE_SPACING = 0.f; +const float MIN_LINE_SIZE = 0.f; inline bool isEmptyLineAtLast( const Vector& lines, const Vector::Iterator& line ) { @@ -130,7 +131,8 @@ struct Engine::Impl Impl() : mLayout{ Layout::Engine::SINGLE_LINE_BOX }, mCursorWidth{ 0.f }, - mDefaultLineSpacing{ LINE_SPACING } + mDefaultLineSpacing{ LINE_SPACING }, + mDefaultLineSize{ MIN_LINE_SIZE } { } @@ -162,8 +164,12 @@ struct Engine::Impl // Sets the minimum descender. lineLayout.descender = std::min( lineLayout.descender, fontMetrics.descender ); - // set the line spacing - lineLayout.lineSpacing = mDefaultLineSpacing; + // Sets the line size + lineLayout.lineSpacing = mDefaultLineSize - ( lineLayout.ascender + -lineLayout.descender ); + lineLayout.lineSpacing = lineLayout.lineSpacing < 0.f ? 0.f : lineLayout.lineSpacing; + + // Add the line spacing + lineLayout.lineSpacing += mDefaultLineSpacing; } /** @@ -921,26 +927,9 @@ struct Engine::Impl lineRun.glyphRun.numberOfGlyphs = layout.numberOfGlyphs; lineRun.characterRun.characterIndex = layout.characterIndex; lineRun.characterRun.numberOfCharacters = layout.numberOfCharacters; - lineRun.lineSpacing = mDefaultLineSpacing; + lineRun.width = layout.length; + lineRun.extraLength = std::ceil( layout.whiteSpaceLengthEndOfLine ); - if( isLastLine && !layoutParameters.isLastNewParagraph ) - { - lineRun.width = layout.length; - if( LTR == layout.direction ) - { - lineRun.width += layout.whiteSpaceLengthEndOfLine; - lineRun.extraLength = 0.f; - } - else - { - lineRun.extraLength = layout.whiteSpaceLengthEndOfLine; - } - } - else - { - lineRun.width = layout.length; - lineRun.extraLength = std::ceil( layout.whiteSpaceLengthEndOfLine ); - } // Rounds upward to avoid a non integer size. lineRun.width = std::ceil( lineRun.width ); @@ -950,6 +939,12 @@ struct Engine::Impl lineRun.direction = layout.direction; lineRun.ellipsis = false; + lineRun.lineSpacing = mDefaultLineSize - ( lineRun.ascender + -lineRun.descender ); + lineRun.lineSpacing = lineRun.lineSpacing < 0.f ? 0.f : lineRun.lineSpacing; + + lineRun.lineSpacing += mDefaultLineSpacing; + + // Update the actual size. if( lineRun.width > layoutSize.width ) { @@ -1001,7 +996,11 @@ struct Engine::Impl lineRun.alignmentOffset = 0.f; lineRun.direction = LTR; lineRun.ellipsis = false; - lineRun.lineSpacing = mDefaultLineSpacing; + + lineRun.lineSpacing = mDefaultLineSize - ( lineRun.ascender + -lineRun.descender ); + lineRun.lineSpacing = lineRun.lineSpacing < 0.f ? 0.f : lineRun.lineSpacing; + + lineRun.lineSpacing += mDefaultLineSpacing; layoutSize.height += ( lineRun.ascender + -lineRun.descender ) + lineRun.lineSpacing; } @@ -1566,6 +1565,7 @@ struct Engine::Impl Type mLayout; float mCursorWidth; float mDefaultLineSpacing; + float mDefaultLineSize; IntrusivePtr mMetrics; }; @@ -1647,6 +1647,16 @@ float Engine::GetDefaultLineSpacing() const return mImpl->mDefaultLineSpacing; } +void Engine::SetDefaultLineSize( float lineSize ) +{ + mImpl->mDefaultLineSize = lineSize; +} + +float Engine::GetDefaultLineSize() const +{ + return mImpl->mDefaultLineSize; +} + } // namespace Layout } // namespace Text