ComponentTextStyle
The object for defining the style for a text component, including spacing, alignment, and drop caps.
Declaration
object ComponentTextStyleProperties
| Name | Type | Description |
|---|---|---|
backgroundColor | (Color | string("none")) | The background color for text lines. The value defaults to transparent. Use the |
conditional | (ConditionalComponentTextStyle | [ConditionalComponentTextStyle]) | An instance or array of component text style properties that can be applied conditionally, and the conditions that cause them to be applied. |
dropCapStyle | (DropCapStyle | string("none")) | The style of drop cap to apply to the first paragraph of the component. Use the |
firstLineIndent | integer | The indent of the first line of each paragraph in points. |
fontFamily | (string | string("system")) | The font family to use for text rendering; for example, You can use the value |
fontName | string | The |
fontScaling | boolean | A Boolean value that indicates whether scaling of font sizes for various screen sizes is enabled. By default, text in Apple News Format articles is scaled down when viewed on devices with screens that are narrower than the width specified in the document layout. This scaling effect occurs at a faster rate for heading roles (Title, Heading, and so on) than for body roles (Body, Byline, Caption, and so on). To disable this effect, set |
fontSize | integer | The size of the font, in points. By default, Apple News applies the font size from a containing component or a default style. As a best practice, try not to go below 16 points for body text. The |
fontStyle | string | The font style to apply. Valid values:
|
fontWeight | (integer | string) | The font weight to apply for font selection. In addition to specific weights (named or numerical), If Apple News can’t find a font variant with the given specifications in the provided font family, it selects an alternative with the closest match. If Apple News doesn’t find a bold/bolder font, it doesn’t create a faux-bold alternative, and instead uses the closest match. Similarly, if Apple News can’t find an italic or oblique font variant, it won’t slant text or make it appear italicized. Valid values:
|
fontWidth | string | The font width to apply for font selection (known in CSS as Valid values:
|
hangingPunctuation | boolean | A Boolean value that defines whether Apple News positions punctuation outside the margins of the text. |
hyphenation | boolean | A Boolean value that indicates whether Apple News hyphenates text when necessary. By default, only components with a |
hyphenationMinimumCharactersAfter | integer | The minimum number of characters required after the hyphen to enable hyphenation. |
hyphenationMinimumCharactersBefore | integer | The minimum number of characters required before the hyphen to enable hyphenation. |
hyphenationMinimumWordLength | integer | The minimum number of characters required for a word to be hyphenated. |
hyphenationZone | integer | The area in points from the right edge of the text component before which a word needs to start to enable hyphenation. By default, the value is set to A larger value reduces the allowable hyphenation area of a word, which can result in a more ragged appearance of the text along the right margin. |
lineBalancing | boolean | A Boolean value that defines whether the system enables line balancing for the text component. |
lineHeight | integer | A number that provides the default line height, in points. Apple News recalculates |
linkStyle | (TextStyle | string("none")) | An object that provides text styling for all links within a text component. Use the |
orderedListItems | (ListItemStyle | string("none")) | An object for use with text components with HTML markup. You can create text styles containing an Use the |
paragraphSpacingAfter | integer | A number that defines the spacing after each paragraph in points relative to the |
paragraphSpacingBefore | integer | A number that defines the spacing before each paragraph in points relative to the |
strikethrough | (TextDecoration | boolean) | The text strikethrough. Set |
stroke | (TextStrokeStyle | string("none")) | The Use the |
textAlignment | string | The justification for all text within the component. If you omit |
textColor | Color | The text color. |
textShadow | (TextShadow | string("none")) | The text shadow for this style. Use the |
textTransform | string | The transform to apply to the text. Valid values:
|
tracking | number | The amount of tracking (spacing between characters) in text, as a percentage of the Example: Set |
underline | (TextDecoration | boolean) | The text underlining. You can use this style for links. Set |
unorderedListItems | (ListItemStyle | string("none")) | The object for use with text components with HTML markup. You can create text styles containing an Use the |
verticalAlignment | string | The vertical alignment of the text. You can use this property for superscripts and subscripts. To override values specified in parent text styles, use Defaults to The values |
Mentioned in
Discussion
Use a ComponentTextStyle object to define the text style for an entire text component (such as body or heading). A ComponentTextStyle object can have the same properties as a TextStyle object, as well as some additional properties such as a drop cap and text alignment.
To use a ComponentTextStyle once, include a ComponentTextStyle object as the value of the individual component’s style property.
To define a style that multiple components can use:
Include a property, with a name that you define and a
ComponentTextStyleobject value, in the ArticleDocument.componentTextStyles object.Use the name you created as the value of the individual component’s
textStyleproperty.
To create a default text style for the article, define a component text style in ArticleDocument.componentTextStyles object and use the key default.
To create a default component text style for a role, define a component text style in ArticleDocument.componentTextStyles and use the key default-<role>. For example, if you define a component text style with the key default-title, all components with a role of title use that style, unless you override it.
For more information about properties, objects, keys, and values, see JSON Concepts and Article Structure. For more about components and roles, see Components.
You can use this object in Text and ArticleDocument.componentTextStyles.
Example
{
"componentTextStyles": {
"exampleStyle": {
"fontName": "HelveticaNeue",
"fontSize": 20,
"dropCapStyle": {
"numberOfLines": 3,
"numberOfRaisedLines": 2,
"numberOfCharacters": 1,
"fontName": "HelveticaNeue",
"textColor": "#FFF",
"backgroundColor": "#000",
"padding": 5
}
}
},
"components": [
{
"role": "body",
"text": "This is body text",
"textStyle": "exampleStyle"
}
]
}