primitives.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #pragma once
  8. #include <functional>
  9. #include <limits>
  10. namespace facebook {
  11. namespace react {
  12. enum class FontStyle { Normal, Italic, Oblique };
  13. enum class FontWeight : int {
  14. Weight100 = 100,
  15. UltraLight = 100,
  16. Weight200 = 200,
  17. Thin = 200,
  18. Weight300 = 300,
  19. Light = 300,
  20. Weight400 = 400,
  21. Regular = 400,
  22. Weight500 = 500,
  23. Medium = 500,
  24. Weight600 = 600,
  25. Semibold = 600,
  26. Demibold = 600,
  27. Weight700 = 700,
  28. Bold = 700,
  29. Weight800 = 800,
  30. Heavy = 800,
  31. Weight900 = 900,
  32. Black = 900
  33. };
  34. enum class FontVariant : int {
  35. Default = 0,
  36. SmallCaps = 1 << 1,
  37. OldstyleNums = 1 << 2,
  38. LiningNums = 1 << 3,
  39. TabularNums = 1 << 4,
  40. ProportionalNums = 1 << 5
  41. };
  42. enum class EllipsizeMode {
  43. Clip, // Do not add ellipsize, simply clip.
  44. Head, // Truncate at head of line: "...wxyz".
  45. Tail, // Truncate at tail of line: "abcd...".
  46. Middle // Truncate middle of line: "ab...yz".
  47. };
  48. enum class TextBreakStrategy { Simple, Balanced, HighQuality };
  49. enum class TextAlignment {
  50. Natural, // Indicates the default alignment for script.
  51. Left, // Visually left aligned.
  52. Center, // Visually centered.
  53. Right, // Visually right aligned.
  54. Justified // Fully-justified. The last line in a paragraph is natural-aligned.
  55. };
  56. enum class WritingDirection {
  57. Natural, // Determines direction using the Unicode Bidi Algorithm rules P2 and
  58. // P3.
  59. LeftToRight, // Left to right writing direction.
  60. RightToLeft // Right to left writing direction.
  61. };
  62. enum class TextDecorationLineType {
  63. None,
  64. Underline,
  65. Strikethrough,
  66. UnderlineStrikethrough
  67. };
  68. enum class TextDecorationLineStyle { Single, Thick, Double };
  69. enum class TextDecorationLinePattern {
  70. Solid,
  71. Dot,
  72. Dash,
  73. DashDot,
  74. DashDotDot,
  75. };
  76. } // namespace react
  77. } // namespace facebook
  78. namespace std {
  79. template <>
  80. struct hash<facebook::react::FontVariant> {
  81. size_t operator()(const facebook::react::FontVariant &v) const {
  82. return hash<int>()(static_cast<int>(v));
  83. }
  84. };
  85. template <>
  86. struct hash<facebook::react::TextAlignment> {
  87. size_t operator()(const facebook::react::TextAlignment &v) const {
  88. return hash<int>()(static_cast<int>(v));
  89. }
  90. };
  91. template <>
  92. struct hash<facebook::react::FontStyle> {
  93. size_t operator()(const facebook::react::FontStyle &v) const {
  94. return hash<int>()(static_cast<int>(v));
  95. }
  96. };
  97. template <>
  98. struct hash<facebook::react::TextDecorationLineType> {
  99. size_t operator()(const facebook::react::TextDecorationLineType &v) const {
  100. return hash<int>()(static_cast<int>(v));
  101. }
  102. };
  103. template <>
  104. struct hash<facebook::react::WritingDirection> {
  105. size_t operator()(const facebook::react::WritingDirection &v) const {
  106. return hash<int>()(static_cast<int>(v));
  107. }
  108. };
  109. template <>
  110. struct hash<facebook::react::TextDecorationLinePattern> {
  111. size_t operator()(const facebook::react::TextDecorationLinePattern &v) const {
  112. return hash<int>()(static_cast<int>(v));
  113. }
  114. };
  115. template <>
  116. struct hash<facebook::react::TextDecorationLineStyle> {
  117. size_t operator()(const facebook::react::TextDecorationLineStyle &v) const {
  118. return hash<int>()(static_cast<int>(v));
  119. }
  120. };
  121. template <>
  122. struct hash<facebook::react::FontWeight> {
  123. size_t operator()(const facebook::react::FontWeight &v) const {
  124. return hash<int>()(static_cast<int>(v));
  125. }
  126. };
  127. template <>
  128. struct hash<facebook::react::EllipsizeMode> {
  129. size_t operator()(const facebook::react::EllipsizeMode &v) const {
  130. return hash<int>()(static_cast<int>(v));
  131. }
  132. };
  133. template <>
  134. struct hash<facebook::react::TextBreakStrategy> {
  135. size_t operator()(const facebook::react::TextBreakStrategy &v) const {
  136. return hash<int>()(static_cast<int>(v));
  137. }
  138. };
  139. } // namespace std