TypefaceCompat
public class TypefaceCompat
Helper for accessing features in Typeface.
Summary
Public methods |
|
|---|---|
static @NonNull Typeface |
Retrieves the best matching typeface given the family, style and context. |
static @NonNull Typeface |
create(Creates a typeface object that best matches the specified existing typeface and the specified weight and italic style |
Public methods
create
public static @NonNull Typeface create(@NonNull Context context, @Nullable Typeface family, int style)
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.
create
public static @NonNull Typeface create(
@NonNull Context context,
@Nullable Typeface family,
@IntRange(from = 1, to = 1000) int weight,
boolean italic
)
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 | |
|---|---|
@NonNull Context context |
context to use for the creation. |
@Nullable Typeface family |
An existing |
@IntRange(from = 1, to = 1000) int weight |
The desired weight to be drawn. |
boolean italic |
|