utc-Dali-Dictionary.cpp
utc-Dali-FeedbackStyle.cpp
utc-Dali-ItemView-internal.cpp
+ utc-Dali-LineHelperFunctions.cpp
utc-Dali-LogicalModel.cpp
utc-Dali-PropertyHelper.cpp
+ utc-Dali-Text-AbstractStyleCharacterRun.cpp
utc-Dali-Text-Characters.cpp
utc-Dali-Text-CharacterSetConversion.cpp
utc-Dali-Text-Circular.cpp
--- /dev/null
+/*
+ * Copyright (c) 2020 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 <stdlib.h>
+#include <unistd.h>
+#include <iostream>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/internal/text/line-helper-functions.h>
+#include <dali-toolkit/internal/text/rendering/text-typesetter.h>
+#include <dali-toolkit/internal/text/rendering/view-model.h>
+#include <dali-toolkit/internal/text/text-controller.h>
+#include <toolkit-text-utils.h>
+
+using namespace Dali;
+using namespace Toolkit;
+using namespace Text;
+
+int UtcDaliGetPreOffsetVerticalLineAlignmentWithNegativeLineSpacing(void)
+{
+ tet_infoline(" UtcDaliGetPreOffsetVerticalLineAlignmentWithNegativeLineSpacing ");
+ ToolkitTestApplication application;
+
+ uint32_t expectedNumberOfLines = 2u;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel(controller);
+
+ // Sets the text.
+ controller->SetMarkupProcessorEnabled(true);
+ controller->SetTextElideEnabled(false);
+ controller->SetText("<p rel-line-height=0.5>Line one Line two</p>");
+
+ // Creates the text's model and relais-out the text.
+ const Size relayoutSize(120.f, 100.f);
+ controller->Relayout(relayoutSize);
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK(model);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(model->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
+ DALI_TEST_CHECK(model->GetLines());
+
+ const LineRun& lineOne = *(model->GetLines() + 0u);
+ const LineRun& lineTwo = *(model->GetLines() + 1u);
+
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), 0.0f, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), 0.0f, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliGetPreOffsetVerticalLineAlignmentWithPositiveLineSpacing(void)
+{
+ tet_infoline(" UtcDaliGetPreOffsetVerticalLineAlignmentWithPositiveLineSpacing ");
+ ToolkitTestApplication application;
+
+ uint32_t expectedNumberOfLines = 2u;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel(controller);
+
+ // Sets the text.
+ controller->SetMarkupProcessorEnabled(true);
+ controller->SetTextElideEnabled(false);
+ controller->SetText("<p rel-line-height=2.0>Line one Line two</p>");
+
+ // Creates the text's model and relais-out the text.
+ const Size relayoutSize(120.f, 100.f);
+ controller->Relayout(relayoutSize);
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK(model);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(model->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
+ DALI_TEST_CHECK(model->GetLines());
+
+ const LineRun& lineOne = *(model->GetLines() + 0u);
+ const LineRun& lineTwo = *(model->GetLines() + 1u);
+
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), 9.5f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), 19.0f, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), 0.0f, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliGetPostOffsetVerticalLineAlignmentWithNegativeLineSpacing(void)
+{
+ tet_infoline(" UtcDaliGetPostOffsetVerticalLineAlignmentWithNegativeLineSpacing ");
+ ToolkitTestApplication application;
+
+ uint32_t expectedNumberOfLines = 2u;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel(controller);
+
+ // Sets the text.
+ controller->SetMarkupProcessorEnabled(true);
+ controller->SetTextElideEnabled(false);
+ controller->SetText("<p rel-line-height=0.5>Line one Line two</p>");
+
+ // Creates the text's model and relais-out the text.
+ const Size relayoutSize(120.f, 100.f);
+ controller->Relayout(relayoutSize);
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK(model);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(model->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
+ DALI_TEST_CHECK(model->GetLines());
+
+ const LineRun& lineOne = *(model->GetLines() + 0u);
+ const LineRun& lineTwo = *(model->GetLines() + 1u);
+
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), -9.5f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), -9.5f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), -9.5f, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), 0.0f, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliGetPostOffsetVerticalLineAlignmentWithPositiveLineSpacing(void)
+{
+ tet_infoline(" UtcDaliGetPostOffsetVerticalLineAlignmentWithPositiveLineSpacing ");
+ ToolkitTestApplication application;
+
+ uint32_t expectedNumberOfLines = 2u;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel(controller);
+
+ // Sets the text.
+ controller->SetMarkupProcessorEnabled(true);
+ controller->SetTextElideEnabled(false);
+ controller->SetText("<p rel-line-height=2.0>Line one Line two</p>");
+
+ // Creates the text's model and relais-out the text.
+ const Size relayoutSize(120.f, 100.f);
+ controller->Relayout(relayoutSize);
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK(model);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(model->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
+ DALI_TEST_CHECK(model->GetLines());
+
+ const LineRun& lineOne = *(model->GetLines() + 0u);
+ const LineRun& lineTwo = *(model->GetLines() + 1u);
+
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), 19.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), 9.5f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), 0.0f, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), 0.0f, TEST_LOCATION);
+ END_TEST;
+}
--- /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 <stdlib.h>
+#include <unistd.h>
+#include <iostream>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/internal/text/bounded-paragraph-run.h>
+#include <dali-toolkit/internal/text/character-spacing-character-run.h>
+#include <dali-toolkit/internal/text/color-run.h>
+#include <dali-toolkit/internal/text/font-description-run.h>
+#include <dali-toolkit/internal/text/strikethrough-character-run.h>
+#include <dali-toolkit/internal/text/underlined-character-run.h>
+
+using namespace Dali;
+using namespace Toolkit;
+using namespace Text;
+
+// Tests the following functions for AbstractStyleCharacterRun.
+// CharacterIndex GetStartCharacterIndex() const;
+// Length GetNumberOfCharacters() const;
+// CharacterIndex GetEndCharacterIndex() const;
+
+template<typename TYPE_OF_RUN>
+void TestAbstractStyleCharacterRunEmptyCharacterRun(std::string test_name)
+{
+ tet_infoline(" TestAbstractStyleCharacterRunEmptyCharacterRun ");
+ std::cout << " testing " << test_name << std::endl;
+
+ tet_infoline(" Default Constructor ");
+ TYPE_OF_RUN abstractStyleCharacterRun;
+
+ tet_infoline(" AbstractStyleCharacterRun_GetStartCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetStartCharacterIndex(), 0u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetNumberOfCharacters ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetNumberOfCharacters(), 0u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetEndCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetEndCharacterIndex(), 0u, TEST_LOCATION);
+}
+
+template<typename TYPE_OF_RUN>
+void TestAbstractStyleCharacterRunOneCharacter(std::string test_name)
+{
+ tet_infoline(" TestAbstractStyleCharacterRunOneCharacter ");
+ std::cout << " testing " << test_name << std::endl;
+
+ TYPE_OF_RUN abstractStyleCharacterRun;
+ abstractStyleCharacterRun.characterRun.numberOfCharacters = 1u;
+ tet_infoline(" AbstractStyleCharacterRun_GetStartCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetStartCharacterIndex(), 0u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetNumberOfCharacters ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetNumberOfCharacters(), 1u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetEndCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetEndCharacterIndex(), 0u, TEST_LOCATION);
+
+ abstractStyleCharacterRun.characterRun.characterIndex = 5u;
+ tet_infoline(" AbstractStyleCharacterRun_GetStartCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetStartCharacterIndex(), 5u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetNumberOfCharacters ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetNumberOfCharacters(), 1u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetEndCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetEndCharacterIndex(), 5u, TEST_LOCATION);
+}
+
+template<typename TYPE_OF_RUN>
+void TestAbstractStyleCharacterRunMoreThanOneCharacter(std::string test_name)
+{
+ tet_infoline(" TestAbstractStyleCharacterRunOneCharacter ");
+ std::cout << " testing " << test_name << std::endl;
+
+ TYPE_OF_RUN abstractStyleCharacterRun;
+ abstractStyleCharacterRun.characterRun.numberOfCharacters = 15u;
+ tet_infoline(" AbstractStyleCharacterRun_GetStartCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetStartCharacterIndex(), 0u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetNumberOfCharacters ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetNumberOfCharacters(), 15u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetEndCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetEndCharacterIndex(), 14u, TEST_LOCATION);
+
+ abstractStyleCharacterRun.characterRun.characterIndex = 5u;
+ tet_infoline(" AbstractStyleCharacterRun_GetStartCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetStartCharacterIndex(), 5u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetNumberOfCharacters ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetNumberOfCharacters(), 15u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetEndCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetEndCharacterIndex(), 19u, TEST_LOCATION);
+}
+
+int UtcDaliTextAbstractStyleCharacterRun(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextAbstractStyleCharacterRun");
+
+ TestAbstractStyleCharacterRunEmptyCharacterRun<Dali::Toolkit::Text::ColorRun>("ColorRun");
+ TestAbstractStyleCharacterRunEmptyCharacterRun<Dali::Toolkit::Text::CharacterSpacingCharacterRun>("CharacterSpacingCharacterRun");
+ TestAbstractStyleCharacterRunEmptyCharacterRun<Dali::Toolkit::Text::FontDescriptionRun>("FontDescriptionRun");
+ TestAbstractStyleCharacterRunEmptyCharacterRun<Dali::Toolkit::Text::UnderlinedCharacterRun>("UnderlinedCharacterRun");
+ TestAbstractStyleCharacterRunEmptyCharacterRun<Dali::Toolkit::Text::StrikethroughCharacterRun>("StrikethroughCharacterRun");
+ TestAbstractStyleCharacterRunEmptyCharacterRun<Dali::Toolkit::Text::BoundedParagraphRun>("BoundedParagraphRun");
+
+ TestAbstractStyleCharacterRunOneCharacter<Dali::Toolkit::Text::ColorRun>("ColorRun");
+ TestAbstractStyleCharacterRunOneCharacter<Dali::Toolkit::Text::CharacterSpacingCharacterRun>("CharacterSpacingCharacterRun");
+ TestAbstractStyleCharacterRunOneCharacter<Dali::Toolkit::Text::FontDescriptionRun>("FontDescriptionRun");
+ TestAbstractStyleCharacterRunOneCharacter<Dali::Toolkit::Text::UnderlinedCharacterRun>("UnderlinedCharacterRun");
+ TestAbstractStyleCharacterRunOneCharacter<Dali::Toolkit::Text::StrikethroughCharacterRun>("StrikethroughCharacterRun");
+ TestAbstractStyleCharacterRunOneCharacter<Dali::Toolkit::Text::BoundedParagraphRun>("BoundedParagraphRun");
+
+ TestAbstractStyleCharacterRunMoreThanOneCharacter<Dali::Toolkit::Text::ColorRun>("ColorRun");
+ TestAbstractStyleCharacterRunMoreThanOneCharacter<Dali::Toolkit::Text::CharacterSpacingCharacterRun>("CharacterSpacingCharacterRun");
+ TestAbstractStyleCharacterRunMoreThanOneCharacter<Dali::Toolkit::Text::FontDescriptionRun>("FontDescriptionRun");
+ TestAbstractStyleCharacterRunMoreThanOneCharacter<Dali::Toolkit::Text::UnderlinedCharacterRun>("UnderlinedCharacterRun");
+ TestAbstractStyleCharacterRunMoreThanOneCharacter<Dali::Toolkit::Text::StrikethroughCharacterRun>("StrikethroughCharacterRun");
+ TestAbstractStyleCharacterRunMoreThanOneCharacter<Dali::Toolkit::Text::BoundedParagraphRun>("BoundedParagraphRun");
+
+ END_TEST;
+}
${toolkit_src_dir}/image-loader/image-load-thread.cpp
${toolkit_src_dir}/image-loader/image-url-impl.cpp
${toolkit_src_dir}/styling/style-manager-impl.cpp
+ ${toolkit_src_dir}/text/abstract-style-character-run.cpp
${toolkit_src_dir}/text/bidirectional-support.cpp
${toolkit_src_dir}/text/bounded-paragraph-helper-functions.cpp
${toolkit_src_dir}/text/character-set-conversion.cpp
${toolkit_src_dir}/text/multi-language-support.cpp
${toolkit_src_dir}/text/hidden-text.cpp
${toolkit_src_dir}/text/input-filter.cpp
+ ${toolkit_src_dir}/text/line-helper-functions.cpp
${toolkit_src_dir}/text/property-string-parser.cpp
${toolkit_src_dir}/text/segmentation.cpp
${toolkit_src_dir}/text/shaper.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.
+ *
+ */
+
+// FILE HEADER
+#include <dali-toolkit/internal/text/abstract-style-character-run.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+CharacterIndex AbstractStyleCharacterRun::GetStartCharacterIndex() const
+{
+ return characterRun.characterIndex;
+}
+
+Length AbstractStyleCharacterRun::GetNumberOfCharacters() const
+{
+ return characterRun.numberOfCharacters;
+}
+
+CharacterIndex AbstractStyleCharacterRun::GetEndCharacterIndex() const
+{
+ return characterRun.GetEndCharacterIndex();
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_ABSTRACT_STYLE_CHARACTER_RUN_H
+#define DALI_TOOLKIT_TEXT_ABSTRACT_STYLE_CHARACTER_RUN_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/public-api/common/type-traits.h>
+#include <dali/public-api/math/vector4.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/character-run.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+/**
+ * @brief Run of characters with the same style.
+ */
+struct AbstractStyleCharacterRun
+{
+ CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
+
+ // Constructors
+
+protected:
+ /**
+ * @brief Constructor.
+ * Default constructor to set the default values
+ */
+ AbstractStyleCharacterRun()
+ : characterRun{}
+ {
+ }
+
+ /**
+ * @brief Constructor.
+ * Default constructor to set the default values
+ *
+ * @param[in] characterRun the character run
+ */
+ AbstractStyleCharacterRun(const CharacterRun& characterRun)
+ : characterRun{characterRun}
+ {
+ }
+
+public:
+ AbstractStyleCharacterRun(const AbstractStyleCharacterRun&) = default;
+
+ AbstractStyleCharacterRun(AbstractStyleCharacterRun&&) noexcept = default;
+
+ // Operators
+
+ AbstractStyleCharacterRun& operator=(const AbstractStyleCharacterRun&) = default;
+
+ AbstractStyleCharacterRun& operator=(AbstractStyleCharacterRun&&) noexcept = default;
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~AbstractStyleCharacterRun() = default;
+
+ //Methods
+
+ /**
+ * @brief Retrive the first index in run.
+ * @return the end character index in run.
+ */
+ CharacterIndex GetStartCharacterIndex() const;
+
+ /**
+ * @brief Retrive the number of characters in the run.
+ * @return the the number of characters in run.
+ */
+ Length GetNumberOfCharacters() const;
+
+ /**
+ * @brief Calculate the end index in run.
+ * @return the end character index in run.
+ */
+ CharacterIndex GetEndCharacterIndex() const;
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+// Allow AbstractStyleCharacterRun to be treated as a POD type
+template<>
+struct TypeTraits<Dali::Toolkit::Text::AbstractStyleCharacterRun> : public Dali::BasicTypes<Dali::Toolkit::Text::AbstractStyleCharacterRun>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_ABSTRACT_STYLE_CHARACTER_RUN_H
#include <dali/public-api/math/vector2.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/text/character-run.h>
+#include <dali-toolkit/internal/text/abstract-style-character-run.h>
#include <dali-toolkit/public-api/text/text-enumerations.h>
namespace Dali
* Bounded-paragraph could contain multi paragraphs that have been breaked by Paragraph Separators or appropriate Newline Functions.
* This will be used to handle information for the attributes of markup tag. Like TextAlign, TextDirection, TextIndent, LineHeight, etc.
*/
-struct BoundedParagraphRun
+struct BoundedParagraphRun : public AbstractStyleCharacterRun
{
/**
* Default constructor to set the default values of bitfields
*/
BoundedParagraphRun()
- : characterRun{},
+ : AbstractStyleCharacterRun(),
horizontalAlignment(Text::HorizontalAlignment::BEGIN),
relativeLineSize(1),
horizontalAlignmentDefined{false},
{
}
- CharacterRun characterRun; ///< The initial character index within the whole text and the number of characters of the run.
Text::HorizontalAlignment::Type horizontalAlignment; ///< The paragraph horizontal alignment. Values "BEGIN" "CENTER" "END".
float relativeLineSize; ///< The relative line height to be used for this paragaraph.
bool horizontalAlignmentDefined : 1; ///< Whether the horizontal alignment is defined.
} // namespace Toolkit
+// Allow BoundedParagraphRun to be treated as a POD type
+template<>
+struct TypeTraits<Dali::Toolkit::Text::BoundedParagraphRun> : public Dali::BasicTypes<Dali::Toolkit::Text::BoundedParagraphRun>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
} // namespace Dali
#endif // DALI_TOOLKIT_TEXT_BOUNDED_PARAGRAPH_RUN_H
*
*/
-// EXTERNAL INCLUDES
-#include <dali/public-api/math/vector4.h>
-
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/text/character-run.h>
+#include <dali-toolkit/internal/text/abstract-style-character-run.h>
namespace Dali
{
/**
* @brief Run of character-spacing characters with same properties.
*/
-struct CharacterSpacingCharacterRun
+struct CharacterSpacingCharacterRun : public AbstractStyleCharacterRun
{
/**
- * Default constructor to set the default values of bitfields
+ * @brief Constructor.
+ * Default constructor to set the default values
*/
CharacterSpacingCharacterRun()
- : characterRun{},
+ : AbstractStyleCharacterRun(),
value{0.f} //The default value is 0.f which does nothing.
{
}
- CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
- float value; /// The spaces between characters in Pixels. A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
+ float value; /// The spaces between characters in Pixels. A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
//TODO: Add unit property to choose between Pixel or Scale (%)
};
} // namespace Toolkit
+// Allow ColorRun to be treated as a POD type
+template<>
+struct TypeTraits<Dali::Toolkit::Text::CharacterSpacingCharacterRun> : public Dali::BasicTypes<Dali::Toolkit::Text::CharacterSpacingCharacterRun>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
} // namespace Dali
#endif // DALI_TOOLKIT_TEXT_CHARACTER_SPACING_CHARACTER_RUN_H
#define DALI_TOOLKIT_TEXT_COLOR_RUN_H
/*
- * 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.
*
*/
-// EXTERNAL INCLUDES
-#include <dali/public-api/math/vector4.h>
-
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/text/character-run.h>
-#include <dali-toolkit/internal/text/glyph-run.h>
+#include <dali-toolkit/internal/text/abstract-style-character-run.h>
namespace Dali
{
/**
* @brief Run of characters with the same color.
*/
-struct ColorRun
+struct ColorRun : public AbstractStyleCharacterRun
{
- CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
- Vector4 color; ///< The color of the characters.
+ /**
+ * @brief Constructor.
+ * Default constructor to set the default values
+ */
+ ColorRun()
+ : AbstractStyleCharacterRun()
+ {
+ }
+ Vector4 color; ///< The color of the characters.
};
} // namespace Text
} // namespace Toolkit
+// Allow ColorRun to be treated as a POD type
+template<>
+struct TypeTraits<Dali::Toolkit::Text::ColorRun> : public Dali::BasicTypes<Dali::Toolkit::Text::ColorRun>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
} // namespace Dali
#endif // DALI_TOOLKIT_TEXT_COLOR_RUN_H
#define DALI_TOOLKIT_TEXT_FONT_DESCRIPTION_RUN_H
/*
- * 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.
#include <dali/devel-api/text-abstraction/font-list.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/text/character-run.h>
+#include <dali-toolkit/internal/text/abstract-style-character-run.h>
#include <dali-toolkit/internal/text/text-definitions.h>
namespace Dali
/**
* @brief Run of characters with the same font.
*/
-struct FontDescriptionRun
+struct FontDescriptionRun : public AbstractStyleCharacterRun
{
/**
* Default constructor to set the default values of bitfields
*/
FontDescriptionRun()
- : characterRun{},
+ : AbstractStyleCharacterRun(),
familyName{nullptr},
familyLength{0u},
weight{FontWeight::NONE},
bool widthDefined,
bool slantDefined,
bool sizeDefined)
- : characterRun{characterRun},
+ : AbstractStyleCharacterRun(characterRun),
familyName{familyName},
familyLength{familyLength},
weight{weight},
{
}
- CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
char* familyName; ///< The font's family name.
Length familyLength; ///< The length of the font's family name.
FontWeight weight; ///< The font's weight.
} // namespace Toolkit
+// Allow FontDescriptionRun to be treated as a POD type
+template<>
+struct TypeTraits<Dali::Toolkit::Text::FontDescriptionRun> : public Dali::BasicTypes<Dali::Toolkit::Text::FontDescriptionRun>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
} // namespace Dali
#endif // DALI_TOOLKIT_TEXT_FONT_DESCRIPTION_RUN_H
--- /dev/null
+/*
+ * Copyright (c) 2021 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.
+ *
+ */
+
+// FILE HEADER
+#include <dali-toolkit/internal/text/line-helper-functions.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+float GetPreOffsetVerticalLineAlignment(const LineRun& line, const DevelText::VerticalLineAlignment::Type& verLineAlign)
+{
+ // Calculate vertical line alignment
+ float offset = 0.0f;
+
+ switch(verLineAlign)
+ {
+ case DevelText::VerticalLineAlignment::TOP:
+ {
+ break;
+ }
+ case DevelText::VerticalLineAlignment::MIDDLE:
+ {
+ offset = line.lineSpacing * 0.5f;
+ break;
+ }
+ case DevelText::VerticalLineAlignment::BOTTOM:
+ {
+ offset = line.lineSpacing;
+ break;
+ }
+ }
+
+ // Apply TOP case when the lineSpacing is less than zero.
+ offset = line.lineSpacing < 0.0f ? 0.0f : offset;
+
+ return offset;
+}
+
+float GetPostOffsetVerticalLineAlignment(const LineRun& line, const DevelText::VerticalLineAlignment::Type& verLineAlign)
+{
+ // Calculate vertical line alignment
+ float offset = 0.0f;
+
+ switch(verLineAlign)
+ {
+ case DevelText::VerticalLineAlignment::TOP:
+ {
+ offset = line.lineSpacing;
+ break;
+ }
+ case DevelText::VerticalLineAlignment::MIDDLE:
+ {
+ offset = line.lineSpacing * 0.5f;
+ break;
+ }
+ case DevelText::VerticalLineAlignment::BOTTOM:
+ {
+ break;
+ }
+ }
+
+ // Apply TOP case when the lineSpacing is less than zero.
+ offset = line.lineSpacing < 0.0f ? line.lineSpacing : offset;
+
+ return offset;
+}
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_LINE_HELPER_FUNCTIONS_H
+#define DALI_TOOLKIT_TEXT_LINE_HELPER_FUNCTIONS_H
+
+/*
+ * Copyright (c) 2021 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/text-enumerations-devel.h>
+#include <dali-toolkit/internal/text/line-run.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+/**
+ * @brief Retrieves the vertical offset to shift text inside line to up by negative value and to down by positive value.
+ * The shifting depends on the vertical line alignment @p verLineAlign and lineSpacing when the lineSpacing is poistive.
+ * When the lineSpacing is negative then ignore @p verLineAlign
+ * @param[in] line the line.
+ * @param[in] line the line.
+ *
+ * @return The vertical offset before text.
+ */
+float GetPreOffsetVerticalLineAlignment(const LineRun& line, const Dali::Toolkit::DevelText::VerticalLineAlignment::Type& verLineAlign);
+
+/**
+ * @brief Retrieves the vertical offset to shift the next line to up by negative value and to down by positive value.
+ * The shifting depends on the vertical line alignment @p verLineAlign and lineSpacing when the lineSpacing is poistive.
+ * When the lineSpacing is negative then ignore @p verLineAlign
+ * @param[in] line the line.
+ * @param[in] line the line.
+ *
+ * @return The vertical offset after text.
+ */
+float GetPostOffsetVerticalLineAlignment(const LineRun& line, const Dali::Toolkit::DevelText::VerticalLineAlignment::Type& verLineAlign);
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_LINE_HELPER_FUNCTIONS_H
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
#include <dali-toolkit/internal/text/glyph-metrics-helper.h>
+#include <dali-toolkit/internal/text/line-helper-functions.h>
#include <dali-toolkit/internal/text/rendering/styles/character-spacing-helper-functions.h>
#include <dali-toolkit/internal/text/rendering/styles/strikethrough-helper-functions.h>
#include <dali-toolkit/internal/text/rendering/styles/underline-helper-functions.h>
const Vector4* const backgroundColorsBuffer = model->GetBackgroundColors();
const ColorIndex* const backgroundColorIndicesBuffer = model->GetBackgroundColorIndices();
+ const DevelText::VerticalLineAlignment::Type verLineAlign = model->GetVerticalLineAlignment();
+
// Create and initialize the pixel buffer.
GlyphData glyphData;
glyphData.verticalOffset = verticalOffset;
glyphData.horizontalOffset += horizontalOffset;
// Increases the vertical offset with the line's ascender.
- glyphData.verticalOffset += static_cast<int32_t>(line.ascender);
-
- // Include line spacing after first line
- if(lineIndex > 0u)
- {
- glyphData.verticalOffset += static_cast<int32_t>(line.lineSpacing);
- }
+ glyphData.verticalOffset += static_cast<int32_t>(line.ascender + GetPreOffsetVerticalLineAlignment(line, verLineAlign));
float left = bufferWidth;
float right = 0.0f;
}
// Increases the vertical offset with the line's descender.
- glyphData.verticalOffset += static_cast<int32_t>(-line.descender);
+ glyphData.verticalOffset += static_cast<int32_t>(-line.descender + GetPostOffsetVerticalLineAlignment(line, verLineAlign));
}
return glyphData.bitmapBuffer;
}
}
- // Calculate vertical line alignment
- switch(mModel->GetVerticalLineAlignment())
- {
- case DevelText::VerticalLineAlignment::TOP:
- {
- break;
- }
- case DevelText::VerticalLineAlignment::MIDDLE:
- {
- const auto& line = *mModel->GetLines();
- penY -= line.descender;
- penY += static_cast<int32_t>(line.lineSpacing * 0.5f + line.descender);
- break;
- }
- case DevelText::VerticalLineAlignment::BOTTOM:
- {
- const auto& line = *mModel->GetLines();
- const auto lineHeight = line.ascender + (-line.descender) + line.lineSpacing;
- penY += static_cast<int32_t>(lineHeight - (line.ascender - line.descender));
- break;
- }
- }
-
// Generate the image buffers of the text for each different style first,
// then combine all of them together as one final image buffer. We try to
// do all of these in CPU only, so that once the final texture is generated,
const Vector<CharacterIndex>& glyphToCharacterMap = mModel->GetGlyphsToCharacters();
const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin();
+ const DevelText::VerticalLineAlignment::Type verLineAlign = mModel->GetVerticalLineAlignment();
+
// Traverses the lines of the text.
for(LineIndex lineIndex = 0u; lineIndex < modelNumberOfLines; ++lineIndex)
{
glyphData.horizontalOffset += horizontalOffset;
// Increases the vertical offset with the line's ascender.
- glyphData.verticalOffset += static_cast<int32_t>(line.ascender);
+ glyphData.verticalOffset += static_cast<int32_t>(line.ascender + GetPreOffsetVerticalLineAlignment(line, verLineAlign));
// Retrieves the glyph's outline width
float outlineWidth = static_cast<float>(mModel->GetOutlineWidth());
}
// Increases the vertical offset with the line's descender & line spacing.
- glyphData.verticalOffset += static_cast<int32_t>(-line.descender + line.lineSpacing);
+ glyphData.verticalOffset += static_cast<int32_t>(-line.descender + GetPostOffsetVerticalLineAlignment(line, verLineAlign));
}
return glyphData.bitmapBuffer;
#include <dali/public-api/math/vector4.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/text/character-run.h>
+#include <dali-toolkit/internal/text/abstract-style-character-run.h>
#include <dali-toolkit/internal/text/strikethrough-style-properties.h>
namespace Dali
/**
* @brief Run of strikethrough characters with same properties.
*/
-struct StrikethroughCharacterRun
+struct StrikethroughCharacterRun : public AbstractStyleCharacterRun
{
/**
* Default constructor to set the default values of bitfields
*/
StrikethroughCharacterRun()
- : characterRun{},
+ : AbstractStyleCharacterRun(),
properties{}
{
}
- CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
- StrikethroughStyleProperties properties; /// The properties of strikethrough style
+ StrikethroughStyleProperties properties; /// The properties of strikethrough style
};
} // namespace Text
} // namespace Toolkit
+// Allow StrikethroughCharacterRun to be treated as a POD type
+template<>
+struct TypeTraits<Dali::Toolkit::Text::StrikethroughCharacterRun> : public Dali::BasicTypes<Dali::Toolkit::Text::StrikethroughCharacterRun>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
} // namespace Dali
#endif // DALI_TOOLKIT_TEXT_STRIKETHROUGH_CHARACTER_RUN_H
#include <dali/public-api/math/vector4.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/text/character-run.h>
+#include <dali-toolkit/internal/text/abstract-style-character-run.h>
#include <dali-toolkit/internal/text/underline-style-properties.h>
namespace Dali
/**
* @brief Run of underlined characters with same properties.
*/
-struct UnderlinedCharacterRun
+struct UnderlinedCharacterRun : public AbstractStyleCharacterRun
{
/**
* Default constructor to set the default values of bitfields
*/
UnderlinedCharacterRun()
- : characterRun{},
+ : AbstractStyleCharacterRun(),
properties{}
{
}
- CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
- UnderlineStyleProperties properties; /// The properties of underline style
+ UnderlineStyleProperties properties; /// The properties of underline style
};
} // namespace Text
} // namespace Toolkit
+// Allow UnderlinedCharacterRun to be treated as a POD type
+template<>
+struct TypeTraits<Dali::Toolkit::Text::UnderlinedCharacterRun> : public Dali::BasicTypes<Dali::Toolkit::Text::UnderlinedCharacterRun>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
} // namespace Dali
#endif // DALI_TOOLKIT_TEXT_UNDERLINED_CHARACTER_RUN_H