2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/text/spannable/spans/character-spacing-span-impl.h>
22 #include <dali-toolkit/internal/text/color-run.h>
23 #include <dali-toolkit/internal/text/markup-tags-and-attributes.h>
33 struct CharacterSpacingSpan::Impl
35 float mCharacterSpacing; ///< The character-spacing-value.
36 bool mCharacterSpacingDefined : 1; ///< Whether the character-spacing-value is defined.
39 CharacterSpacingSpan::CharacterSpacingSpan()
40 : BaseSpan(Dali::Toolkit::Text::SpanType::Value::CHARACTER_SPACING)
42 mImpl = std::make_unique<Impl>();
45 CharacterSpacingSpan ::~CharacterSpacingSpan()
49 Dali::Toolkit::Text::CharacterSpacingSpan CharacterSpacingSpan::New(const float& value)
51 CharacterSpacingSpanPtr object = new CharacterSpacingSpan();
52 object->SetCharacterSpacing(value);
54 Dali::Toolkit::Text::CharacterSpacingSpan handle = Dali::Toolkit::Text::CharacterSpacingSpan(object.Get());
60 float CharacterSpacingSpan::GetCharacterSpacing() const
62 return mImpl->mCharacterSpacing;
65 bool CharacterSpacingSpan::IsCharacterSpacingDefined() const
67 return mImpl->mCharacterSpacingDefined;
70 void CharacterSpacingSpan::SetCharacterSpacing(const float& value)
72 mImpl->mCharacterSpacing = value;
73 mImpl->mCharacterSpacingDefined = true;
76 void CharacterSpacingSpan::CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const
78 CharacterSpacingCharacterRun characterSpacingCharacterRun;
79 characterSpacingCharacterRun.characterRun.characterIndex = range.GetStartIndex();
80 characterSpacingCharacterRun.characterRun.numberOfCharacters = range.GetNumberOfIndices();
81 characterSpacingCharacterRun.value = mImpl->mCharacterSpacing;
82 logicalModel->mCharacterSpacingCharacterRuns.PushBack(characterSpacingCharacterRun);
83 logicalModel->mCharacterSpacingRunsUpdated = true;
86 } // namespace Internal
90 } // namespace Toolkit