/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include #include #include #include #include #include #include #include #include namespace facebook { namespace react { class TextAttributes; using SharedTextAttributes = std::shared_ptr; class TextAttributes : public DebugStringConvertible { public: #pragma mark - Fields // Color SharedColor foregroundColor{}; SharedColor backgroundColor{}; Float opacity{std::numeric_limits::quiet_NaN()}; // Font std::string fontFamily{""}; Float fontSize{std::numeric_limits::quiet_NaN()}; Float fontSizeMultiplier{std::numeric_limits::quiet_NaN()}; folly::Optional fontWeight{}; folly::Optional fontStyle{}; folly::Optional fontVariant{}; folly::Optional allowFontScaling{}; Float letterSpacing{std::numeric_limits::quiet_NaN()}; // Paragraph Styles Float lineHeight{std::numeric_limits::quiet_NaN()}; folly::Optional alignment{}; folly::Optional baseWritingDirection{}; // Decoration SharedColor textDecorationColor{}; folly::Optional textDecorationLineType{}; folly::Optional textDecorationLineStyle{}; folly::Optional textDecorationLinePattern{}; // Shadow // TODO: Use `Point` type instead of `Size` for `textShadowOffset` attribute. folly::Optional textShadowOffset{}; Float textShadowRadius{std::numeric_limits::quiet_NaN()}; SharedColor textShadowColor{}; // Special folly::Optional isHighlighted{}; folly::Optional layoutDirection{}; #pragma mark - Operations void apply(TextAttributes textAttributes); #pragma mark - Operators bool operator==(const TextAttributes &rhs) const; bool operator!=(const TextAttributes &rhs) const; #pragma mark - DebugStringConvertible #if RN_DEBUG_STRING_CONVERTIBLE SharedDebugStringConvertibleList getDebugProps() const override; #endif }; } // namespace react } // namespace facebook namespace std { template <> struct hash { size_t operator()( const facebook::react::TextAttributes &textAttributes) const { return std::hash{}( textAttributes.foregroundColor) + std::hash{}( textAttributes.backgroundColor) + std::hash{}(textAttributes.opacity) + std::hash{}( textAttributes.fontFamily) + std::hash{}( textAttributes.fontSize) + std::hash{}( textAttributes.fontSizeMultiplier) + std::hash{}( textAttributes.fontWeight) + std::hash{}( textAttributes.fontStyle) + std::hash{}( textAttributes.fontVariant) + std::hash{}( textAttributes.allowFontScaling) + std::hash{}( textAttributes.letterSpacing) + std::hash{}( textAttributes.lineHeight) + std::hash{}( textAttributes.alignment) + std::hash{}( textAttributes.baseWritingDirection) + std::hash{}( textAttributes.textDecorationColor) + std::hash{}( textAttributes.textDecorationLineType) + std::hash{}( textAttributes.textDecorationLineStyle) + std::hash{}( textAttributes.textDecorationLinePattern) + std::hash{}( textAttributes.textShadowOffset) + std::hash{}( textAttributes.textShadowRadius) + std::hash{}( textAttributes.textShadowColor) + std::hash{}( textAttributes.isHighlighted) + std::hash{}( textAttributes.layoutDirection); } }; } // namespace std