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=ccd42aedec0ff89b6123060fdbd7e163b49a845f;hp=12f20e44635a62cd7f8bc9b4b9cdbfaec6b7bd1d;hb=6c456bd91c102985503b651e4734c5d82221c941;hpb=ab5c560f8956e7b795b7cc2072d06a61aef103b7 diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index 12f20e4..ccd42ae 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -198,7 +198,7 @@ struct Engine::Impl LineLayout tmpLineLayout; const bool isMultiline = mLayout == MULTI_LINE_BOX; - const bool isWordLaidOut = parameters.lineWrapMode == Layout::LineWrap::WORD; + const bool isWordLaidOut = parameters.lineWrapMode == Text::LineWrap::WORD; // The last glyph to be laid-out. const GlyphIndex lastGlyphOfParagraphPlusOne = parameters.startGlyphIndex + parameters.numberOfGlyphs; @@ -470,6 +470,7 @@ struct Engine::Impl void SetGlyphPositions( const GlyphInfo* const glyphsBuffer, Length numberOfGlyphs, + float outlineWidth, Vector2* glyphPositionsBuffer ) { // Traverse the glyphs and set the positions. @@ -479,7 +480,8 @@ struct Engine::Impl // so the penX position needs to be moved to the right. const GlyphInfo& glyph = *glyphsBuffer; - float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing : 0.f; + float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing + outlineWidth : outlineWidth; + for( GlyphIndex i = 0u; i < numberOfGlyphs; ++i ) { @@ -604,6 +606,7 @@ struct Engine::Impl SetGlyphPositions( layoutParameters.glyphsBuffer + lineRun->glyphRun.glyphIndex, ellipsisLayout.numberOfGlyphs, + layoutParameters.outlineWidth, glyphPositionsBuffer + lineRun->glyphRun.glyphIndex - layoutParameters.startGlyphIndex ); } @@ -963,6 +966,7 @@ struct Engine::Impl // Sets the positions of the glyphs. SetGlyphPositions( layoutParameters.glyphsBuffer + index, layout.numberOfGlyphs, + layoutParameters.outlineWidth, glyphPositionsBuffer + index - layoutParameters.startGlyphIndex ); // Updates the vertical pen's position. @@ -1043,7 +1047,7 @@ struct Engine::Impl const CharacterIndex characterVisualIndex = bidiLine.characterRun.characterIndex + *bidiLine.visualToLogicalMap; const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + *( layoutParameters.charactersToGlyphsBuffer + characterVisualIndex ) ); - float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing : 0.f; + float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing - layoutParameters.outlineWidth : -layoutParameters.outlineWidth; Vector2* glyphPositionsBuffer = glyphPositions.Begin(); @@ -1078,7 +1082,7 @@ struct Engine::Impl void Align( const Size& size, CharacterIndex startIndex, Length numberOfCharacters, - HorizontalAlignment horizontalAlignment, + Text::HorizontalAlignment::Type horizontalAlignment, Vector& lines, float& alignmentOffset ) { @@ -1116,32 +1120,32 @@ struct Engine::Impl } void CalculateHorizontalAlignment( float boxWidth, - HorizontalAlignment horizontalAlignment, + HorizontalAlignment::Type horizontalAlignment, LineRun& line ) { line.alignmentOffset = 0.f; const bool isRTL = RTL == line.direction; float lineLength = line.width; - HorizontalAlignment alignment = horizontalAlignment; + HorizontalAlignment::Type alignment = horizontalAlignment; if( isRTL ) { // Swap the alignment type if the line is right to left. switch( alignment ) { - case HORIZONTAL_ALIGN_BEGIN: + case HorizontalAlignment::BEGIN: { - alignment = HORIZONTAL_ALIGN_END; + alignment = HorizontalAlignment::END; break; } - case HORIZONTAL_ALIGN_CENTER: + case HorizontalAlignment::CENTER: { // Nothing to do. break; } - case HORIZONTAL_ALIGN_END: + case HorizontalAlignment::END: { - alignment = HORIZONTAL_ALIGN_BEGIN; + alignment = HorizontalAlignment::BEGIN; break; } } @@ -1150,7 +1154,7 @@ struct Engine::Impl // Calculate the horizontal line offset. switch( alignment ) { - case HORIZONTAL_ALIGN_BEGIN: + case HorizontalAlignment::BEGIN: { line.alignmentOffset = 0.f; @@ -1161,7 +1165,7 @@ struct Engine::Impl } break; } - case HORIZONTAL_ALIGN_CENTER: + case HorizontalAlignment::CENTER: { line.alignmentOffset = 0.5f * ( boxWidth - lineLength ); @@ -1173,7 +1177,7 @@ struct Engine::Impl line.alignmentOffset = floorf( line.alignmentOffset ); // try to avoid pixel alignment. break; } - case HORIZONTAL_ALIGN_END: + case HorizontalAlignment::END: { if( isRTL ) { @@ -1272,7 +1276,7 @@ void Engine::ReLayoutRightToLeftLines( const Parameters& layoutParameters, void Engine::Align( const Size& size, CharacterIndex startIndex, Length numberOfCharacters, - Layout::HorizontalAlignment horizontalAlignment, + Text::HorizontalAlignment::Type horizontalAlignment, Vector& lines, float& alignmentOffset ) {