X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Ftext%2Ftext-utils-devel.cpp;h=7b5e36e3b0e1ce5b9af07a61a31413534284b4c2;hb=150668a2aa35d52ebc3f6a27f55f5cd3a22fcf16;hp=0112e3290bbd3b87e7ae9455d70d6bf93d809947;hpb=f2039d47f9bed8104575da80a2ecf0bb6e37ff8d;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/devel-api/text/text-utils-devel.cpp b/dali-toolkit/devel-api/text/text-utils-devel.cpp index 0112e32..7b5e36e 100644 --- a/dali-toolkit/devel-api/text/text-utils-devel.cpp +++ b/dali-toolkit/devel-api/text/text-utils-devel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -172,7 +173,12 @@ void ShapeTextPreprocess(const RendererParameters& textParameters, TextAbstracti MarkupProcessData markupProcessData(colorRuns, fontDescriptionRuns, - textModel->mLogicalModel->mEmbeddedItems); + textModel->mLogicalModel->mEmbeddedItems, + textModel->mLogicalModel->mAnchors, + textModel->mLogicalModel->mUnderlinedCharacterRuns, + textModel->mLogicalModel->mBackgroundColorRuns, + textModel->mLogicalModel->mStrikethroughCharacterRuns, + textModel->mLogicalModel->mBoundedParagraphRuns); if(textParameters.markupEnabled) { @@ -810,9 +816,13 @@ void Ellipsis(const RendererParameters& textParameters, TextAbstraction::TextRen Text::ModelPtr& textModel = internalDataModel.textModel; FontClient& fontClient = internalDataModel.fontClient; - Vector& lines = textModel->mVisualModel->mLines; // The laid out lines. - Vector& isEmoji = internalDataModel.isEmoji; - const Size textLayoutArea = internalDataModel.textLayoutArea; + Vector& lines = textModel->mVisualModel->mLines; // The laid out lines. + Vector& isEmoji = internalDataModel.isEmoji; + const Size textLayoutArea = internalDataModel.textLayoutArea; + const float characterSpacing = textModel->mVisualModel->GetCharacterSpacing(); + float calculatedAdvance = 0.f; + Vector& glyphToCharacterMap = textModel->mVisualModel->mGlyphsToCharacters; + const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin(); //////////////////////////////////////////////////////////////////////////////// // Ellipsis the text. //////////////////////////////////////////////////////////////////////////////// @@ -825,7 +835,7 @@ void Ellipsis(const RendererParameters& textParameters, TextAbstraction::TextRen { Length finalNumberOfGlyphs = 0u; - if((line.ascender - line.descender) > textLayoutArea.height) + if((GetLineHeight(line, (lines.Size() == 1))) > textLayoutArea.height) { // The height of the line is bigger than the height of the text area. // Show the ellipsis glyph even if it doesn't fit in the text area. @@ -898,7 +908,8 @@ void Ellipsis(const RendererParameters& textParameters, TextAbstraction::TextRen firstPenSet = true; } - removedGlypsWidth += std::min(glyphToRemove.advance, (glyphToRemove.xBearing + glyphToRemove.width)); + calculatedAdvance = GetCalculatedAdvance(*(textModel->mLogicalModel->mText.Begin() + (*(glyphToCharacterMapBuffer + index))), characterSpacing, glyphToRemove.advance); + removedGlypsWidth += std::min(calculatedAdvance, (glyphToRemove.xBearing + glyphToRemove.width)); // Calculate the width of the ellipsis glyph and check if it fits. const float ellipsisGlyphWidth = ellipsisGlyph.width + ellipsisGlyph.xBearing; @@ -975,6 +986,7 @@ Size LayoutText(const RendererParameters& textParameters, TextAbstraction::TextR const bool isTextMirrored = internalDataModel.isTextMirrored; const Vector& mirroredUtf32Characters = internalDataModel.mirroredUtf32Characters; const Length numberOfCharacters = internalDataModel.numberOfCharacters; + const auto ellipsisPosition = textModel->mEllipsisPosition; Layout::Type layout = Layout::SINGLELINE; @@ -1028,9 +1040,8 @@ Size LayoutText(const RendererParameters& textParameters, TextAbstraction::TextR // Resize the vector of positions to have the same size than the vector of glyphs. rendererParameters.positions.Resize(numberOfGlyphs); - textModel->mLineWrapMode = LineWrap::WORD; - textModel->mIgnoreSpacesAfterText = false; - textModel->mMatchSystemLanguageDirection = false; + textModel->mLineWrapMode = Text::LineWrap::WORD; + textModel->mIgnoreSpacesAfterText = false; Text::Layout::Parameters layoutParameters(internalDataModel.textLayoutArea, textModel); @@ -1051,7 +1062,8 @@ Size LayoutText(const RendererParameters& textParameters, TextAbstraction::TextR layoutEngine.LayoutText(layoutParameters, newLayoutSize, textParameters.ellipsisEnabled, - isAutoScrollEnabled); + isAutoScrollEnabled, + ellipsisPosition); return newLayoutSize; } @@ -1384,7 +1396,8 @@ void UpdateBuffer(Devel::PixelBuffer src, Devel::PixelBuffer dst, unsigned int x } const unsigned int bytesPerPixel = Dali::Pixel::GetBytesPerPixel(pixelFormat); - if(bytesPerPixel == 0u || bytesPerPixel == 12u || bytesPerPixel == 24u) + // Ignore when pixelFormat is invalid or contain float + if(bytesPerPixel == 0u || bytesPerPixel == 6u || bytesPerPixel == 12u) { return; } @@ -1515,12 +1528,14 @@ Dali::Property::Array RenderForLastIndex(RendererParameters& textParameters) float penY = 0.f; float lineSize = internalData.layoutEngine.GetDefaultLineSize(); float lineOffset = 0.f; + bool isLastLine; for(unsigned int index = 0u; index < numberOfLines; ++index) { const LineRun& line = *(lines.Begin() + index); numberOfCharacters += line.characterRun.numberOfCharacters; + isLastLine = (index == numberOfLines - 1); - lineOffset = lineSize > 0.f ? lineSize : (line.ascender + -line.descender); + lineOffset = lineSize > 0.f ? lineSize : GetLineHeight(line, isLastLine); penY += lineOffset; if((penY + lineOffset) > boundingBox) {