LayoutElementBuilders.FontStyle.Builder


class LayoutElementBuilders.FontStyle.Builder


Builder for FontStyle

Summary

Public constructors

Creates an instance of Builder.

Public functions

LayoutElementBuilders.FontStyle

Builds an instance from accumulated values.

LayoutElementBuilders.FontStyle.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setColor(color: ColorBuilders.ColorProp)

Sets the text color.

LayoutElementBuilders.FontStyle.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setItalic(italic: Boolean)

Sets whether the text should be rendered in a italic typeface.

LayoutElementBuilders.FontStyle.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setItalic(italic: TypeBuilders.BoolProp)

Sets whether the text should be rendered in a italic typeface.

LayoutElementBuilders.FontStyle.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setLetterSpacing(letterSpacing: DimensionBuilders.EmProp)

Sets the text letter-spacing.

LayoutElementBuilders.FontStyle.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setSize(size: DimensionBuilders.SpProp)

Sets the size of the font, in scaled pixels (sp).

LayoutElementBuilders.FontStyle.Builder
@RequiresSchemaVersion(major = 1, minor = 300)
@ProtoLayoutExperimental
setSizes(sizes: @IntRange(from = 1) @Dimension(unit = Dimension.SP) IntArray)

Sets the available sizes of the font, in scaled pixels (sp).

LayoutElementBuilders.FontStyle.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setUnderline(underline: Boolean)

Sets whether the text should be rendered with an underline.

LayoutElementBuilders.FontStyle.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setUnderline(underline: TypeBuilders.BoolProp)

Sets whether the text should be rendered with an underline.

LayoutElementBuilders.FontStyle.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
@ProtoLayoutExperimental
setVariant(variant: Int)

Sets the variant of a font.

LayoutElementBuilders.FontStyle.Builder

Sets the variant of a font.

LayoutElementBuilders.FontStyle.Builder
@RequiresSchemaVersion(major = 1, minor = 0)
setWeight(weight: Int)

Sets the weight of the font.

LayoutElementBuilders.FontStyle.Builder

Sets the weight of the font.

Public constructors

Builder

Added in 1.0.0
Builder()

Creates an instance of Builder.

Public functions

build

Added in 1.0.0
fun build(): LayoutElementBuilders.FontStyle

Builds an instance from accumulated values.

setColor

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setColor(color: ColorBuilders.ColorProp): LayoutElementBuilders.FontStyle.Builder

Sets the text color. If not defined, defaults to white.

While this field is statically accessible from 1.0, it's only bindable since version 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).

setItalic

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setItalic(italic: Boolean): LayoutElementBuilders.FontStyle.Builder

Sets whether the text should be rendered in a italic typeface. If not specified, defaults to "false".

setItalic

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setItalic(italic: TypeBuilders.BoolProp): LayoutElementBuilders.FontStyle.Builder

Sets whether the text should be rendered in a italic typeface. If not specified, defaults to "false".

Note that this field only supports static values.

setLetterSpacing

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setLetterSpacing(letterSpacing: DimensionBuilders.EmProp): LayoutElementBuilders.FontStyle.Builder

Sets the text letter-spacing. Positive numbers increase the space between letters while negative numbers tighten the space. If not specified, defaults to 0.

setSize

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setSize(size: DimensionBuilders.SpProp): LayoutElementBuilders.FontStyle.Builder

Sets the size of the font, in scaled pixels (sp). If not specified, defaults to the size of the system's "body" font.

Any previously added values with this method or setSizes will be cleared.

setSizes

@RequiresSchemaVersion(major = 1, minor = 300)
@ProtoLayoutExperimental
fun setSizes(sizes: @IntRange(from = 1) @Dimension(unit = Dimension.SP) IntArray): LayoutElementBuilders.FontStyle.Builder

Sets the available sizes of the font, in scaled pixels (sp). If not specified, defaults to the size of the system's "body" font.

If more than one size is specified and this FontStyle is applied to a Text element with static text, the text size will be automatically picked from the provided sizes to try to perfectly fit within its parent bounds. In other words, the largest size from the specified preset sizes that can fit the most text within the parent bounds will be used.

The specified sizes don't have to be sorted, but they need to contain only positive values. The maximum number of sizes used is limited to 10.

Note that, if multiple sizes are set, the parent of the Text element this corresponds to shouldn't have its width and height set to wrapped, as it can lead to unexpected results.

If this FontStyle is set to any other element besides Text or that Text element has dynamic field, only the last added size will be used.

Any previously added values with this method or setSize will be cleared.

While this field is accessible from 1.0 as singular, it only accepts multiple values since version 1.3 and renderers supporting version 1.3 will use the multiple values to automatically scale text. Renderers who don't support this version will use the last size among multiple values.

Throws
java.lang.IllegalArgumentException

if the number of available sizes is larger than 10 or one of the sizes is not a positive value.

setUnderline

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setUnderline(underline: Boolean): LayoutElementBuilders.FontStyle.Builder

Sets whether the text should be rendered with an underline. If not specified, defaults to "false".

setUnderline

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setUnderline(underline: TypeBuilders.BoolProp): LayoutElementBuilders.FontStyle.Builder

Sets whether the text should be rendered with an underline. If not specified, defaults to "false".

Note that this field only supports static values.

setVariant

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
@ProtoLayoutExperimental
fun setVariant(variant: Int): LayoutElementBuilders.FontStyle.Builder

Sets the variant of a font. Some renderers may use different fonts for title and body text, which can be selected using this field. If not specified, defaults to "body".

setVariant

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
@ProtoLayoutExperimental
fun setVariant(variant: LayoutElementBuilders.FontVariantProp): LayoutElementBuilders.FontStyle.Builder

Sets the variant of a font. Some renderers may use different fonts for title and body text, which can be selected using this field. If not specified, defaults to "body".

setWeight

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setWeight(weight: Int): LayoutElementBuilders.FontStyle.Builder

Sets the weight of the font. If the provided value is not supported on a platform, the nearest supported value will be used. If not defined, or when set to an invalid value, defaults to "normal".

setWeight

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 0)
fun setWeight(weight: LayoutElementBuilders.FontWeightProp): LayoutElementBuilders.FontStyle.Builder

Sets the weight of the font. If the provided value is not supported on a platform, the nearest supported value will be used. If not defined, or when set to an invalid value, defaults to "normal".