X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Ftext%2Ftext-utils-devel.cpp;h=fc8afb9ea951df64d344a3200d24e4789d08794e;hp=dcc9ab839af58ce48b0611404ceda902b4eeb2d2;hb=96e0b7fdbe4cfe733a38cbcc2b493a7aeff66d6d;hpb=b03acd78e2289973171be301c1e04fbb5b778d29 diff --git a/dali-toolkit/devel-api/text/text-utils-devel.cpp b/dali-toolkit/devel-api/text/text-utils-devel.cpp index dcc9ab8..fc8afb9 100755 --- a/dali-toolkit/devel-api/text/text-utils-devel.cpp +++ b/dali-toolkit/devel-api/text/text-utils-devel.cpp @@ -32,14 +32,13 @@ #include #include #include -#include #include #include #include #include #include #include -#include +#include namespace Dali { @@ -133,20 +132,19 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, Vector blendingMode; ///< How embedded items and bitmap font glyphs are blended with color text. - Vector isEmoji; ///< Whether the glyph is an emoji. + Text::Layout::Engine layoutEngine; ///< The layout engine. + Text::ModelPtr textModel = Text::Model::New(); ///< Pointer to the text's model. + Vector blendingMode; ///< How embedded items and bitmap font glyphs are blended with color text. + Vector isEmoji; ///< Whether the glyph is an emoji. // Use this to access FontClient i.e. to get down-scaled Emoji metrics. metrics = Metrics::New( fontClient ); layoutEngine.SetMetrics( metrics ); - TextAbstraction::TextRenderer::Parameters rendererParameters( visualModel->mGlyphs, - visualModel->mGlyphPositions, - visualModel->mColors, - visualModel->mColorIndices, + TextAbstraction::TextRenderer::Parameters rendererParameters( textModel->mVisualModel->mGlyphs, + textModel->mVisualModel->mGlyphPositions, + textModel->mVisualModel->mColors, + textModel->mVisualModel->mColorIndices, blendingMode, isEmoji ); @@ -154,22 +152,22 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, Vector& utf32Characters = logicalModel->mText; // Characters encoded in utf32. - Vector mirroredUtf32Characters; // The utf32Characters Characters but mirrored if there are RTL text. - Vector& lineBreakInfo = logicalModel->mLineBreakInfo; // The line break info. - Vector& scripts = logicalModel->mScriptRuns; // Charactes's script. - Vector& fontDescriptionRuns = logicalModel->mFontDescriptionRuns; // Desired font descriptions. - Vector& validFonts = logicalModel->mFontRuns; // Validated fonts. - Vector& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo; // The bidirectional info per paragraph. - Vector& bidirectionalLineInfo = logicalModel->mBidirectionalLineInfo; // The bidirectional info per line. - Vector& directions = logicalModel->mCharacterDirections; // Character's directions. - Vector& colorRuns = logicalModel->mColorRuns; // colors of the text. - - Vector& glyphsToCharacters = visualModel->mGlyphsToCharacters; // Glyphs to character map. - Vector& charactersToGlyph = visualModel->mCharactersToGlyph; // Characters to glyphs map. - Vector& charactersPerGlyph = visualModel->mCharactersPerGlyph; // Number of characters per glyph. - Vector& glyphsPerCharacter = visualModel->mGlyphsPerCharacter; // The number of glyphs that are shaped. - Vector& lines = visualModel->mLines; // The laid out lines. + Vector& utf32Characters = textModel->mLogicalModel->mText; // Characters encoded in utf32. + Vector mirroredUtf32Characters; // The utf32Characters Characters but mirrored if there are RTL text. + Vector& lineBreakInfo = textModel->mLogicalModel->mLineBreakInfo; // The line break info. + Vector& scripts = textModel->mLogicalModel->mScriptRuns; // Charactes's script. + Vector& fontDescriptionRuns = textModel->mLogicalModel->mFontDescriptionRuns; // Desired font descriptions. + Vector& validFonts = textModel->mLogicalModel->mFontRuns; // Validated fonts. + Vector& bidirectionalInfo = textModel->mLogicalModel->mBidirectionalParagraphInfo; // The bidirectional info per paragraph. + //Vector& bidirectionalLineInfo = textModel->mLogicalModel->mBidirectionalLineInfo; // The bidirectional info per line. + Vector& directions = textModel->mLogicalModel->mCharacterDirections; // Character's directions. + Vector& colorRuns = textModel->mLogicalModel->mColorRuns; // colors of the text. + + Vector& glyphsToCharacters = textModel->mVisualModel->mGlyphsToCharacters; // Glyphs to character map. + Vector& charactersToGlyph = textModel->mVisualModel->mCharactersToGlyph; // Characters to glyphs map. + Vector& charactersPerGlyph = textModel->mVisualModel->mCharactersPerGlyph; // Number of characters per glyph. + Vector& glyphsPerCharacter = textModel->mVisualModel->mGlyphsPerCharacter; // The number of glyphs that are shaped. + Vector& lines = textModel->mVisualModel->mLines; // The laid out lines. Vector newParagraphGlyphs; // Glyphs for the new paragraph characters. @@ -189,7 +187,7 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, VectormEmbeddedItems ); + textModel->mLogicalModel->mEmbeddedItems ); if (textParameters.markupEnabled) { @@ -362,19 +360,19 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, VectorCreateGlyphsPerCharacterTable( 0u, 0u, numberOfCharacters ); - visualModel->CreateCharacterToGlyphTable( 0u, 0u, numberOfCharacters ); + textModel->mVisualModel->CreateGlyphsPerCharacterTable( 0u, 0u, numberOfCharacters ); + textModel->mVisualModel->CreateCharacterToGlyphTable( 0u, 0u, numberOfCharacters ); const Length numberOfGlyphs = rendererParameters.glyphs.Count(); // Once the text has been shaped and the glyphs created it's possible to replace the font id of those glyphs // that represent an image or an item and create the embedded item layout info. // Note: the position of the embedded item can't be set until the text is laid-out. - embeddedItemLayout.Reserve( logicalModel->mEmbeddedItems.Count() ); - for( const auto& item : logicalModel->mEmbeddedItems ) + embeddedItemLayout.Reserve( textModel->mLogicalModel->mEmbeddedItems.Count() ); + for( const auto& item : textModel->mLogicalModel->mEmbeddedItems ) { // Get the glyph that matches with the character index. - const GlyphIndex glyphIndex = visualModel->mCharactersToGlyph[item.characterIndex]; + const GlyphIndex glyphIndex = textModel->mVisualModel->mCharactersToGlyph[item.characterIndex]; GlyphInfo& glyph = rendererParameters.glyphs[glyphIndex]; glyph.fontId = 0u; @@ -421,11 +419,11 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, VectormColors, - visualModel->mColorIndices ); + textModel->mVisualModel->mColors, + textModel->mVisualModel->mColorIndices ); // Insert the default color at the beginning of the vector. - visualModel->mColors.Insert( visualModel->mColors.Begin(),textParameters.textColor ); + textModel->mVisualModel->mColors.Insert( textModel->mVisualModel->mColors.Begin(),textParameters.textColor ); // Set how the embedded items are blended with text color. blendingMode.Resize( numberOfGlyphs, textParameters.isTextColorSet ? ColorBlendingMode::MULTIPLY : ColorBlendingMode::NONE ); @@ -435,9 +433,9 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, VectormCharactersToGlyph[run.characterRun.characterIndex]; + const GlyphIndex firstGlyph = textModel->mVisualModel->mCharactersToGlyph[run.characterRun.characterIndex]; const CharacterIndex lastCharacter = run.characterRun.characterIndex + run.characterRun.numberOfCharacters - 1u; - const GlyphIndex lastGlyphPlusOne = visualModel->mCharactersToGlyph[lastCharacter] + visualModel->mGlyphsPerCharacter[lastCharacter]; + const GlyphIndex lastGlyphPlusOne = textModel->mVisualModel->mCharactersToGlyph[lastCharacter] + textModel->mVisualModel->mGlyphsPerCharacter[lastCharacter]; for( GlyphIndex index = firstGlyph; index < lastGlyphPlusOne; ++index ) { @@ -447,9 +445,9 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, VectormEmbeddedItems ) + for( const auto& item : textModel->mLogicalModel->mEmbeddedItems ) { - const GlyphIndex glyphIndex = visualModel->mCharactersToGlyph[item.characterIndex]; + const GlyphIndex glyphIndex = textModel->mVisualModel->mCharactersToGlyph[item.characterIndex]; blendingMode[glyphIndex] = item.colorBlendingMode; } @@ -463,9 +461,9 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, VectormCharactersToGlyph[run.characterRun.characterIndex]; + const GlyphIndex firstGlyph = textModel->mVisualModel->mCharactersToGlyph[run.characterRun.characterIndex]; const CharacterIndex lastCharacter = run.characterRun.characterIndex + run.characterRun.numberOfCharacters - 1u; - const GlyphIndex lastGlyphPlusOne = visualModel->mCharactersToGlyph[lastCharacter] + visualModel->mGlyphsPerCharacter[lastCharacter]; + const GlyphIndex lastGlyphPlusOne = textModel->mVisualModel->mCharactersToGlyph[lastCharacter] + textModel->mVisualModel->mGlyphsPerCharacter[lastCharacter]; for( GlyphIndex index = firstGlyph; index < lastGlyphPlusOne; ++index ) { @@ -560,22 +558,12 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, Vector( rendererParameters.radius ) ); } + textModel->mHorizontalAlignment = isCircularTextLayout ? horizontalCircularAlignment : horizontalAlignment; + textModel->mLineWrapMode = LineWrap::WORD; + textModel->mIgnoreSpacesAfterText = false; + textModel->mMatchSystemLanguageDirection = false; Text::Layout::Parameters layoutParameters( textLayoutArea, - textToShape.Begin(), - lineBreakInfo.Begin(), - nullptr, - ( 0u != directions.Count() ) ? directions.Begin() : nullptr, - rendererParameters.glyphs.Begin(), - glyphsToCharacters.Begin(), - charactersPerGlyph.Begin(), - charactersToGlyph.Begin(), - glyphsPerCharacter.Begin(), - numberOfGlyphs, - isCircularTextLayout ? horizontalCircularAlignment : horizontalAlignment, - LineWrap::WORD, - 0.f, - false, - false ); // Outline's width + textModel ); // Resize the vector of positions to have the same size than the vector of glyphs. rendererParameters.positions.Resize( numberOfGlyphs ); @@ -594,39 +582,11 @@ Devel::PixelBuffer Render( const RendererParameters& textParameters, Vector