ItalicSpan: Span to change the font slant of characters.
Example:
===========================================================================================
Dali::Toolkit::Text::SpannableString ss =
Dali::Toolkit::Text::SpannableString::New("Testing italic span");
auto italicSpan =Dali::Toolkit::Text::ItalicSpan::New();
ss.AttachSpan(italicSpan,Dali::Toolkit::Text::Range::New(0u, 8u));
Dali::Toolkit::Text::SetSpannedText(textLabel,ss);
==========================================================================================
Change-Id: I9832203ed07433be292ca2dc66d82899ced288ce
#include <toolkit-text-utils.h>
#include <dali-toolkit/devel-api/text/spans/character-spacing-span.h>
#include <dali-toolkit/devel-api/text/spans/bold-span.h>
+#include <dali-toolkit/devel-api/text/spans/italic-span.h>
using namespace Dali;
using namespace Toolkit;
}
+Text::SpannableString CreateSpannableStringForItalicSpan()
+{
+ Text::SpannableString spannableString = Text::SpannableString::New("Hello");
+ DALI_TEST_CHECK(spannableString);
+
+ auto isAddedItalic = spannableString.AttachSpan(
+ Text::ItalicSpan::New(),
+ Text::Range::New(0u, 3u));
+ DALI_TEST_CHECK(isAddedItalic);
+
+ return spannableString;
+}
+
void CheckColorIndices(const Text::ColorIndex* const colorIndicesBuffer,
uint32_t numberOfIndices,
std::vector<uint32_t> indicesToCheck,
DALI_TEST_EQUALS(validFonts[0].isBoldRequired, true, TEST_LOCATION);
END_TEST;
+}
+
+int UtcDaliToolkitTextLabelSetSpannedText_ItalicSpan(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliToolkitTextLabelSetSpannedText_ItalicSpan");
+
+ TextLabel textLabel = TextLabel::New();
+ DALI_TEST_CHECK(textLabel);
+
+ application.GetScene().Add(textLabel);
+
+ Text::SpannableString spannableString = CreateSpannableStringForItalicSpan();
+
+ Text::SetSpannedText(textLabel, spannableString);
+ application.SendNotification();
+ application.Render();
+
+ Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel);
+ const Vector<Text::FontRun>& validFontsItalic = labelImpl.GetTextController()->GetTextModel()->GetFontRuns();
+
+ DALI_TEST_EQUALS(validFontsItalic.Count(), 2, TEST_LOCATION);
+ DALI_TEST_EQUALS(validFontsItalic[0].characterRun.characterIndex, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(validFontsItalic[0].characterRun.GetEndCharacterIndex(), 3, TEST_LOCATION);
+ DALI_TEST_EQUALS(validFontsItalic[0].isItalicRequired, true, TEST_LOCATION);
+ END_TEST;
}
\ No newline at end of file
utc-Dali-Text-CharacterSpacingSpan.cpp
utc-Dali-Text-FontSpan.cpp
utc-Dali-Text-BoldSpan.cpp
+ utc-Dali-Text-ItalicSpan.cpp
utc-Dali-Text-Range.cpp
utc-Dali-Text-SpannableString.cpp
utc-Dali-Text-UnderlineSpan.cpp
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/text/spans/italic-span.h>
+
+using namespace Dali;
+using namespace Toolkit;
+
+int UtcDaliToolkitTextItalicSpanNew(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliToolkitTextItalicSpanNew");
+
+ auto italicSpan = Text::ItalicSpan::New();
+ DALI_TEST_CHECK(italicSpan);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextItalicSpanDownCast(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliToolkitTextItalicSpanDownCast");
+
+ Text::BaseSpan baseSpan = Text::ItalicSpan::New();
+
+ DALI_TEST_CHECK(baseSpan);
+ Text::ItalicSpan italicSpan = Text::ItalicSpan::DownCast(baseSpan);
+
+ DALI_TEST_CHECK(italicSpan);
+ END_TEST;
+}
\ No newline at end of file
${devel_api_src_dir}/text/spans/font-span.cpp
${devel_api_src_dir}/text/spans/underline-span.cpp
${devel_api_src_dir}/text/spans/bold-span.cpp
+ ${devel_api_src_dir}/text/spans/italic-span.cpp
${devel_api_src_dir}/transition-effects/cube-transition-cross-effect.cpp
${devel_api_src_dir}/transition-effects/cube-transition-effect.cpp
${devel_api_src_dir}/transition-effects/cube-transition-fold-effect.cpp
${devel_api_src_dir}/text/spans/font-span.h
${devel_api_src_dir}/text/spans/underline-span.h
${devel_api_src_dir}/text/spans/bold-span.h
+ ${devel_api_src_dir}/text/spans/italic-span.h
)
SET( devel_api_tool_bar_header_files
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/text/spans/italic-span.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/spannable/spans/italic-span-impl.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+ItalicSpan ItalicSpan::New()
+{
+ return Internal::ItalicSpan::New();
+}
+
+ItalicSpan::ItalicSpan() = default;
+
+ItalicSpan::ItalicSpan(const ItalicSpan& rhs) = default;
+
+ItalicSpan::ItalicSpan(ItalicSpan&& rhs) = default;
+
+ItalicSpan& ItalicSpan::operator=(const ItalicSpan& rhs) = default;
+
+ItalicSpan& ItalicSpan::operator=(ItalicSpan&& rhs) = default;
+
+ItalicSpan::~ItalicSpan() = default;
+
+
+ItalicSpan ItalicSpan::DownCast(BaseHandle handle)
+{
+ return ItalicSpan(dynamic_cast<Dali::Toolkit::Text::Internal::ItalicSpan*>(handle.GetObjectPtr()));
+}
+
+ItalicSpan::ItalicSpan(Internal::ItalicSpan* internal)
+: BaseSpan(internal)
+{
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_ITALICSPAN_H
+#define DALI_TOOLKIT_TEXT_ITALICSPAN_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/text/spans/base-span.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+namespace Internal DALI_INTERNAL
+{
+class ItalicSpan;
+}
+
+/**
+ * @brief ItalicSpan is a handle to an object that specifies the Italic font for range of characters.
+ */
+class DALI_TOOLKIT_API ItalicSpan : public BaseSpan
+{
+public:
+ /**
+ * @brief Create an Initialized ItalicSpan.
+ *
+ * @return A handle to a newly allocated Dali resource.
+ */
+ static ItalicSpan New();
+
+ /**
+ * @brief Creates an uninitialized ItalicSpan handle.
+ *
+ * Calling member functions with an uninitialized ItalicSpan handle is not allowed.
+ */
+ ItalicSpan();
+
+ /**
+ * @brief Copy constructor.
+ * @param[in] rhs A reference to the copied handle.
+ */
+ ItalicSpan(const ItalicSpan& rhs);
+
+ /**
+ * @brief Move constructor.
+ * @param rhs A reference to the handle to move.
+ */
+ ItalicSpan(ItalicSpan&& rhs);
+
+ /**
+ * @brief Assignment operator.
+ * @param[in] rhs A reference to the copied handle
+ * @return A reference to this
+ */
+ ItalicSpan& operator=(const ItalicSpan& rhs);
+
+ /**
+ * @brief Move assignment operator.
+ * @param[in] rhs A reference to the moved handle.
+ * @return A reference to this.
+ */
+ ItalicSpan& operator=(ItalicSpan&& rhs);
+
+ /**
+ * @brief Non virtual destructor.
+ */
+ ~ItalicSpan();
+
+ /**
+ * @brief Downcasts to a ItalicSpan handle.
+ * If handle is not a ItalicSpan, the returned handle is left uninitialized.
+ *
+ * @param[in] handle Handle to an object.
+ * @return ItalicSpan handle or an uninitialized handle.
+ */
+ static ItalicSpan DownCast(BaseHandle handle);
+
+ // Not intended for application developers.
+ /**
+ * @brief This constructor is used internally to Create an initialized ItalicSpan handle.
+ *
+ * @param[in] italicSpan Pointer to internal ItalicSpan.
+ */
+ explicit DALI_INTERNAL ItalicSpan(Internal::ItalicSpan* italicSpan);
+
+};
+
+}// namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif //DALI_TOOLKIT_TEXT_ITALICSPAN_H
\ No newline at end of file
${toolkit_src_dir}/text/spannable/spans/font-span-impl.cpp
${toolkit_src_dir}/text/spannable/spans/underline-span-impl.cpp
${toolkit_src_dir}/text/spannable/spans/bold-span-impl.cpp
+ ${toolkit_src_dir}/text/spannable/spans/italic-span-impl.cpp
${toolkit_src_dir}/text/spannable/span-ranges-container-impl.cpp
${toolkit_src_dir}/text/hyphenator.cpp
${toolkit_src_dir}/text/text-enumerations-impl.cpp
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/text/spannable/spans/italic-span-impl.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/font-description-run.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+namespace Internal
+{
+ItalicSpan::ItalicSpan():BaseSpan()
+{
+}
+
+ItalicSpan::~ItalicSpan()
+{
+}
+
+Dali::Toolkit::Text::ItalicSpan ItalicSpan::New()
+{
+ ItalicSpanPtr object = new ItalicSpan();
+ Dali::Toolkit::Text::ItalicSpan handle = Dali::Toolkit::Text::ItalicSpan(object.Get());
+ return handle;
+}
+void ItalicSpan::CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const
+{
+ FontDescriptionRun fontRun;
+ fontRun.slant = TextAbstraction::FontSlant::ITALIC;
+ fontRun.slantDefined = true;
+ fontRun.characterRun.characterIndex = range.GetStartIndex();
+ fontRun.characterRun.numberOfCharacters = range.GetNumberOfIndices();
+ logicalModel->mFontDescriptionRuns.PushBack(fontRun);
+}
+
+} // namespace Internal
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
\ No newline at end of file
--- /dev/null
+#ifndef DALI_TOOLKIT_INTERNAL_TEXT_ITALIC_SPAN_IMPL_H
+#define DALI_TOOLKIT_INTERNAL_TEXT_ITALIC_SPAN_IMPL_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali-toolkit/devel-api/text/spans/italic-span.h>
+#include <memory>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/logical-model-impl.h>
+#include <dali-toolkit/internal/text/spannable/spans/base-span-impl.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+namespace Internal
+{
+class ItalicSpan;
+using ItalicSpanPtr = IntrusivePtr<ItalicSpan>;
+
+/**
+ * @copydoc Dali::Toolkit::Text::ItalicSpan
+ */
+class ItalicSpan : public BaseSpan
+{
+public:
+ /**
+ * @brief Creates a new ItalicSpan object.
+ */
+ static Dali::Toolkit::Text::ItalicSpan New();
+
+ /**
+ * Default Constructor
+ */
+ ItalicSpan();
+
+ ///< Deleted copy constructor
+ ItalicSpan(const ItalicSpan&) = delete;
+
+ ///< Deleted move constructor
+ ItalicSpan(ItalicSpan&&) = delete;
+
+ ///< Deleted copy assignment operator
+ ItalicSpan& operator=(const ItalicSpan&) = delete;
+
+ ///< Deleted move assignment operator
+ ItalicSpan& operator=(ItalicSpan&&) = delete;
+
+ /**
+ * @brief Destructor.
+ *
+ * A reference counted object may only be deleted by calling Unreference().
+ */
+ ~ItalicSpan() override;
+
+ //Methods for internal only
+ /**
+ * @copydoc Dali::Toolkit::Text::BaseSpan::CreateStyleCharacterRun
+ */
+ void CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const override;
+
+}; // class ItalicSpan
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Internal::ItalicSpan& GetImplementation(Dali::Toolkit::Text::ItalicSpan& italicSpan)
+{
+ DALI_ASSERT_ALWAYS(italicSpan && "italicSpan handle is empty");
+
+ BaseObject& object = italicSpan.GetBaseObject();
+
+ return static_cast<Internal::ItalicSpan&>(object);
+}
+
+inline const Internal::ItalicSpan& GetImplementation(const Dali::Toolkit::Text::ItalicSpan& italicSpan)
+{
+ DALI_ASSERT_ALWAYS(italicSpan && "italicSpan handle is empty");
+
+ const BaseObject& object = italicSpan.GetBaseObject();
+
+ return static_cast<const Internal::ItalicSpan&>(object);
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+
+#endif // DALI_TOOLKIT_INTERNAL_TEXT_ITALIC_SPAN_IMPL_H
\ No newline at end of file