{
return 0;
}
- FontId GetFontId(const FontDescription& fontDescription, PointSize26Dot6 pointSize, FaceIndex faceIndex)
+ FontId GetFontId(const FontDescription& fontDescription, PointSize26Dot6 pointSize, FaceIndex faceIndex, Property::Map* variationsMapPtr)
{
return 0;
}
}
}
- Length Shape(TextAbstraction::FontClient& fontClient, unsigned int const* text, unsigned int numChars, unsigned int fontId, Script script)
+ Length Shape(TextAbstraction::FontClient& fontClient, unsigned int const* text, unsigned int numChars, unsigned int fontId, Script script, Property::Map* variationsMapPtr)
{
mText = new unsigned char[numChars];
mNumChars = numChars;
FontId FontClient::GetFontId(const FontDescription& fontDescription,
PointSize26Dot6 pointSize,
- FaceIndex faceIndex)
+ FaceIndex faceIndex,
+ Property::Map* variationsMapPtr)
{
return GetImplementation(*this).GetFontId(fontDescription,
pointSize,
- faceIndex);
+ faceIndex,
+ variationsMapPtr);
}
bool FontClient::IsScalable(const FontPath& path)
GetImplementation(*this).GetGlyphs(glyphStore, mappingTable);
}
-Length Shaping::Shape(TextAbstraction::FontClient& fontClient, unsigned int const* text, unsigned int numChars, unsigned int fontId, Script script)
+Length Shaping::Shape(TextAbstraction::FontClient& fontClient, unsigned int const* text, unsigned int numChars, unsigned int fontId, Script script, Property::Map* variationsMapPtr)
{
- return GetImplementation(*this).Shape(fontClient, text, numChars, fontId, script);
+ return GetImplementation(*this).Shape(fontClient, text, numChars, fontId, script, variationsMapPtr);
}
} // namespace TextAbstraction
const char* const PROPERTY_NAME_REMOVE_FRONT_INSET = "removeFrontInset";
const char* const PROPERTY_NAME_REMOVE_BACK_INSET = "removeBackInset";
+const char* const PROPERTY_NAME_FONT_VARIATIONS = "fontVariations";
const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextEditor::Property::SELECTION_POPUP_STYLE);
DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_REMOVE_FRONT_INSET) == DevelTextEditor::Property::REMOVE_FRONT_INSET);
DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_REMOVE_BACK_INSET) == DevelTextEditor::Property::REMOVE_BACK_INSET);
+ DALI_TEST_CHECK(editor.GetPropertyIndex(PROPERTY_NAME_FONT_VARIATIONS) == DevelTextEditor::Property::FONT_VARIATIONS);
END_TEST;
}
editor.SetProperty(DevelTextEditor::Property::REMOVE_BACK_INSET, true);
DALI_TEST_CHECK(editor.GetProperty<bool>(DevelTextEditor::Property::REMOVE_BACK_INSET));
+ // Check font variations property
+ Property::Map fontVariationsMapSet;
+ Property::Map fontVariationsMapGet;
+
+ fontVariationsMapSet.Insert("wght", 400.f);
+ fontVariationsMapSet.Insert("wdth", 100.f);
+ fontVariationsMapSet.Insert("slnt", 0.f);
+ editor.SetProperty(DevelTextEditor::Property::FONT_VARIATIONS, fontVariationsMapSet);
+
+ fontVariationsMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::FONT_VARIATIONS);
+ DALI_TEST_EQUALS(fontVariationsMapSet.Count(), fontVariationsMapGet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(fontVariationsMapSet, fontVariationsMapGet), true, TEST_LOCATION);
+
+ // Check font variations ignore invalid values
+ Property::Map invalidFontVariationsMapSet;
+ Property::Map invalidFontVariationsMapGet;
+
+ invalidFontVariationsMapSet.Insert("abcde", 0.f); // invalid because key length is not 4.
+ invalidFontVariationsMapSet.Insert("abc", 0.f); // invalid because key length is not 4.
+ invalidFontVariationsMapSet.Insert("abcd", "str"); // invalid because value is not float.
+ editor.SetProperty(DevelTextEditor::Property::FONT_VARIATIONS, invalidFontVariationsMapSet);
+
+ invalidFontVariationsMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::FONT_VARIATIONS);
+ DALI_TEST_EQUALS(invalidFontVariationsMapGet.Count(), 0u, TEST_LOCATION);
+
application.SendNotification();
application.Render();
END_TEST;
}
+
int utcDaliTextEditorRemoveBackInset(void)
{
ToolkitTestApplication application;
END_TEST;
}
+
+int utcDaliTextEditorFontVariationsRegister(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorFontVariationsRegister");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK(editor);
+
+ application.GetScene().Add(editor);
+ application.SendNotification();
+ application.Render();
+
+ // Invalid key check
+ std::string INVALID_KEY = "invalid";
+ auto invalidFontVariationsIndex = DevelTextEditor::RegisterFontVariationProperty(editor, INVALID_KEY.data());
+ DALI_TEST_CHECK(invalidFontVariationsIndex == Property::INVALID_INDEX);
+
+ application.GetScene().Add(editor);
+ application.SendNotification();
+ application.Render();
+
+ std::string WGHT_KEY = "wght";
+ const float WGHT_VALUE = 100.f;
+ const float WGHT_VALUE_END = 900.f;
+
+ // Check with no previous variations.
+ auto fontVariationsIndex = DevelTextEditor::RegisterFontVariationProperty(editor, WGHT_KEY.data());
+ editor.SetProperty(fontVariationsIndex, WGHT_VALUE);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(editor.GetProperty(fontVariationsIndex).Get<float>() == WGHT_VALUE);
+
+ Property::Map fontVariationsGet;
+ fontVariationsGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::FONT_VARIATIONS);
+
+ DALI_TEST_CHECK(fontVariationsGet.Count() == 1u);
+
+ const KeyValuePair& keyvalue = fontVariationsGet.GetKeyValue(0);
+
+ std::string key = "";
+ if(keyvalue.first.type == Property::Key::STRING)
+ {
+ key = keyvalue.first.stringKey;
+ }
+
+ float value = keyvalue.second.Get<float>();
+
+ DALI_TEST_CHECK(key == WGHT_KEY);
+ DALI_TEST_CHECK(value = WGHT_VALUE);
+
+ application.SendNotification();
+ application.Render();
+
+ // Animation test
+
+ Animation anim = Animation::New(1);
+ anim.AnimateTo(Property(editor, fontVariationsIndex), WGHT_VALUE_END);
+ anim.Play();
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
\ No newline at end of file
const char* const PROPERTY_NAME_REMOVE_FRONT_INSET = "removeFrontInset";
const char* const PROPERTY_NAME_REMOVE_BACK_INSET = "removeBackInset";
+const char* const PROPERTY_NAME_FONT_VARIATIONS = "fontVariations";
const Vector4 PLACEHOLDER_TEXT_COLOR(0.8f, 0.8f, 0.8f, 0.8f);
const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); // The text highlight color.
DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_SELECTION_POPUP_STYLE) == DevelTextField::Property::SELECTION_POPUP_STYLE);
DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_REMOVE_FRONT_INSET) == DevelTextField::Property::REMOVE_FRONT_INSET);
DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_REMOVE_BACK_INSET) == DevelTextField::Property::REMOVE_BACK_INSET);
+ DALI_TEST_CHECK(field.GetPropertyIndex(PROPERTY_NAME_FONT_VARIATIONS) == DevelTextField::Property::FONT_VARIATIONS);
END_TEST;
}
application.SendNotification();
application.Render();
+ // Check font variations property
+ Property::Map fontVariationsMapSet;
+ Property::Map fontVariationsMapGet;
+
+ fontVariationsMapSet.Insert("wght", 400.f);
+ fontVariationsMapSet.Insert("wdth", 100.f);
+ fontVariationsMapSet.Insert("slnt", 0.f);
+ field.SetProperty(DevelTextField::Property::FONT_VARIATIONS, fontVariationsMapSet);
+
+ fontVariationsMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::FONT_VARIATIONS);
+ DALI_TEST_EQUALS(fontVariationsMapSet.Count(), fontVariationsMapGet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(fontVariationsMapSet, fontVariationsMapGet), true, TEST_LOCATION);
+
+ // Check font variations ignore invalid values
+ Property::Map invalidFontVariationsMapSet;
+ Property::Map invalidFontVariationsMapGet;
+
+ invalidFontVariationsMapSet.Insert("abcde", 0.f); // invalid because key length is not 4.
+ invalidFontVariationsMapSet.Insert("abc", 0.f); // invalid because key length is not 4.
+ invalidFontVariationsMapSet.Insert("abcd", "str"); // invalid because value is not float.
+ field.SetProperty(DevelTextField::Property::FONT_VARIATIONS, invalidFontVariationsMapSet);
+
+ invalidFontVariationsMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::FONT_VARIATIONS);
+ DALI_TEST_EQUALS(invalidFontVariationsMapGet.Count(), 0u, TEST_LOCATION);
END_TEST;
}
END_TEST;
}
+
+int utcDaliTextFieldFontVariationsRegister(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldFontVariationsRegister");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ application.GetScene().Add(field);
+ application.SendNotification();
+ application.Render();
+
+ // Invalid key check
+ std::string INVALID_KEY = "invalid";
+ auto invalidFontVariationsIndex = DevelTextField::RegisterFontVariationProperty(field, INVALID_KEY.data());
+ DALI_TEST_CHECK(invalidFontVariationsIndex == Property::INVALID_INDEX);
+
+ application.GetScene().Add(field);
+ application.SendNotification();
+ application.Render();
+
+ std::string WGHT_KEY = "wght";
+ const float WGHT_VALUE = 100.f;
+ const float WGHT_VALUE_END = 900.f;
+
+ // Check with no previous variations.
+ auto fontVariationsIndex = DevelTextField::RegisterFontVariationProperty(field, WGHT_KEY.data());
+ field.SetProperty(fontVariationsIndex, WGHT_VALUE);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(field.GetProperty(fontVariationsIndex).Get<float>() == WGHT_VALUE);
+
+ Property::Map fontVariationsGet;
+ fontVariationsGet = field.GetProperty<Property::Map>(DevelTextField::Property::FONT_VARIATIONS);
+
+ DALI_TEST_CHECK(fontVariationsGet.Count() == 1u);
+
+ const KeyValuePair& keyvalue = fontVariationsGet.GetKeyValue(0);
+
+ std::string key = "";
+ if(keyvalue.first.type == Property::Key::STRING)
+ {
+ key = keyvalue.first.stringKey;
+ }
+
+ float value = keyvalue.second.Get<float>();
+
+ DALI_TEST_CHECK(key == WGHT_KEY);
+ DALI_TEST_CHECK(value = WGHT_VALUE);
+
+ application.SendNotification();
+ application.Render();
+
+ // Animation test
+
+ Animation anim = Animation::New(1);
+ anim.AnimateTo(Property(field, fontVariationsIndex), WGHT_VALUE_END);
+ anim.Play();
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
\ No newline at end of file
const char* const PROPERTY_NAME_MANUAL_RENDERED = "manualRendered";
const char* const PROPERTY_NAME_ASYNC_LINE_COUNT = "asyncLineCount";
const char* const PROPERTY_NAME_ELLIPSIS_MODE = "ellipsisMode";
+const char* const PROPERTY_NAME_FONT_VARIATIONS = "fontVariations";
const std::string DEFAULT_FONT_DIR("/resources/fonts");
const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_MANUAL_RENDERED) == DevelTextLabel::Property::MANUAL_RENDERED);
DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ASYNC_LINE_COUNT) == DevelTextLabel::Property::ASYNC_LINE_COUNT);
DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS_MODE) == DevelTextLabel::Property::ELLIPSIS_MODE);
+ DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_FONT_VARIATIONS) == DevelTextLabel::Property::FONT_VARIATIONS);
END_TEST;
}
label.SetProperty(DevelTextLabel::Property::ELLIPSIS_MODE, Toolkit::DevelText::Ellipsize::AUTO_SCROLL);
DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_MODE), static_cast<int>(Toolkit::DevelText::Ellipsize::AUTO_SCROLL), TEST_LOCATION);
+ // Check font variations property
+ Property::Map fontVariationsMapSet;
+ Property::Map fontVariationsMapGet;
+
+ fontVariationsMapSet.Insert("wght", 400.f);
+ fontVariationsMapSet.Insert("wdth", 100.f);
+ fontVariationsMapSet.Insert("slnt", 0.f);
+ label.SetProperty(DevelTextLabel::Property::FONT_VARIATIONS, fontVariationsMapSet);
+
+ fontVariationsMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::FONT_VARIATIONS);
+ DALI_TEST_EQUALS(fontVariationsMapSet.Count(), fontVariationsMapGet.Count(), TEST_LOCATION);
+ DALI_TEST_EQUALS(DaliTestCheckMaps(fontVariationsMapSet, fontVariationsMapGet), true, TEST_LOCATION);
+
+ // Check font variations ignore invalid values
+ Property::Map invalidFontVariationsMapSet;
+ Property::Map invalidFontVariationsMapGet;
+
+ invalidFontVariationsMapSet.Insert("abcde", 0.f); // invalid because key length is not 4.
+ invalidFontVariationsMapSet.Insert("abc", 0.f); // invalid because key length is not 4.
+ invalidFontVariationsMapSet.Insert("abcd", "str"); // invalid because value is not float.
+ label.SetProperty(DevelTextLabel::Property::FONT_VARIATIONS, invalidFontVariationsMapSet);
+
+ invalidFontVariationsMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::FONT_VARIATIONS);
+ DALI_TEST_EQUALS(invalidFontVariationsMapGet.Count(), 0u, TEST_LOCATION);
+
application.SendNotification();
application.Render();
DevelTextLabel::SetRemoveBackInset(label, true);
DALI_TEST_CHECK(DevelTextLabel::IsRemoveBackInset(label));
+ END_TEST;
+}
+
+int utcDaliTextLabelFontVariationsRegister(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextLabelFontVariationsRegister");
+
+ TextLabel label = TextLabel::New();
+ DALI_TEST_CHECK(label);
+
+ application.GetScene().Add(label);
+ application.SendNotification();
+ application.Render();
+
+ // Invalid key check
+ std::string INVALID_KEY = "invalid";
+ auto invalidFontVariationsIndex = DevelTextLabel::RegisterFontVariationProperty(label, INVALID_KEY.data());
+ DALI_TEST_CHECK(invalidFontVariationsIndex == Property::INVALID_INDEX);
+
+ application.GetScene().Add(label);
+ application.SendNotification();
+ application.Render();
+
+ std::string WGHT_KEY = "wght";
+ const float WGHT_VALUE = 100.f;
+ const float WGHT_VALUE_END = 900.f;
+
+ // Check with no previous variations.
+ auto fontVariationsIndex = DevelTextLabel::RegisterFontVariationProperty(label, WGHT_KEY.data());
+ label.SetProperty(fontVariationsIndex, WGHT_VALUE);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(label.GetProperty(fontVariationsIndex).Get<float>() == WGHT_VALUE);
+
+ Property::Map fontVariationsGet;
+ fontVariationsGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::FONT_VARIATIONS);
+
+ DALI_TEST_CHECK(fontVariationsGet.Count() == 1u);
+
+ const KeyValuePair& keyvalue = fontVariationsGet.GetKeyValue(0);
+
+ std::string key = "";
+ if(keyvalue.first.type == Property::Key::STRING)
+ {
+ key = keyvalue.first.stringKey;
+ }
+
+ float value = keyvalue.second.Get<float>();
+
+ DALI_TEST_CHECK(key == WGHT_KEY);
+ DALI_TEST_CHECK(value = WGHT_VALUE);
+
+ application.SendNotification();
+ application.Render();
+
+ // Animation test
+
+ Animation anim = Animation::New(1);
+ anim.AnimateTo(Property(label, fontVariationsIndex), WGHT_VALUE_END);
+ anim.Play();
+
+ application.SendNotification();
+ application.Render();
+
END_TEST;
}
\ No newline at end of file
return GetImpl(textEditor).IsRemoveBackInset();
}
+Dali::Property::Index RegisterFontVariationProperty(TextEditor textEditor, std::string tag)
+{
+ return GetImpl(textEditor).RegisterFontVariationProperty(tag);
+}
+
} // namespace DevelTextEditor
} // namespace Toolkit
*/
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/input-method-context.h>
+#include <dali/public-api/object/property.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/text-controls/input-filter-properties.h>
* @details Name "removeBackInset", type Property::BOOLEAN.
*/
REMOVE_BACK_INSET,
+
+ /**
+ * @brief Enables customization of fonts with variations such as weight and slant.
+ * @details Name "fontVariations", type Property::MAP.
+ * @note This property can be used only when using variable fonts.
+ */
+ FONT_VARIATIONS,
};
} // namespace Property
*/
DALI_TOOLKIT_API bool IsRemoveBackInset(TextEditor textEditor);
+/**
+ * @brief Registers a new font variation property based on the provided tag.
+ *
+ * @param[in] textEditor The instance of TextEditor.
+ * @param[in] tag A 4-character string representing the variation property tag.
+ * @return The index of the registered variation property. Property::INVALID_INDEX if failed.
+ */
+DALI_TOOLKIT_API Dali::Property::Index RegisterFontVariationProperty(TextEditor textEditor, std::string tag);
+
} // namespace DevelTextEditor
return GetImpl(textField).IsRemoveBackInset();
}
+Dali::Property::Index RegisterFontVariationProperty(TextField textField, std::string tag)
+{
+ return GetImpl(textField).RegisterFontVariationProperty(tag);
+}
+
} // namespace DevelTextField
} // namespace Toolkit
*/
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/input-method-context.h>
+#include <dali/public-api/object/property.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/text-controls/input-filter-properties.h>
* @details Name "removeBackInset", type Property::BOOLEAN.
*/
REMOVE_BACK_INSET,
+
+ /**
+ * @brief Enables customization of fonts with variations such as weight and slant.
+ * @details Name "fontVariations", type Property::MAP.
+ * @note This property can be used only when using variable fonts.
+ */
+ FONT_VARIATIONS,
};
} // namespace Property
*/
DALI_TOOLKIT_API bool IsRemoveBackInset(TextField textField);
+/**
+ * @brief Registers a new font variation property based on the provided tag.
+ *
+ * @param[in] textField The instance of TextField.
+ * @param[in] tag A 4-character string representing the variation property tag.
+ * @return The index of the registered variation property. Property::INVALID_INDEX if failed.
+ */
+DALI_TOOLKIT_API Dali::Property::Index RegisterFontVariationProperty(TextField textField, std::string tag);
+
} // namespace DevelTextField
} // namespace Toolkit
return GetImpl(textLabel).GetLineCount(width);
}
+Dali::Property::Index RegisterFontVariationProperty(TextLabel textLabel, std::string tag)
+{
+ return GetImpl(textLabel).RegisterFontVariationProperty(tag);
+}
+
} // namespace DevelTextLabel
} // namespace Toolkit
// EXTERNAL INCLUDES
#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/object/property.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
* @note This property is read-only.
*/
IS_SCROLLING,
+
+ /**
+ * @brief Enables customization of fonts with variations such as weight and slant.
+ * @details Name "fontVariations", type Property::MAP.
+ * @note This property can be used only when using variable fonts.
+ */
+ FONT_VARIATIONS,
};
} // namespace Property
*/
DALI_TOOLKIT_API int GetLineCount(TextLabel textLabel, float width);
+/**
+ * @brief Registers a new font variation property based on the provided tag.
+ *
+ * @param[in] textLabel The instance of TextLabel.
+ * @param[in] tag A 4-character string representing the variation property tag.
+ * @return The index of the registered variation property. Property::INVALID_INDEX if failed.
+ */
+DALI_TOOLKIT_API Dali::Property::Index RegisterFontVariationProperty(TextLabel textLabel, std::string tag);
+
/**
* @brief Anchor clicked signal type.
*
DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "selectionPopupStyle", MAP, SELECTION_POPUP_STYLE )
DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "removeFrontInset", BOOLEAN, REMOVE_FRONT_INSET )
DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "removeBackInset", BOOLEAN, REMOVE_BACK_INSET )
+DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "fontVariations", MAP, FONT_VARIATIONS )
DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED )
}
default:
{
- Control::OnPropertySet(index, propertyValue); // up call to control for non-handled properties
+ if(Self().DoesCustomPropertyExist(index) && mVariationIndexMap.find(index) != mVariationIndexMap.end())
+ {
+ std::string tag = mVariationIndexMap[index];
+ float value = propertyValue.Get<float>();
+
+ Property::Map map;
+ mController->GetVariationsMap(map);
+ map[tag.data()] = value;
+
+ mController->SetVariationsMap(map);
+ }
+ else
+ {
+ Control::OnPropertySet(index, propertyValue); // up call to control for non-handled properties
+ }
break;
}
}
return mController->IsRemoveBackInset();
}
+Dali::Property::Index TextEditor::RegisterFontVariationProperty(std::string tag)
+{
+ if(tag.length() != 4) // Variable tag must be 4-length string.
+ {
+ DALI_LOG_ERROR("Font Variation Register Failed. The length of tag is not 4.\n");
+ return Property::INVALID_INDEX;
+ }
+
+ Actor self = Self();
+
+ Property::Map variationsMap;
+ mController->GetVariationsMap(variationsMap);
+
+ float variationValue = 0.f;
+ auto tagPtr = variationsMap.Find(tag);
+
+ if(tagPtr)
+ {
+ variationValue = tagPtr->Get<float>();
+ }
+
+ Dali::Property::Index index = self.RegisterProperty(tag.data(), variationValue);
+ if(mVariationIndexMap.find(index) == mVariationIndexMap.end())
+ {
+ PropertyNotification customFontVariationNotification = self.AddPropertyNotification(index, StepCondition(1.0f));
+ // TODO: Make step value customizable by user.
+ customFontVariationNotification.NotifySignal().Connect(this, &TextEditor::OnVariationPropertyNotify);
+
+ mVariationIndexMap[index] = tag;
+ // TODO: Make UnregisterProperty() to remove tag from mVariationIndexMap.
+ }
+
+ return index;
+}
+
+void TextEditor::OnVariationPropertyNotify(PropertyNotification& source)
+{
+ Property::Map map;
+ mController->GetVariationsMap(map);
+
+ for(auto &[index, tag] : mVariationIndexMap)
+ {
+ if(Self().DoesCustomPropertyExist(index))
+ {
+ float value = Self().GetCurrentProperty(index).Get<float>();
+ map[tag.data()] = std::round(value);
+ }
+ }
+
+ // Full Variation Update.
+ mController->SetVariationsMap(map);
+}
+
TextEditor::TextEditor(ControlBehaviour additionalBehaviour)
: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT | additionalBehaviour)),
mAnimationPeriod(0.0f, 0.0f),
*/
bool IsRemoveBackInset() const;
+ /**
+ * @brief Registers a new font variation property based on the provided tag.
+ *
+ * @param[in] tag A 4-character string representing the variation property tag.
+ * @return The index of the registered variation property. Property::INVALID_INDEX if failed.
+ */
+ Dali::Property::Index RegisterFontVariationProperty(std::string tag);
+
private: // Implementation
/**
* @copydoc Dali::Toolkit::Text::Controller::(InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent)
// Needed to synchronize TextAnchor actors with Anchor objects in text's logical model
void OnAccessibilityStatusChanged();
+ /**
+ * @brief Notifies when the font variation property changes to specific value.
+ */
+ void OnVariationPropertyNotify(PropertyNotification& source);
+
private: // Data
// Signals
Toolkit::TextEditor::TextChangedSignalType mTextChangedSignal;
Toolkit::DevelTextEditor::SelectionClearedSignalType mSelectionClearedSignal;
Toolkit::DevelTextEditor::SelectionStartedSignalType mSelectionStartedSignal;
+ // for Font Variations
+ std::map<Dali::Property::Index, std::string> mVariationIndexMap; // Stores [CustomPropertyIndex, tag].
+
InputMethodContext mInputMethodContext;
Text::ControllerPtr mController;
Text::RendererPtr mRenderer;
impl.mController->SetRemoveBackInset(remove);
break;
}
+ case Toolkit::DevelTextEditor::Property::FONT_VARIATIONS:
+ {
+ const Property::Map variationsMap = value.Get<Property::Map>();
+ impl.mController->SetVariationsMap(variationsMap);
+
+ impl.RequestTextRelayout();
+ break;
+ }
}
}
value = impl.mController->IsRemoveBackInset();
break;
}
+ case Toolkit::DevelTextEditor::Property::FONT_VARIATIONS:
+ {
+ Property::Map variationsMap;
+ impl.mController->GetVariationsMap(variationsMap);
+
+ value = variationsMap;
+ break;
+ }
} //switch
return value;
}
DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionPopupStyle", MAP, SELECTION_POPUP_STYLE )
DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "removeFrontInset", BOOLEAN, REMOVE_FRONT_INSET )
DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "removeBackInset", BOOLEAN, REMOVE_BACK_INSET )
+DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "fontVariations", MAP, FONT_VARIATIONS )
DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
}
default:
{
- Control::OnPropertySet(index, propertyValue); // up call to control for non-handled properties
+ if(Self().DoesCustomPropertyExist(index) && mVariationIndexMap.find(index) != mVariationIndexMap.end())
+ {
+ std::string tag = mVariationIndexMap[index];
+ float value = propertyValue.Get<float>();
+
+ Property::Map map;
+ mController->GetVariationsMap(map);
+ map[tag.data()] = value;
+
+ mController->SetVariationsMap(map);
+ }
+ else
+ {
+ Control::OnPropertySet(index, propertyValue); // up call to control for non-handled properties
+ }
break;
}
}
return mController->IsRemoveBackInset();
}
+Dali::Property::Index TextField::RegisterFontVariationProperty(std::string tag)
+{
+ if(tag.length() != 4) // Variable tag must be 4-length string.
+ {
+ DALI_LOG_ERROR("Font Variation Register Failed. The length of tag is not 4.\n");
+ return Property::INVALID_INDEX;
+ }
+
+ Actor self = Self();
+
+ Property::Map variationsMap;
+ mController->GetVariationsMap(variationsMap);
+
+ float variationValue = 0.f;
+ auto tagPtr = variationsMap.Find(tag);
+
+ if(tagPtr)
+ {
+ variationValue = tagPtr->Get<float>();
+ }
+
+ Dali::Property::Index index = self.RegisterProperty(tag.data(), variationValue);
+ if(mVariationIndexMap.find(index) == mVariationIndexMap.end())
+ {
+ PropertyNotification customFontVariationNotification = self.AddPropertyNotification(index, StepCondition(1.0f));
+ // TODO: Make step value customizable by user.
+ customFontVariationNotification.NotifySignal().Connect(this, &TextField::OnVariationPropertyNotify);
+
+ mVariationIndexMap[index] = tag;
+ // TODO: Make UnregisterProperty() to remove tag from mVariationIndexMap.
+ }
+
+ return index;
+}
+
+void TextField::OnVariationPropertyNotify(PropertyNotification& source)
+{
+ Property::Map map;
+ mController->GetVariationsMap(map);
+
+ for(auto &[index, tag] : mVariationIndexMap)
+ {
+ if(Self().DoesCustomPropertyExist(index))
+ {
+ float value = Self().GetCurrentProperty(index).Get<float>();
+ map[tag.data()] = std::round(value);
+ }
+ }
+
+ // Full Variation Update.
+ mController->SetVariationsMap(map);
+}
+
std::string TextField::TextFieldAccessible::GetName() const
{
if(IsHiddenInput())
*/
DevelTextField::SelectionStartedSignalType& SelectionStartedSignal();
+ /**
+ * @brief Registers a new font variation property based on the provided tag.
+ *
+ * @param[in] tag A 4-character string representing the variation property tag.
+ * @return The index of the registered variation property. Property::INVALID_INDEX if failed.
+ */
+ Dali::Property::Index RegisterFontVariationProperty(std::string tag);
+
private: // From Control
/**
* @copydoc Control::OnInitialize()
// Needed to synchronize TextAnchor actors with Anchor objects in text's logical model
void OnAccessibilityStatusChanged();
+ /**
+ * @brief Notifies when the font variation property changes to specific value.
+ */
+ void OnVariationPropertyNotify(PropertyNotification& source);
+
private: // Data
// Signals
Toolkit::TextField::TextChangedSignalType mTextChangedSignal;
Toolkit::DevelTextField::SelectionClearedSignalType mSelectionClearedSignal;
Toolkit::DevelTextField::SelectionStartedSignalType mSelectionStartedSignal;
+ // for Font Variations
+ std::map<Dali::Property::Index, std::string> mVariationIndexMap; // Stores [CustomPropertyIndex, tag].
+
InputMethodContext mInputMethodContext;
Text::ControllerPtr mController;
Text::RendererPtr mRenderer;
impl.mController->SetRemoveBackInset(remove);
break;
}
+ case Toolkit::DevelTextField::Property::FONT_VARIATIONS:
+ {
+ const Property::Map variationsMap = value.Get<Property::Map>();
+ impl.mController->SetVariationsMap(variationsMap);
+
+ impl.RequestTextRelayout();
+ break;
+ }
}
}
value = impl.mController->IsRemoveBackInset();
break;
}
+ case Toolkit::DevelTextField::Property::FONT_VARIATIONS:
+ {
+ Property::Map variationsMap;
+ impl.mController->GetVariationsMap(variationsMap);
+
+ value = variationsMap;
+ break;
+ }
} //switch
return value;
DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY(Toolkit, TextLabel, "asyncLineCount", INTEGER, ASYNC_LINE_COUNT )
DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextLabel, "ellipsisMode", INTEGER, ELLIPSIS_MODE )
DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY(Toolkit, TextLabel, "isScrolling", BOOLEAN, IS_SCROLLING )
+DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextLabel, "fontVariations", MAP, FONT_VARIATIONS )
DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT(Toolkit, TextLabel, "textColor", Color::BLACK, TEXT_COLOR )
DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION(Toolkit, TextLabel, "textColorRed", TEXT_COLOR_RED, TEXT_COLOR, 0)
}
break;
}
+ case Toolkit::DevelTextLabel::Property::FONT_VARIATIONS:
+ {
+ const Property::Map variationsMap = value.Get<Property::Map>();
+ impl.mController->SetVariationsMap(variationsMap);
+
+ impl.RequestTextRelayout();
+ impl.mIsAsyncRenderNeeded = true;
+ break;
+ }
}
// Request relayout when text update is needed. It's necessary to call it
value = impl.mTextScroller && impl.mTextScroller->IsScrolling() ? true : false;
break;
}
+ case Toolkit::DevelTextLabel::Property::FONT_VARIATIONS:
+ {
+ Property::Map variationsMap;
+ impl.mController->GetVariationsMap(variationsMap);
+
+ value = variationsMap;
+ break;
+ }
}
}
}
default:
{
- Control::OnPropertySet(index, propertyValue); // up call to control for non-handled properties
+ if(Self().DoesCustomPropertyExist(index) && mVariationIndexMap.find(index) != mVariationIndexMap.end())
+ {
+ std::string tag = mVariationIndexMap[index];
+ float value = propertyValue.Get<float>();
+
+ Property::Map map;
+ mController->GetVariationsMap(map);
+ map[tag.data()] = value;
+
+ mController->SetVariationsMap(map);
+ }
+ else
+ {
+ Control::OnPropertySet(index, propertyValue); // up call to control for non-handled properties
+ }
break;
}
}
mIsAsyncRenderNeeded = false;
}
+Dali::Property::Index TextLabel::RegisterFontVariationProperty(std::string tag)
+{
+ if(tag.length() != 4) // Variable tag must be 4-length string.
+ {
+ DALI_LOG_ERROR("Font Variation Register Failed. The length of tag is not 4.\n");
+ return Property::INVALID_INDEX;
+ }
+
+ Actor self = Self();
+
+ Property::Map variationsMap;
+ mController->GetVariationsMap(variationsMap);
+
+ float variationValue = 0.f;
+ auto tagPtr = variationsMap.Find(tag);
+
+ if(tagPtr)
+ {
+ variationValue = tagPtr->Get<float>();
+ }
+
+ Dali::Property::Index index = self.RegisterProperty(tag.data(), variationValue);
+ if(mVariationIndexMap.find(index) == mVariationIndexMap.end())
+ {
+ PropertyNotification customFontVariationNotification = self.AddPropertyNotification(index, StepCondition(1.0f));
+ // TODO: Make step value customizable by user.
+ customFontVariationNotification.NotifySignal().Connect(this, &TextLabel::OnVariationPropertyNotify);
+
+ mVariationIndexMap[index] = tag;
+ // TODO: Make UnregisterProperty() to remove tag from mVariationIndexMap.
+ }
+
+ return index;
+}
+
+void TextLabel::OnVariationPropertyNotify(PropertyNotification& source)
+{
+ Property::Map map;
+ mController->GetVariationsMap(map);
+
+ for(auto &[index, tag] : mVariationIndexMap)
+ {
+ if(Self().DoesCustomPropertyExist(index))
+ {
+ float value = Self().GetCurrentProperty(index).Get<float>();
+ map[tag.data()] = std::round(value);
+ }
+ }
+
+ // Full Variation Update.
+ mController->SetVariationsMap(map);
+}
+
std::string TextLabel::TextLabelAccessible::GetNameRaw() const
{
return GetWholeText();
*/
void RequestAsyncHeightForWidth(float width);
+ /**
+ * @brief Registers a new font variation property based on the provided tag.
+ *
+ * @param[in] tag A 4-character string representing the variation property tag.
+ * @return The index of the registered variation property. Property::INVALID_INDEX if failed.
+ */
+ Dali::Property::Index RegisterFontVariationProperty(std::string tag);
private: // From Control
/**
void OnAccessibilityStatusChanged();
+ /**
+ * @brief Notifies when the font variation property changes to specific value.
+ */
+ void OnVariationPropertyNotify(PropertyNotification& source);
+
private: // Data
Text::ControllerPtr mController;
Text::TextScrollerPtr mTextScroller;
Toolkit::DevelTextLabel::AsyncNaturalSizeComputedSignalType mAsyncNaturalSizeComputedSignal;
Toolkit::DevelTextLabel::AsyncHeightForWidthComputedSignalType mAsyncHeightForWidthComputedSignal;
+ // for Font Variations
+ std::map<Dali::Property::Index, std::string> mVariationIndexMap; // Stores [CustomPropertyIndex, tag].
std::string mLocale;
Vector2 mSize;
const Vector<Character>& textToShape = mIsTextMirrored ? mirroredUtf32Characters : utf32Characters;
+ Property::Map *variationsMapPtr = nullptr;
+ if(!mTextModel->mLogicalModel->mVariationsMap.Empty())
+ {
+ variationsMapPtr = &mTextModel->mLogicalModel->mVariationsMap;
+ }
+
// Shapes the text.
ShapeText(mModule.GetShaping(),
mModule.GetFontClient(),
glyphs,
glyphsToCharactersMap,
charactersPerGlyph,
- newParagraphGlyphs);
+ newParagraphGlyphs,
+ variationsMapPtr);
// Create the 'number of glyphs' per character and the glyph to character conversion tables.
mTextModel->mVisualModel->CreateGlyphsPerCharacterTable(0u, 0u, numberOfCharacters);
}
}
+ Property::Map *variationsMapPtr = nullptr;
+ if(!impl.mModel->mLogicalModel->mVariationsMap.Empty())
+ {
+ variationsMapPtr = &impl.mModel->mLogicalModel->mVariationsMap;
+ }
+
// 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(impl.mFontClient,
impl.GetFontSizeScale(),
startIndex,
requestedNumberOfCharacters,
- validFonts);
+ validFonts,
+ variationsMapPtr);
}
updated = true;
}
TextAbstraction::Shaping shaping = TextAbstraction::Shaping::Get();
+ Property::Map *variationsMapPtr = nullptr;
+ if(!impl.mModel->mLogicalModel->mVariationsMap.Empty())
+ {
+ variationsMapPtr = &impl.mModel->mLogicalModel->mVariationsMap;
+ }
+
// Shapes the text.
ShapeText(shaping,
impl.mFontClient,
glyphs,
glyphsToCharactersMap,
charactersPerGlyph,
- newParagraphGlyphs);
+ newParagraphGlyphs,
+ variationsMapPtr);
// Create the 'number of glyphs' per character and the glyph to character conversion tables.
impl.mModel->mVisualModel->CreateGlyphsPerCharacterTable(startIndex, impl.mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters);
}
}
+void Controller::GetVariationsMap(Property::Map& map)
+{
+ map = mImpl->mModel->mLogicalModel->mVariationsMap;
+}
+
+void Controller::SetVariationsMap(const Property::Map& map)
+{
+ auto& variationsMap = mImpl->mModel->mLogicalModel->mVariationsMap;
+ variationsMap.Clear();
+
+ std::size_t numberOfItems = map.Count();
+
+ for(std::size_t index = 0; index < numberOfItems; index++)
+ {
+ const KeyValuePair& keyvalue = map.GetKeyValue(index);
+
+ if(keyvalue.first.type == Property::Key::STRING)
+ {
+ float value = 0.f;
+ if(keyvalue.first.stringKey.length() == 4 && keyvalue.second.Get(value)) // Variable tag must be 4-length string.
+ {
+ variationsMap[keyvalue.first.stringKey.data()] = value;
+ }
+ }
+ }
+
+ // Clear the font-specific data
+ mImpl->ClearFontData();
+
+ mImpl->RequestRelayout();
+}
+
void Controller::ChangedLayoutDirection()
{
mImpl->mIsLayoutDirectionChanged = true;
*/
void SetTextCutout(bool cutout);
+ /**
+ * @brief Retrieves variation value to model
+ * @param[out] map The value of cutout for the text
+ */
+ void GetVariationsMap(Property::Map& map);
+
+ /**
+ * @brief Sets variation value to model
+ * @param[in] map The value of cutout for the text
+ */
+ void SetVariationsMap(const Property::Map& map);
+
/**
* @brief Sets SetMatchLayoutDirection value to model
* @param[in] match The value of matchLayoutDirection for the text
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/object/property-map.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/text/anchor.h>
Vector<BoundedParagraphRun> mBoundedParagraphRuns; ///< The bounded paragraph is used to handle a paragraph mark-up tag and it's attributes. Like TextAlign, TextDirection, TextIndent, LineHeight, etc.
Vector<CharacterSpacingCharacterRun> mCharacterSpacingCharacterRuns; ///< The character-spacing character run from markup-processor.
+ Property::Map mVariationsMap; ///< The map for variable fonts. it might be replaced by variable map run.
+
BidirectionalLineRunIndex mBidirectionalLineIndex; ///< The last fetched bidirectional line info.
bool mSpannedTextPlaced : 1; ///< Whether the spanned-text is placed.
float fontSizeScale,
CharacterIndex startIndex,
Length numberOfCharacters,
- Vector<FontRun>& fonts)
+ Vector<FontRun>& fonts,
+ Property::Map* variationsMapPtr)
{
DALI_LOG_INFO(gLogFilter, Debug::General, "-->MultilanguageSupport::ValidateFonts\n");
isDefaultFont);
// Get the font for the current character.
- FontId fontId = fontClient.GetFontId(currentFontDescription, currentFontPointSize);
+ FontId fontId = fontClient.GetFontId(currentFontDescription, currentFontPointSize, 0, variationsMapPtr);
+
currentFontId = fontId;
// Prevent double-bolding from both markup and style
float fontSizeScale,
CharacterIndex startIndex,
Length numberOfCharacters,
- Vector<FontRun>& fonts);
+ Vector<FontRun>& fonts,
+ Property::Map* variationsMapPtr);
/**
* @brief Callback function for when the locale is changed.
float fontSizeScale,
CharacterIndex startIndex,
Length numberOfCharacters,
- Vector<FontRun>& fonts)
+ Vector<FontRun>& fonts,
+ Property::Map* variationsMapPtr)
{
GetImplementation(*this).ValidateFonts(fontClient,
text,
fontSizeScale,
startIndex,
numberOfCharacters,
- fonts);
+ fonts,
+ variationsMapPtr);
}
const std::string& MultilanguageSupport::GetLocale()
* @param[in] startIndex The character from where the font info is set.
* @param[in] numberOfCharacters The number of characters to set the font.
* @param[out] fonts The validated fonts.
+ * @param[in] variationsMapPtr The variations used in variable fonts.
*/
void ValidateFonts(TextAbstraction::FontClient& fontClient,
const Vector<Character>& text,
float fontSizeScale,
CharacterIndex startIndex,
Length numberOfCharacters,
- Vector<FontRun>& fonts);
+ Vector<FontRun>& fonts,
+ Property::Map* variationsMapPtr = nullptr);
/**
* @brief Gets the locale.
Vector<GlyphInfo>& glyphs,
Vector<CharacterIndex>& glyphToCharacterMap,
Vector<Length>& charactersPerGlyph,
- Vector<GlyphIndex>& newParagraphGlyphs)
+ Vector<GlyphIndex>& newParagraphGlyphs,
+ Property::Map* variationsMapPtr)
{
if(0u == numberOfCharacters)
{
textBuffer + previousIndex,
(currentIndex - previousIndex), // The number of characters to shape.
currentFontId,
- currentScript);
+ currentScript,
+ variationsMapPtr);
#if defined(TRACE_ENABLED)
if(logEnabled)
{
// Add the index of the new paragraph glyph to a vector.
// Their metrics will be updated in a following step.
+ DALI_ASSERT_ALWAYS(glyphIndex > 0u);
newParagraphGlyphs.PushBack(glyphIndex - 1u);
}
* @param[out] glyphToCharacterMap Vector containing the first character in the logical model that each glyph relates to.
* @param[out] charactersPerGlyph Vector containing the number of characters per glyph.
* @param[out] newParagraphGlyphs Vector containing the indices to the new paragraph glyphs.
+ * @param[in] variationsMapPtr The variations used in variable fonts.
*/
void ShapeText(TextAbstraction::Shaping& shaping,
TextAbstraction::FontClient& fontClient,
Vector<GlyphInfo>& glyphs,
Vector<CharacterIndex>& glyphToCharacterMap,
Vector<Length>& charactersPerGlyph,
- Vector<GlyphIndex>& newParagraphGlyphs);
+ Vector<GlyphIndex>& newParagraphGlyphs,
+ Property::Map* variationsMapPtr = nullptr);
} // namespace Text