2018-05-08 00:43:08 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
|
|
|
* 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 <limits>
|
|
|
|
|
2018-05-14 22:43:45 +00:00
|
|
|
#include <fabric/attributedstring/primitives.h>
|
2018-05-08 00:43:08 +00:00
|
|
|
#include <fabric/core/LayoutPrimitives.h>
|
|
|
|
#include <fabric/core/ReactPrimitives.h>
|
|
|
|
#include <fabric/debug/DebugStringConvertible.h>
|
|
|
|
#include <fabric/graphics/Color.h>
|
|
|
|
#include <fabric/graphics/Geometry.h>
|
|
|
|
#include <folly/Optional.h>
|
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
|
|
|
class TextAttributes;
|
|
|
|
|
|
|
|
using SharedTextAttributes = std::shared_ptr<const TextAttributes>;
|
|
|
|
|
|
|
|
class TextAttributes:
|
|
|
|
public DebugStringConvertible {
|
|
|
|
public:
|
|
|
|
|
|
|
|
#pragma mark - Fields
|
|
|
|
|
|
|
|
// Color
|
2018-07-18 01:05:40 +00:00
|
|
|
SharedColor foregroundColor {};
|
|
|
|
SharedColor backgroundColor {};
|
2018-05-08 00:43:08 +00:00
|
|
|
Float opacity {std::numeric_limits<Float>::quiet_NaN()};
|
|
|
|
|
|
|
|
// Font
|
|
|
|
std::string fontFamily {""};
|
|
|
|
Float fontSize {std::numeric_limits<Float>::quiet_NaN()};
|
|
|
|
Float fontSizeMultiplier {std::numeric_limits<Float>::quiet_NaN()};
|
|
|
|
folly::Optional<FontWeight> fontWeight {};
|
|
|
|
folly::Optional<FontStyle> fontStyle {};
|
|
|
|
folly::Optional<FontVariant> fontVariant {};
|
|
|
|
folly::Optional<bool> allowFontScaling {};
|
|
|
|
Float letterSpacing {std::numeric_limits<Float>::quiet_NaN()};
|
|
|
|
|
|
|
|
// Paragraph Styles
|
|
|
|
Float lineHeight {std::numeric_limits<Float>::quiet_NaN()};
|
|
|
|
folly::Optional<TextAlignment> alignment {};
|
|
|
|
folly::Optional<WritingDirection> baseWritingDirection {};
|
|
|
|
|
|
|
|
// Decoration
|
2018-07-18 01:05:40 +00:00
|
|
|
SharedColor textDecorationColor {};
|
2018-05-08 00:43:08 +00:00
|
|
|
folly::Optional<TextDecorationLineType> textDecorationLineType {};
|
|
|
|
folly::Optional<TextDecorationLineStyle> textDecorationLineStyle {};
|
|
|
|
folly::Optional<TextDecorationLinePattern> textDecorationLinePattern {};
|
|
|
|
|
|
|
|
// Shadow
|
2018-06-09 03:16:13 +00:00
|
|
|
// TODO: Use `Point` type instead of `Size` for `textShadowOffset` attribute.
|
|
|
|
folly::Optional<Size> textShadowOffset {};
|
2018-05-08 00:43:08 +00:00
|
|
|
Float textShadowRadius {std::numeric_limits<Float>::quiet_NaN()};
|
2018-07-18 01:05:40 +00:00
|
|
|
SharedColor textShadowColor {};
|
2018-05-08 00:43:08 +00:00
|
|
|
|
|
|
|
// Special
|
|
|
|
folly::Optional<bool> isHighlighted {};
|
|
|
|
folly::Optional<LayoutDirection> layoutDirection {};
|
|
|
|
|
|
|
|
#pragma mark - Operations
|
|
|
|
|
|
|
|
void apply(TextAttributes textAttributes);
|
|
|
|
|
|
|
|
#pragma mark - DebugStringConvertible
|
|
|
|
|
|
|
|
SharedDebugStringConvertibleList getDebugProps() const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace react
|
|
|
|
} // namespace facebook
|
|
|
|
|