| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
MAX_FALLBACK_NUM |
Specifies the maximum number of
FontFamily objects allowed in the custom fallback list. |
| 构造器 | 说明 |
|---|---|
Builder(File file) |
Creates a
Builder instance with specified font file. |
Builder(FileDescriptor fileDescriptor) |
Creates a
Font object based on the file descriptor. |
Builder(String name) |
Creates a
Builder instance with specified font family. |
Builder(Font font) |
|
Builder(FontFamily fontFamily) |
Creates a font based on the specified
fontFamily. |
Builder(ResourceManager resourceManager,
String path) |
Creates a
Font object based on the specified font file (from the Resource Manager). |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
Font.Builder |
addCustomFallback(FontFamily fontFamily) |
Adds the specified
fontFamily to the custom fallback list. |
Font |
build() |
Creates a font object based on the specified style.
|
Font.Builder |
makeItalic(boolean italic) |
Italicizes the font to be built.
|
Font.Builder |
setFontCollectionIndex(int fontCollectionIndex) |
Sets the index of the font collection.
|
Font.Builder |
setFontVariations(String variations) |
Specifies the settings of the font variation axis.
|
Font.Builder |
setSystemFallback(String fontFamilyName) |
Searches for the system fallback list matching the specified
fontFamilyName and uses it as the
fallback list of the font to be created. |
Font.Builder |
setWeight(int weight) |
Sets the font weight of the font to be built.
|
public static final int MAX_FALLBACK_NUM
FontFamily objects allowed in the custom fallback list.public Builder(String name)
Builder instance with specified font family.name - Indicates the font family specified for the Builder instance.public Builder(File file)
Builder instance with specified font file.file - Indicates the font file specified for the Builder instance.public Builder(FileDescriptor fileDescriptor)
Font object based on the file descriptor.fileDescriptor - Indicates the font file descriptor.public Builder(ResourceManager resourceManager, String path)
Font object based on the specified font file (from the Resource Manager).resourceManager - Indicates the Resource Manager. You can use getResourceManager() to obtain
the Resource Manager.path - Indicates the path of the font file. The font file is stored in the rawfile directory,
for example, resources/rawfile/your_font_file.ttf.NullPointerException - Throws this exception if the specified resourceManager or
path is null.public Builder(Font font)
Font object based on the existing Font object.
Then, you can obtain Font objects of different styles by specifying the font weight and italic
style.
font - Indicates the existing Font object. The default font will be used if this parameter
is null.public Builder(FontFamily fontFamily)
fontFamily.fontFamily - Indicates the FontFamily object.NullPointerException - Throws this exception if the specified fontFamily is null.public Font.Builder makeItalic(boolean italic)
italic - Specifies whether to italicize the font,
true means to italicize the font, and false means the opposite.public Font.Builder setWeight(int weight)
weight - Indicates the font weight to set. The value ranges from 1 to 1000.
Commonly used weights includes Font.REGULAR, Font.MEDIUM and Font.BOLD.public Font build()
public Font.Builder setSystemFallback(String fontFamilyName)
fontFamilyName and uses it as the
fallback list of the font to be created.
A custom fallback (if available) takes precedence over the system fallback list.
fontFamilyName - Indicates the font family name specified. It is used to search for the system
fallback list.NullPointerException - Throws this exception if the specified fontFamilyName is null.IllegalArgumentException - Throws this exception if the family name and font
objects are specified as Builder parameters.public Font.Builder addCustomFallback(FontFamily fontFamily)
fontFamily to the custom fallback list.
A maximum of 64 FontFamilys (Include the one passed in the constructor).
fontFamily - Indicates the FontFamily to be added to the custom fallback list.NullPointerException - Throws this exception if the specified fontFamily is null.IllegalArgumentException - Throws this exception if the number of FontFamily objects is
0 or exceeds the upper limit.public Font.Builder setFontCollectionIndex(int fontCollectionIndex)
0 is always valid.fontCollectionIndex - Indicates the index of the font collection. Ensure that the index is valid.
The value 0 is always valid.IllegalArgumentException - Throws this exception if no font file is specified as the Builder
parameter.public Font.Builder setFontVariations(String variations)
variations - Indicates the font variation axis to set. For example, the string
"'wght' 400,'ital' 1" means that the font is in italics and the font weight is 400.NullPointerException - Throws this exception if the specified variations is null.IllegalArgumentException - Throws this exception if no font file is specified as the
Builder parameter.