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=ad513a82672ea0799a000f7ea0314bedf6fae48b;hp=5ee4992338333f74fd1ad52c8ef4045189ad97bb;hb=0031ca8312dba666109e4f7fbb62a3a5e288b7c2;hpb=678abc1612bf792741f9018c0cb5210738b61113 diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index 5ee4992..ad513a8 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -105,7 +105,6 @@ struct LayoutEngine::Impl mCursorWidth( CURSOR_WIDTH ), mEllipsisEnabled( false ) { - mFontClient = TextAbstraction::FontClient::Get(); } /** @@ -117,7 +116,7 @@ struct LayoutEngine::Impl void UpdateLineHeight( FontId fontId, LineLayout& lineLayout ) { Text::FontMetrics fontMetrics; - mFontClient.GetFontMetrics( fontId, fontMetrics ); + mMetrics->GetFontMetrics( fontId, fontMetrics ); // Sets the maximum ascender. if( fontMetrics.ascender > lineLayout.ascender ) @@ -452,7 +451,6 @@ struct LayoutEngine::Impl const GlyphInfo& glyph = *glyphsBuffer; float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing : 0.f; - penX += mCursorWidth; // Added to give some space to the cursor. for( GlyphIndex i = 0u; i < numberOfGlyphs; ++i ) { @@ -634,7 +632,7 @@ struct LayoutEngine::Impl const GlyphInfo& glyphInfo = *( layoutParameters.glyphsBuffer + layoutParameters.totalNumberOfGlyphs - 1u ); Text::FontMetrics fontMetrics; - mFontClient.GetFontMetrics( glyphInfo.fontId, fontMetrics ); + mMetrics->GetFontMetrics( glyphInfo.fontId, fontMetrics ); LineRun lineRun; lineRun.glyphRun.glyphIndex = 0u; @@ -673,7 +671,6 @@ struct LayoutEngine::Impl const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + *( layoutParameters.charactersToGlyphsBuffer + characterVisualIndex ) ); float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing : 0.f; - penX += mCursorWidth; // Added to give some space to the cursor. Vector2* glyphPositionsBuffer = glyphPositions.Begin(); @@ -769,10 +766,12 @@ struct LayoutEngine::Impl { if( isLastLine && !isRTL ) { + // Add the length of the white saces at the end of the line. lineLength += line.extraLength; if( lineLength > boxWidth ) { - lineLength = boxWidth; + // The line's length is longer than the box's width. + // Set the line's offset to 0 and nothing else to do. line.alignmentOffset = 0.f; break; } @@ -821,7 +820,7 @@ struct LayoutEngine::Impl LayoutEngine::VerticalAlignment mVerticalAlignment; float mCursorWidth; - TextAbstraction::FontClient mFontClient; + IntrusivePtr mMetrics; bool mEllipsisEnabled:1; }; @@ -837,6 +836,11 @@ LayoutEngine::~LayoutEngine() delete mImpl; } +void LayoutEngine::SetMetrics( MetricsPtr& metrics ) +{ + mImpl->mMetrics = metrics; +} + void LayoutEngine::SetLayout( Layout layout ) { mImpl->mLayout = layout;