Sdílet prostřednictvím


FontFamily.Builder.BuildVariableFamily Method

Definition

Build a variable font family that automatically adjust the wght and ital axes value for the requested weight/italic style values.

[Android.Runtime.Register("buildVariableFamily", "()Landroid/graphics/fonts/FontFamily;", "", ApiSince=35)]
public Android.Graphics.Fonts.FontFamily? BuildVariableFamily ();
[<Android.Runtime.Register("buildVariableFamily", "()Landroid/graphics/fonts/FontFamily;", "", ApiSince=35)>]
member this.BuildVariableFamily : unit -> Android.Graphics.Fonts.FontFamily

Returns

A variable font family. null if a variable font cannot be built from the given fonts.

Attributes

Remarks

Build a variable font family that automatically adjust the `wght` and `ital` axes value for the requested weight/italic style values.

To build a variable font family, added fonts must meet one of following conditions.

If two font files are added, both font files must support `wght` axis and one font must support FontStyle#FONT_SLANT_UPRIGHT and another font must support FontStyle#FONT_SLANT_ITALIC. If the requested weight value is lower than minimum value of the supported `wght` axis, the minimum supported `wght` value is used. If the requested weight value is larger than maximum value of the supported `wght` axis, the maximum supported `wght` value is used. The weight values of the fonts are ignored.

If one font file is added, that font must support the `wght` axis. If that font support `ital` axis, that `ital` value is set to 1 when the italic style is requested. If that font doesn't support `ital` axis, synthetic italic may be used. If the requested weight value is lower than minimum value of the supported `wght` axis, the minimum supported `wght` value is used. If the requested weight value is larger than maximum value of the supported `wght`axis, the maximum supported `wght` value is used. The weight value of the font is ignored.

If none of the above conditions are met, the provided font files cannot be used for variable font family and this function returns null. Even if this function returns null, you can still use #build() method for creating FontFamily instance with manually specifying variation settings by using Font.Builder#setFontVariationSettings(String).

Java documentation for android.graphics.fonts.FontFamily.Builder.buildVariableFamily().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to