1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_FONT_SPAN_IMPL_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_FONT_SPAN_IMPL_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali-toolkit/devel-api/text/spans/font-span.h>
25 #include <dali-toolkit/internal/text/logical-model-impl.h>
26 #include <dali-toolkit/internal/text/spannable/spans/base-span-impl.h>
27 #include <dali-toolkit/internal/text/text-definitions.h>
28 #include <dali/public-api/math/vector4.h>
39 using FontSpanPtr = IntrusivePtr<FontSpan>;
42 * @copydoc Dali::Toolkit::Text::FontSpan
44 class FontSpan : public BaseSpan
48 * @brief Creates a new FontSpan object.
50 static Dali::Toolkit::Text::FontSpan New(const std::string& familyName,
51 const float& sizeInPoints,
52 const Dali::TextAbstraction::FontWeight::Type& weight,
53 const Dali::TextAbstraction::FontWidth::Type& width,
54 const Dali::TextAbstraction::FontSlant::Type& slant);
61 FontSpan(const FontSpan&) = delete; ///< Deleted copy constructor
62 FontSpan(FontSpan&&) = delete; ///< Deleted move constructor
63 FontSpan& operator=(const FontSpan&) = delete; ///< Deleted copy assignment operator
64 FontSpan& operator=(FontSpan&&) = delete; ///< Deleted move assignment operator
69 * A reference counted object may only be deleted by calling Unreference()
76 * @copydoc Dali::Toolkit::Text::FontSpan::GetFamilyName()
78 const std::string GetFamilyName() const;
81 * @copydoc Dali::Toolkit::Text::FontSpan::IsFamilyNameDefined()
83 bool IsFamilyNameDefined() const;
86 * @copydoc Dali::Toolkit::Text::FontSpan::GetWeight()
88 const Dali::TextAbstraction::FontWeight::Type GetWeight() const;
91 * @copydoc Dali::Toolkit::Text::FontSpan::IsWeightDefined()
93 bool IsWeightDefined() const;
96 * @copydoc Dali::Toolkit::Text::FontSpan::GetWidth()
98 const Dali::TextAbstraction::FontWidth::Type GetWidth() const;
101 * @copydoc Dali::Toolkit::Text::FontSpan::IsWidthDefined()
103 bool IsWidthDefined() const;
106 * @copydoc Dali::Toolkit::Text::FontSpan::GetSlant()
108 const Dali::TextAbstraction::FontSlant::Type GetSlant() const;
111 * @copydoc Dali::Toolkit::Text::FontSpan::IsSlantDefined()
113 bool IsSlantDefined() const;
116 * @copydoc Dali::Toolkit::Text::FontSpan::GetSize()
118 const float GetSize() const;
121 * @copydoc Dali::Toolkit::Text::FontSpan::IsSizeDefined()
123 bool IsSizeDefined() const;
125 public: //Methods. Not intended for application developers
127 * @brief Set the font family name.
129 * @param[in] familyName The font family name.
131 void SetFamilyName(const std::string& familyName);
134 * @brief Set the font weight.
136 * @param[in] weight The font weight.
138 void SetWeight(const Dali::TextAbstraction::FontWeight::Type& weight);
141 * @brief Set the font width.
143 * @param[in] width The font width.
145 void SetWidth(const Dali::TextAbstraction::FontWidth::Type& width);
148 * @brief Set the font slant.
150 * @param[in] slant The font slant.
152 void SetSlant(const Dali::TextAbstraction::FontSlant::Type& slant);
155 * @brief Set the font size.
157 * @param[in] size The font size.
159 void SetSize(const float& size);
162 void InitializeFontRun(FontDescriptionRun& fontRun) const;
163 void ProcessFontFamily(FontDescriptionRun& fontRun) const;
164 void ProcessFontSize(FontDescriptionRun& fontRun) const;
165 void ProcessFontWeight(FontDescriptionRun& fontRun) const;
166 void ProcessFontWidth(FontDescriptionRun& fontRun) const;
167 void ProcessFontSlant(FontDescriptionRun& fontRun) const;
169 public: //Methods for internal only
171 * @copydoc Dali::Toolkit::Text::BaseSpan::CreateStyleCharacterRun
173 void CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const override;
177 std::unique_ptr<Impl> mImpl{nullptr};
181 } // namespace Internal
183 // Helpers for public-api forwarding methods
185 inline Internal::FontSpan& GetImplementation(Dali::Toolkit::Text::FontSpan& fontSpan)
187 DALI_ASSERT_ALWAYS(fontSpan && "fontSpan handle is empty");
189 BaseObject& object = fontSpan.GetBaseObject();
191 return static_cast<Internal::FontSpan&>(object);
194 inline const Internal::FontSpan& GetImplementation(const Dali::Toolkit::Text::FontSpan& fontSpan)
196 DALI_ASSERT_ALWAYS(fontSpan && "fontSpan handle is empty");
198 const BaseObject& object = fontSpan.GetBaseObject();
200 return static_cast<const Internal::FontSpan&>(object);
205 } // namespace Toolkit
209 #endif // DALI_TOOLKIT_INTERNAL_TEXT_FONT_SPAN_IMPL_H