TypefaceCompat
class TypefaceCompat
Helper for accessing features in Typeface.
Summary
Public functions |
|
|---|---|
java-static Typeface |
Retrieves the best matching typeface given the family, style and context. |
java-static Typeface |
create(Creates a typeface object that best matches the specified existing typeface and the specified weight and italic style |
Public functions
create
java-static fun create(context: Context, family: Typeface?, style: Int): Typeface
Retrieves the best matching typeface given the family, style and context. If null is passed for the family, then the "default" font will be chosen.
| Parameters | |
|---|---|
context: Context |
The context used to retrieve the font. |
family: Typeface? |
The font family. May be null. |
style: Int |
The style of the typeface. e.g. NORMAL, BOLD, ITALIC, BOLD_ITALIC |
| Returns | |
|---|---|
Typeface |
The best matching typeface. |
create
java-static fun create(
context: Context,
family: Typeface?,
weight: @IntRange(from = 1, to = 1000) Int,
italic: Boolean
): Typeface
Creates a typeface object that best matches the specified existing typeface and the specified weight and italic style
Below are numerical values and corresponding common weight names.
| Value | Common weight name |
|---|---|
| 100 | Thin |
| 200 | Extra Light |
| 300 | Light |
| 400 | Normal |
| 500 | Medium |
| 600 | Semi Bold |
| 700 | Bold |
| 800 | Extra Bold |
| 900 | Black |
This method is thread safe.
| Parameters | |
|---|---|
context: Context |
context to use for the creation. |
family: Typeface? |
An existing |
weight: @IntRange(from = 1, to = 1000) Int |
The desired weight to be drawn. |
italic: Boolean |
|