| 构造器 | 说明 |
|---|---|
Builder(File path) |
A constructor used to create a
Builder instance with the specified file. |
Builder(FileDescriptor fileDescriptor) |
A constructor used to create a
Builder instance with the specified file descriptor. |
Builder(FileDescriptor fileDescriptor,
long offset,
long size) |
A constructor used to create a
Builder instance with the specified file descriptor and file offset. |
Builder(ByteBuffer buffer) |
A constructor used to create a
Builder instance with the specified byte buffer. |
Builder(ResourceManager resourceManager,
int resourceId) |
A constructor used to create a
Builder instance with the specified resource ID. |
Builder(ResourceManager resourceManager,
String path) |
A constructor used to create a
Builder instance with the specified resource file path. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
RawFont |
build() |
A constructor used to create a
RawFont instance based on your configurations. |
RawFont.Builder |
setFontCollectionIndex(int fontCollectionIndex) |
Sets the index of the font collection.
|
RawFont.Builder |
setFontVariations(String variations) |
Sets a font variation axis.
|
RawFont.Builder |
setItalic(boolean isItalic) |
Sets the font to be italic.
|
RawFont.Builder |
setWeight(int weight) |
Sets the font weight.
|
public Builder(ByteBuffer buffer)
Builder instance with the specified byte buffer.buffer - Indicates the byte buffer, which must be a direct buffer.IllegalArgumentException - Throws this exception if the specified buffer is not
a direct buffer.NullPointerException - Throws this exception if the specified buffer is null.ByteBuffer.allocateDirect(int)public Builder(File path)
Builder instance with the specified file.path - Indicates the file path.NullPointerException - Throws this exception if the specified path is null.public Builder(FileDescriptor fileDescriptor)
Builder instance with the specified file descriptor.fileDescriptor - Indicates the file descriptor.NullPointerException - Throws this exception if the specified fileDescriptor is null.public Builder(FileDescriptor fileDescriptor, long offset, long size)
Builder instance with the specified file descriptor and file offset.fileDescriptor - Indicates the file descriptor.offset - Indicates the offset of the file.size - Indicates the data size. If size is set to -1, the actual file size is used.NullPointerException - Throws this exception if the specified fileDescriptor is null.public Builder(ResourceManager resourceManager, int resourceId)
Builder instance with the specified resource ID.resourceManager - Indicates a resource manager, which is obtained using
Context.getResourceManager().resourceId - Indicates the resource ID. The font file is stored in media, for example,
ResourceTable.Media_yourfontfile.NullPointerException - Throws this exception if no data is obtained using the specified
resourceId.public Builder(ResourceManager resourceManager, String path)
Builder instance with the specified resource file path.resourceManager - Indicates a resource manager, which is obtained using
Context.getResourceManager().path - Indicates the path of the font file. The font file is stored in rawfile, for example,
resources/rawfile/your_font_file.ttf.NullPointerException - Throws this exception if no data is obtained using the specified path.public RawFont.Builder setFontVariations(String variations)
Note: When calling this method, you must know the valid variation axes of the corresponding font file and the valid ranges of the values.
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.Builder instance.public RawFont.Builder setItalic(boolean isItalic)
isItalic - Specifies whether to set the font to be italic. The value true means to set the
font to be italic, and false means the opposite.Builder instance.public RawFont.Builder setFontCollectionIndex(int fontCollectionIndex)
Note: When calling this method, you must know the valid index range of the corresponding font collection
file. The value 0 is always valid.
fontCollectionIndex - Indicates the index of the font collection. You must ensure the validity of the
index. The value 0 is always valid.Builder instance.public RawFont.Builder setWeight(int weight)
weight - Indicates the font weight to set. The value ranges from 1 to 1000.
Commonly used weights include Font#REGULAR, Font#MEDIUM, and Font#BOLD.Builder instance.IllegalArgumentException - Throws this exception if the specified weight is not in the valid
range.public RawFont build() throws IOException
RawFont instance based on your configurations.RawFont instance.IOException - Throws this exception if the configurations passed to the Builder
constructor are invalid.