Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

FontVariationAxis

public final class FontVariationAxis
extends Object

java.lang.Object
   ↳ android.graphics.fonts.FontVariationAxis


Class that holds information about single font variation axis.

Summary

Public constructors

FontVariationAxis(String tagString, float styleValue)

Construct FontVariationAxis.

Public methods

static FontVariationAxis[] fromFontVariationSettings(String settings)

Construct FontVariationAxis array from font variation settings.

float getStyleValue()

Returns the style value associated to the given axis for this font.

String getTag()

Returns the variable font axis tag associated to this axis.

static String toFontVariationSettings(FontVariationAxis[] axes)

Stringify the array of FontVariationAxis.

String toString()

Returns a valid font variation setting string for this object.

Inherited methods

Public constructors

FontVariationAxis

added in API level 26
public FontVariationAxis (String tagString, 
                float styleValue)

Construct FontVariationAxis. The axis tag must contain four ASCII characters. Tag string that are longer or shorter than four characters, or contains characters outside of U+0020..U+007E are invalid.

Parameters
tagString String

This value must never be null.

styleValue float

Throws
IllegalArgumentException If given tag string is invalid.

Public methods

fromFontVariationSettings

added in API level 26
public static FontVariationAxis[] fromFontVariationSettings (String settings)

Construct FontVariationAxis array from font variation settings. The settings string is constructed from multiple pairs of axis tag and style values. The axis tag must contain four ASCII characters and must be wrapped with single quotes (U+0027) or double quotes (U+0022). Axis strings that are longer or shorter than four characters, or contain characters outside of U+0020..U+007E are invalid. If a specified axis name is not defined in the font, the settings will be ignored.

   FontVariationAxis.fromFontVariationSettings("'wdth' 1.0");
   FontVariationAxis.fromFontVariationSettings("'AX  ' 1.0, 'FB  ' 2.0");
 

Parameters
settings String: font variation settings.

This value may be null.

Returns
FontVariationAxis[] FontVariationAxis[] the array of parsed font variation axis. null if settings has no font variation settings.

Throws
IllegalArgumentException If given string is not a valid font variation settings format.

getStyleValue

added in API level 26
public float getStyleValue ()

Returns the style value associated to the given axis for this font.

Returns
float

getTag

added in API level 26
public String getTag ()

Returns the variable font axis tag associated to this axis.

Returns
String

toFontVariationSettings

added in API level 26
public static String toFontVariationSettings (FontVariationAxis[] axes)

Stringify the array of FontVariationAxis.

Parameters
axes FontVariationAxis: an array of FontVariationAxis.

This value may be null.

Returns
String String a valid font variation settings string.

This value will never be null.

toString

added in API level 26
public String toString ()

Returns a valid font variation setting string for this object.

Returns
String a string representation of the object.

This value will never be null.