/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
// EXTERNAL INCLUDES
#include <dali/devel-api/text-abstraction/font-client.h>
#include <limits>
+#include <cstring> ///< for memcpy
// INTERNAL INCLUDES
#include <dali-toolkit/internal/text/bidirectional-support.h>
#include <dali-toolkit/internal/text/hyphenator.h>
#include <dali-toolkit/internal/text/layouts/layout-engine.h>
#include <dali-toolkit/internal/text/layouts/layout-parameters.h>
-#include <dali-toolkit/internal/text/markup-processor.h>
+#include <dali-toolkit/internal/text/markup-processor/markup-processor.h>
#include <dali-toolkit/internal/text/multi-language-support.h>
#include <dali-toolkit/internal/text/segmentation.h>
#include <dali-toolkit/internal/text/shaper.h>
-#include <dali-toolkit/internal/text/text-controller-impl.h>
+#include <dali-toolkit/internal/text/controller/text-controller-impl.h>
namespace Dali
{
LineWrap::Mode wrapMode,
bool ellipsisEnabled,
DevelText::EllipsisPosition::Type ellipsisPosition,
- float lineSpacing)
+ float lineSpacing,
+ float characterSpacing)
{
textModel = Model::New(); ///< Pointer to the text's model.
LogicalModelPtr logicalModel = textModel->mLogicalModel;
logicalModel->mAnchors,
logicalModel->mUnderlinedCharacterRuns,
logicalModel->mBackgroundColorRuns,
- logicalModel->mStrikethroughCharacterRuns);
+ logicalModel->mStrikethroughCharacterRuns,
+ logicalModel->mBoundedParagraphRuns,
+ logicalModel->mCharacterSpacingCharacterRuns);
Length textSize = 0u;
const uint8_t* utf8 = NULL;
if(markupProcessorEnabled)
{
- ProcessMarkupString(text, markupProcessData);
+ MarkupPropertyData markupPropertyData(Color::MEDIUM_BLUE, Color::DARK_MAGENTA);
+
+ ProcessMarkupString(text, markupPropertyData, markupProcessData);
textSize = markupProcessData.markupProcessedText.size();
// This is a bit horrible but std::string returns a (signed) char*
textModel->mEllipsisPosition = ellipsisPosition;
textModel->mVisualModel->SetEllipsisPosition(ellipsisPosition);
+ //Inset
+ textModel->mRemoveFrontInset = true;
+ textModel->mRemoveBackInset = true;
+
// 1) Convert to utf32
Vector<Character>& utf32Characters = logicalModel->mText;
utf32Characters.Resize(textSize);
Vector<LineBreakInfo>& lineBreakInfo = logicalModel->mLineBreakInfo;
lineBreakInfo.Resize(characterCount);
- SetLineBreakInfo(utf32Characters,
+ TextAbstraction::Segmentation segmentation = TextAbstraction::Segmentation::Get();
+ SetLineBreakInfo(segmentation,
+ utf32Characters,
0u,
characterCount,
lineBreakInfo);
CharacterIndex end = characterCount;
LineBreakInfo* lineBreakInfoBuffer = lineBreakInfo.Begin();
+ TextAbstraction::Hyphenation hyphenation = TextAbstraction::Hyphenation::Get();
+
for(CharacterIndex index = 0; index < end; index++)
{
CharacterIndex wordEnd = index;
wordEnd++;
}
- Vector<bool> hyphens = GetWordHyphens(utf32Characters.Begin() + index, wordEnd - index, nullptr);
+ Vector<bool> hyphens = GetWordHyphens(hyphenation, utf32Characters.Begin() + index, wordEnd - index, nullptr);
for(CharacterIndex i = 0; i < (wordEnd - index); i++)
{
// Validates the fonts. If there is a character with no assigned font it sets a default one.
// After this call, fonts are validated.
- multilanguageSupport.ValidateFonts(utf32Characters,
+ multilanguageSupport.ValidateFonts(fontClient,
+ utf32Characters,
scripts,
fontDescriptionRuns,
fontDescription,
TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
+ 1.0f,
0u,
characterCount,
validFonts);
Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = logicalModel->mBidirectionalParagraphInfo;
// Calculates the bidirectional info for the whole paragraph if it contains right to left scripts.
- SetBidirectionalInfo(utf32Characters,
+
+ TextAbstraction::BidirectionalSupport bidirectionalSupport = TextAbstraction::BidirectionalSupport::Get();
+
+ SetBidirectionalInfo(bidirectionalSupport,
+ utf32Characters,
scripts,
lineBreakInfo,
0u,
if(0u != bidirectionalInfo.Count())
{
// Only set the character directions if there is right to left characters.
- GetCharactersDirection(bidirectionalInfo,
+ GetCharactersDirection(bidirectionalSupport,
+ bidirectionalInfo,
characterCount,
0u,
characterCount,
characterDirections);
// This paragraph has right to left text. Some characters may need to be mirrored.
- textMirrored = GetMirroredText(utf32Characters,
+ textMirrored = GetMirroredText(bidirectionalSupport,
+ utf32Characters,
characterDirections,
bidirectionalInfo,
0u,
const Vector<Character>& textToShape = textMirrored ? mirroredUtf32Characters : utf32Characters;
- ShapeText(textToShape,
+ TextAbstraction::Shaping shaping = TextAbstraction::Shaping::Get();
+
+ ShapeText(shaping,
+ fontClient,
+ textToShape,
lineBreakInfo,
scripts,
validFonts,
visualModel->CreateGlyphsPerCharacterTable(0u, 0u, characterCount);
visualModel->CreateCharacterToGlyphTable(0u, 0u, characterCount);
+ visualModel->SetCharacterSpacing(characterSpacing);
+
const Length numberOfGlyphs = glyphs.Count();
// 8) Get the glyph metrics
textModel->mHorizontalAlignment = Text::HorizontalAlignment::BEGIN;
textModel->mIgnoreSpacesAfterText = true;
Layout::Parameters layoutParameters(textArea,
- textModel);
+ textModel,
+ fontClient,
+ bidirectionalSupport);
Vector<LineRun>& lines = visualModel->mLines;
layoutParameters.startLineIndex = 0u;
layoutParameters.estimatedNumberOfLines = logicalModel->mParagraphInfo.Count();
- bool isAutoScroll = false;
+ bool isAutoScroll = false;
+ bool isAutoScrollMaxTextureExceeded = false;
+ bool isHiddenInputEnabled = false;
layoutEngine.LayoutText(layoutParameters,
layoutSize,
false,
isAutoScroll,
+ isAutoScrollMaxTextureExceeded,
+ isHiddenInputEnabled,
ellipsisPosition);
if(options.align)