X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Frendering%2Ftext-typesetter.cpp;h=314bc63f02ac4a504270c193c44f210286afe58f;hb=1e5f8e03bf0dfd40c9efd641d915dd1173eae4e5;hp=3184d4ac38dc9a10865a141e3773cf5c8c6ce5e7;hpb=eac074bfe3a3c144f55583135515d2c8d16eb479;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/rendering/text-typesetter.cpp b/dali-toolkit/internal/text/rendering/text-typesetter.cpp index 3184d4a..314bc63 100755 --- a/dali-toolkit/internal/text/rendering/text-typesetter.cpp +++ b/dali-toolkit/internal/text/rendering/text-typesetter.cpp @@ -19,12 +19,13 @@ #include // EXTERNAL INCLUDES -#include #include +#include #include // INTERNAL INCLUDES #include +#include namespace Dali { @@ -298,6 +299,29 @@ PixelData Typesetter::Render( const Vector2& size, RenderBehaviour behaviour, bo } } + // Calculate vertical line alignment + switch( mModel->GetVerticalLineAlignment() ) + { + case DevelText::VerticalLineAlignment::TOP: + { + break; + } + case DevelText::VerticalLineAlignment::MIDDLE: + { + const auto& line = *mModel->GetLines(); + penY -= line.descender; + penY += static_cast(line.lineSpacing*0.5f + line.descender); + break; + } + case DevelText::VerticalLineAlignment::BOTTOM: + { + const auto& line = *mModel->GetLines(); + const auto lineHeight = line.ascender + (-line.descender) + line.lineSpacing; + penY += static_cast(lineHeight - (line.ascender - line.descender)); + break; + } + } + // Generate the image buffers of the text for each different style first, // then combine all of them together as one final image buffer. We try to // do all of these in CPU only, so that once the final texture is generated, @@ -353,6 +377,14 @@ PixelData Typesetter::Render( const Vector2& size, RenderBehaviour behaviour, bo // Create the image buffer for shadow Devel::PixelBuffer shadowImageBuffer = CreateImageBuffer( bufferWidth, bufferHeight, Typesetter::STYLE_SHADOW, ignoreHorizontalAlignment, pixelFormat, penY, 0u, numberOfGlyphs - 1 ); + // Check whether it will be a soft shadow + const float& blurRadius = mModel->GetShadowBlurRadius(); + + if ( blurRadius > Math::MACHINE_EPSILON_1 ) + { + shadowImageBuffer.ApplyGaussianBlur( blurRadius ); + } + // Combine the two buffers imageBuffer = CombineImageBuffer( imageBuffer, shadowImageBuffer, bufferWidth, bufferHeight ); } @@ -423,6 +455,12 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer( const unsigned int bufferWidth // Increases the vertical offset with the line's ascender. glyphData.verticalOffset += static_cast( line.ascender ); + // Include line spacing after first line + if( lineIndex > 0u ) + { + glyphData.verticalOffset += static_cast( line.lineSpacing ); + } + // Retrieves the glyph's outline width float outlineWidth = mModel->GetOutlineWidth(); @@ -582,11 +620,14 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer( const unsigned int bufferWidth // Don't render outline for other styles outlineWidth = 0.0f; } + if( style != Typesetter::STYLE_UNDERLINE ) + { + fontClient.CreateBitmap( glyphInfo->fontId, + glyphInfo->index, + glyphData.glyphBitmap, + outlineWidth ); + } - fontClient.CreateBitmap( glyphInfo->fontId, - glyphInfo->index, - glyphData.glyphBitmap, - outlineWidth ); // Sets the glyph's bitmap into the bitmap of the whole text. if( NULL != glyphData.glyphBitmap.buffer ) @@ -609,7 +650,7 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer( const unsigned int bufferWidth for( unsigned int y = underlineYOffset; y < underlineYOffset + maxUnderlineThickness; y++ ) { - if( ( y < 0 ) || ( y > bufferHeight - 1 ) ) + if( y > bufferHeight - 1 ) { // Do not write out of bounds. break; @@ -617,7 +658,7 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer( const unsigned int bufferWidth for( unsigned int x = glyphData.horizontalOffset + lineExtentLeft; x <= glyphData.horizontalOffset + lineExtentRight; x++ ) { - if( ( x < 0 ) || ( x > bufferWidth - 1 ) ) + if( x > bufferWidth - 1 ) { // Do not write out of bounds. break;