figma_api/models/
type_style.rs

1/*
2 * Figma API
3 *
4 * This is the OpenAPI specification for the [Figma REST API](https://www.figma.com/developers/api).  Note: we are releasing the OpenAPI specification as a beta given the large surface area and complexity of the REST API. If you notice any inaccuracies with the specification, please [file an issue](https://github.com/figma/rest-api-spec/issues).
5 *
6 * The version of the OpenAPI document: 0.31.0
7 * Contact: support@figma.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct TypeStyle {
16    /// Font family of text (standard name).
17    #[serde(rename = "fontFamily", skip_serializing_if = "Option::is_none")]
18    pub font_family: Option<String>,
19    /// PostScript font name.
20    #[serde(rename = "fontPostScriptName", skip_serializing_if = "Option::is_none")]
21    pub font_post_script_name: Option<String>,
22    /// Describes visual weight or emphasis, such as Bold or Italic.
23    #[serde(rename = "fontStyle", skip_serializing_if = "Option::is_none")]
24    pub font_style: Option<String>,
25    /// Whether or not text is italicized.
26    #[serde(rename = "italic", skip_serializing_if = "Option::is_none")]
27    pub italic: Option<bool>,
28    /// Numeric font weight.
29    #[serde(rename = "fontWeight", skip_serializing_if = "Option::is_none")]
30    pub font_weight: Option<f64>,
31    /// Font size in px.
32    #[serde(rename = "fontSize", skip_serializing_if = "Option::is_none")]
33    pub font_size: Option<f64>,
34    /// Text casing applied to the node, default is the original casing.
35    #[serde(rename = "textCase", skip_serializing_if = "Option::is_none")]
36    pub text_case: Option<TextCase>,
37    /// Horizontal text alignment as string enum.
38    #[serde(rename = "textAlignHorizontal", skip_serializing_if = "Option::is_none")]
39    pub text_align_horizontal: Option<TextAlignHorizontal>,
40    /// Vertical text alignment as string enum.
41    #[serde(rename = "textAlignVertical", skip_serializing_if = "Option::is_none")]
42    pub text_align_vertical: Option<TextAlignVertical>,
43    /// Space between characters in px.
44    #[serde(rename = "letterSpacing", skip_serializing_if = "Option::is_none")]
45    pub letter_spacing: Option<f64>,
46    /// An array of fill paints applied to the characters.
47    #[serde(rename = "fills", skip_serializing_if = "Option::is_none")]
48    pub fills: Option<Vec<models::Paint>>,
49    /// Link to a URL or frame.
50    #[serde(rename = "hyperlink", skip_serializing_if = "Option::is_none")]
51    pub hyperlink: Option<Box<models::Hyperlink>>,
52    /// A map of OpenType feature flags to 1 or 0, 1 if it is enabled and 0 if it is disabled. Note that some flags aren't reflected here. For example, SMCP (small caps) is still represented by the `textCase` field.
53    #[serde(rename = "opentypeFlags", skip_serializing_if = "Option::is_none")]
54    pub opentype_flags: Option<std::collections::HashMap<String, f64>>,
55    /// Indicates how the font weight was overridden when there is a text style override.
56    #[serde(rename = "semanticWeight", skip_serializing_if = "Option::is_none")]
57    pub semantic_weight: Option<SemanticWeight>,
58    /// Indicates how the font style was overridden when there is a text style override.
59    #[serde(rename = "semanticItalic", skip_serializing_if = "Option::is_none")]
60    pub semantic_italic: Option<SemanticItalic>,
61    /// Space between paragraphs in px, 0 if not present.
62    #[serde(rename = "paragraphSpacing", skip_serializing_if = "Option::is_none")]
63    pub paragraph_spacing: Option<f64>,
64    /// Paragraph indentation in px, 0 if not present.
65    #[serde(rename = "paragraphIndent", skip_serializing_if = "Option::is_none")]
66    pub paragraph_indent: Option<f64>,
67    /// Space between list items in px, 0 if not present.
68    #[serde(rename = "listSpacing", skip_serializing_if = "Option::is_none")]
69    pub list_spacing: Option<f64>,
70    /// Text decoration applied to the node, default is none.
71    #[serde(rename = "textDecoration", skip_serializing_if = "Option::is_none")]
72    pub text_decoration: Option<TextDecoration>,
73    /// Dimensions along which text will auto resize, default is that the text does not auto-resize. TRUNCATE means that the text will be shortened and trailing text will be replaced with \"…\" if the text contents is larger than the bounds. `TRUNCATE` as a return value is deprecated and will be removed in a future version. Read from `textTruncation` instead.
74    #[serde(rename = "textAutoResize", skip_serializing_if = "Option::is_none")]
75    pub text_auto_resize: Option<TextAutoResize>,
76    /// Whether this text node will truncate with an ellipsis when the text contents is larger than the text node.
77    #[serde(rename = "textTruncation", skip_serializing_if = "Option::is_none")]
78    pub text_truncation: Option<TextTruncation>,
79    /// When `textTruncation: \"ENDING\"` is set, `maxLines` determines how many lines a text node can grow to before it truncates.
80    #[serde(rename = "maxLines", skip_serializing_if = "Option::is_none")]
81    pub max_lines: Option<f64>,
82    /// Line height in px.
83    #[serde(rename = "lineHeightPx", skip_serializing_if = "Option::is_none")]
84    pub line_height_px: Option<f64>,
85    /// Line height as a percentage of normal line height. This is deprecated; in a future version of the API only lineHeightPx and lineHeightPercentFontSize will be returned.
86    #[serde(rename = "lineHeightPercent", skip_serializing_if = "Option::is_none")]
87    pub line_height_percent: Option<f64>,
88    /// Line height as a percentage of the font size. Only returned when `lineHeightPercent` (deprecated) is not 100.
89    #[serde(rename = "lineHeightPercentFontSize", skip_serializing_if = "Option::is_none")]
90    pub line_height_percent_font_size: Option<f64>,
91    /// The unit of the line height value specified by the user.
92    #[serde(rename = "lineHeightUnit", skip_serializing_if = "Option::is_none")]
93    pub line_height_unit: Option<LineHeightUnit>,
94    /// Whether or not this style has overrides over a text style. The possible fields to override are semanticWeight, semanticItalic, hyperlink, and textDecoration. If this is true, then those fields are overrides if present.
95    #[serde(rename = "isOverrideOverTextStyle", skip_serializing_if = "Option::is_none")]
96    pub is_override_over_text_style: Option<bool>,
97    #[serde(rename = "boundVariables", skip_serializing_if = "Option::is_none")]
98    pub bound_variables: Option<Box<models::TypeStyleAllOfBoundVariables>>,
99}
100
101impl TypeStyle {
102    pub fn new() -> TypeStyle {
103        TypeStyle {
104            font_family: None,
105            font_post_script_name: None,
106            font_style: None,
107            italic: None,
108            font_weight: None,
109            font_size: None,
110            text_case: None,
111            text_align_horizontal: None,
112            text_align_vertical: None,
113            letter_spacing: None,
114            fills: None,
115            hyperlink: None,
116            opentype_flags: None,
117            semantic_weight: None,
118            semantic_italic: None,
119            paragraph_spacing: None,
120            paragraph_indent: None,
121            list_spacing: None,
122            text_decoration: None,
123            text_auto_resize: None,
124            text_truncation: None,
125            max_lines: None,
126            line_height_px: None,
127            line_height_percent: None,
128            line_height_percent_font_size: None,
129            line_height_unit: None,
130            is_override_over_text_style: None,
131            bound_variables: None,
132        }
133    }
134}
135/// Text casing applied to the node, default is the original casing.
136#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
137pub enum TextCase {
138    #[serde(rename = "UPPER")]
139    Upper,
140    #[serde(rename = "LOWER")]
141    Lower,
142    #[serde(rename = "TITLE")]
143    Title,
144    #[serde(rename = "SMALL_CAPS")]
145    SmallCaps,
146    #[serde(rename = "SMALL_CAPS_FORCED")]
147    SmallCapsForced,
148}
149
150impl Default for TextCase {
151    fn default() -> TextCase {
152        Self::Upper
153    }
154}
155/// Horizontal text alignment as string enum.
156#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
157pub enum TextAlignHorizontal {
158    #[serde(rename = "LEFT")]
159    Left,
160    #[serde(rename = "RIGHT")]
161    Right,
162    #[serde(rename = "CENTER")]
163    Center,
164    #[serde(rename = "JUSTIFIED")]
165    Justified,
166}
167
168impl Default for TextAlignHorizontal {
169    fn default() -> TextAlignHorizontal {
170        Self::Left
171    }
172}
173/// Vertical text alignment as string enum.
174#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
175pub enum TextAlignVertical {
176    #[serde(rename = "TOP")]
177    Top,
178    #[serde(rename = "CENTER")]
179    Center,
180    #[serde(rename = "BOTTOM")]
181    Bottom,
182}
183
184impl Default for TextAlignVertical {
185    fn default() -> TextAlignVertical {
186        Self::Top
187    }
188}
189/// Indicates how the font weight was overridden when there is a text style override.
190#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
191pub enum SemanticWeight {
192    #[serde(rename = "BOLD")]
193    Bold,
194    #[serde(rename = "NORMAL")]
195    Normal,
196}
197
198impl Default for SemanticWeight {
199    fn default() -> SemanticWeight {
200        Self::Bold
201    }
202}
203/// Indicates how the font style was overridden when there is a text style override.
204#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
205pub enum SemanticItalic {
206    #[serde(rename = "ITALIC")]
207    Italic,
208    #[serde(rename = "NORMAL")]
209    Normal,
210}
211
212impl Default for SemanticItalic {
213    fn default() -> SemanticItalic {
214        Self::Italic
215    }
216}
217/// Text decoration applied to the node, default is none.
218#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
219pub enum TextDecoration {
220    #[serde(rename = "NONE")]
221    None,
222    #[serde(rename = "STRIKETHROUGH")]
223    Strikethrough,
224    #[serde(rename = "UNDERLINE")]
225    Underline,
226}
227
228impl Default for TextDecoration {
229    fn default() -> TextDecoration {
230        Self::None
231    }
232}
233/// Dimensions along which text will auto resize, default is that the text does not auto-resize. TRUNCATE means that the text will be shortened and trailing text will be replaced with \"…\" if the text contents is larger than the bounds. `TRUNCATE` as a return value is deprecated and will be removed in a future version. Read from `textTruncation` instead.
234#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
235pub enum TextAutoResize {
236    #[serde(rename = "NONE")]
237    None,
238    #[serde(rename = "WIDTH_AND_HEIGHT")]
239    WidthAndHeight,
240    #[serde(rename = "HEIGHT")]
241    Height,
242    #[serde(rename = "TRUNCATE")]
243    Truncate,
244}
245
246impl Default for TextAutoResize {
247    fn default() -> TextAutoResize {
248        Self::None
249    }
250}
251/// Whether this text node will truncate with an ellipsis when the text contents is larger than the text node.
252#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
253pub enum TextTruncation {
254    #[serde(rename = "DISABLED")]
255    Disabled,
256    #[serde(rename = "ENDING")]
257    Ending,
258}
259
260impl Default for TextTruncation {
261    fn default() -> TextTruncation {
262        Self::Disabled
263    }
264}
265/// The unit of the line height value specified by the user.
266#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
267pub enum LineHeightUnit {
268    #[serde(rename = "PIXELS")]
269    Pixels,
270    #[serde(rename = "FONT_SIZE_%")]
271    FontSizePercent,
272    #[serde(rename = "INTRINSIC_%")]
273    IntrinsicPercent,
274}
275
276impl Default for LineHeightUnit {
277    fn default() -> LineHeightUnit {
278        Self::Pixels
279    }
280}
281