{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

DeviceFontFamilyNameFontKt

public final class DeviceFontFamilyNameFontKt


Summary

Public methods

static final @NonNull Font
Font(
    @NonNull DeviceFontFamilyName familyName,
    @NonNull FontWeight weight,
    @NonNull FontStyle style,
    @NonNull FontVariation.Settings variationSettings
)

Describes a system-installed font that may be present on some Android devices.

Public methods

Font

public static final @NonNull Font Font(
    @NonNull DeviceFontFamilyName familyName,
    @NonNull FontWeight weight,
    @NonNull FontStyle style,
    @NonNull FontVariation.Settings variationSettings
)

Describes a system-installed font that may be present on some Android devices.

You should assume this will not resolve on some devices and provide an appropriate fallback font.

Family name lookup is device and platform-specific, and different OEMs may install different fonts. All fonts described this way are considered FontLoadingStrategy.OptionalLocal and will continue to the next font in the chain if they are not present on a device.

Use this method to prefer locally pre-loaded system fonts when they are available. System fonts are always more efficient to load than reading a font file, or downloadable fonts.

A system installed font resolution will never trigger text reflow.

This descriptor will trust the weight and style parameters as accurate. However, it is not required that the loaded fonts actually support the requested weight and style and this may trigger platform level font-synthesis of fake bold or fake italic during font resolution.

This Font can not describe the system-installed Typeface.DEFAULT. All other system-installed fonts are allowed.

Note: When setting variationSettings any unset axis may be reset to the font default, ignoring any axis restrictions in fonts.xml or font_customizations.xml. This may have surprising side-effects when named fonts differ only by the default axis settings in XML. When setting variation axis for device fonts, ensure you set all possible settings for the font.

Parameters
@NonNull DeviceFontFamilyName familyName

Android system-installed font family name

@NonNull FontWeight weight

weight to load

@NonNull FontStyle style

style to load

@NonNull FontVariation.Settings variationSettings

font variation settings, unset by default to load default VF from system

Throws
kotlin.IllegalArgumentException

if familyName is empty