Added in API level 29

FontStyle

class FontStyle
kotlin.Any
   ↳ android.graphics.fonts.FontStyle

A font style object. This class represents a single font style which is a pair of weight value and slant value. Here are common font styles examples:

<code>
  final FontStyle NORMAL = new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT);
  final FontStyle BOLD = new FontStyle(FONT_WEIGHT_BOLD, FONT_SLANT_UPRIGHT);
  final FontStyle ITALIC = new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_ITALIC);
  final FontStyle BOLD_ITALIC = new FontStyle(FONT_WEIGHT_BOLD, FONT_SLANT_ITALIC);
  </code>

Summary

Constants
static Int

A font slant value for italic

static Int

A font slant value for upright

static Int

A font weight value for the black weight

static Int

A font weight value for the bold weight.

static Int

A font weight value for the extra-bold weight

static Int

A font weight value for the extra-light weight

static Int

A font weight value for the light weight

static Int

A maximum weight value for the font

static Int

A font weight value for the medium weight

static Int

A minimum weight value for the font

static Int

A font weight value for the normal weight

static Int

A font weight value for the semi-bold weight

static Int

A font weight value for the thin weight

static Int

A default value when font weight is unspecified

Public constructors

FontStyle(weight: Int, slant: Int)

Create FontStyle with specific weight and italic

Public methods
Boolean
equals(other: Any?)

Indicates whether some other object is "equal to" this one.

Int

Gets the slant value

Int

Gets the weight value

Int

String

Constants

FONT_SLANT_ITALIC

Added in API level 29
static val FONT_SLANT_ITALIC: Int

A font slant value for italic

Value: 1

FONT_SLANT_UPRIGHT

Added in API level 29
static val FONT_SLANT_UPRIGHT: Int

A font slant value for upright

Value: 0

FONT_WEIGHT_BLACK

Added in API level 29
static val FONT_WEIGHT_BLACK: Int

A font weight value for the black weight

Value: 900

FONT_WEIGHT_BOLD

Added in API level 29
static val FONT_WEIGHT_BOLD: Int

A font weight value for the bold weight.

Value: 700

FONT_WEIGHT_EXTRA_BOLD

Added in API level 29
static val FONT_WEIGHT_EXTRA_BOLD: Int

A font weight value for the extra-bold weight

Value: 800

FONT_WEIGHT_EXTRA_LIGHT

Added in API level 29
static val FONT_WEIGHT_EXTRA_LIGHT: Int

A font weight value for the extra-light weight

Value: 200

FONT_WEIGHT_LIGHT

Added in API level 29
static val FONT_WEIGHT_LIGHT: Int

A font weight value for the light weight

Value: 300

FONT_WEIGHT_MAX

Added in API level 29
static val FONT_WEIGHT_MAX: Int

A maximum weight value for the font

Value: 1000

FONT_WEIGHT_MEDIUM

Added in API level 29
static val FONT_WEIGHT_MEDIUM: Int

A font weight value for the medium weight

Value: 500

FONT_WEIGHT_MIN

Added in API level 29
static val FONT_WEIGHT_MIN: Int

A minimum weight value for the font

Value: 1

FONT_WEIGHT_NORMAL

Added in API level 29
static val FONT_WEIGHT_NORMAL: Int

A font weight value for the normal weight

Value: 400

FONT_WEIGHT_SEMI_BOLD

Added in API level 29
static val FONT_WEIGHT_SEMI_BOLD: Int

A font weight value for the semi-bold weight

Value: 600

FONT_WEIGHT_THIN

Added in API level 29
static val FONT_WEIGHT_THIN: Int

A font weight value for the thin weight

Value: 100

FONT_WEIGHT_UNSPECIFIED

Added in API level 34
static val FONT_WEIGHT_UNSPECIFIED: Int

A default value when font weight is unspecified

Value: -1

Public constructors

FontStyle

Added in API level 29
FontStyle()

Public methods

equals

Added in API level 29
fun equals(other: Any?): Boolean

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj the reference object with which to compare.
o This value may be null.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getSlant

Added in API level 29
fun getSlant(): Int

Gets the slant value

Return
Int a slant value Value is android.graphics.fonts.FontStyle#FONT_SLANT_UPRIGHT, or android.graphics.fonts.FontStyle#FONT_SLANT_ITALIC

getWeight

Added in API level 29
fun getWeight(): Int

Gets the weight value

Return
Int a weight value Value is between 0 and 1000 inclusive

hashCode

Added in API level 29
fun hashCode(): Int
Return
Int a hash code value for this object.

toString

Added in API level 29
fun toString(): String
Return
String a string representation of the object.