# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Ctors | Methods | Inherited Methods

# Font.Builder

`public static final class Font.Builder`
`extends Object` ``

java.lang.Object
↳ | android.graphics.fonts.Font.Builder

A builder class for creating new Font.

## Summary

### Public constructors
`Builder(ByteBuffer buffer)` Constructs a builder with a byte buffer.
`Builder(File path)` Constructs a builder with a file path.
`Builder(ParcelFileDescriptor fd)` Constructs a builder with a file descriptor.
`Builder(ParcelFileDescriptor fd, long offset, long size)` Constructs a builder with a file descriptor.
`Builder(AssetManager am, String path)` Constructs a builder from an asset manager and a file path in an asset directory.
`Builder(Resources res, int resId)` Constructs a builder from resources.

### Public methods
`Font` | `build()` Creates the font based on the configured values.
`Font.Builder` | `setFontVariationSettings(String variationSettings)` Sets the font variation settings.
`Font.Builder` | `setFontVariationSettings(FontVariationAxis[] axes)` Sets the font variation settings.
`Font.Builder` | `setSlant(int slant)` Sets italic information of the font.
`Font.Builder` | `setTtcIndex(int ttcIndex)` Sets an index of the font collection.
`Font.Builder` | `setWeight(int weight)` Sets weight of the font.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Public constructors

### Builder

    public Builder (ByteBuffer buffer)

Constructs a builder with a byte buffer. Note that only direct buffer can be used as the source of font data.

Parameters
`buffer` | `ByteBuffer`: a byte buffer of a font data This value cannot be `null`.

See also:

- `ByteBuffer.allocateDirect(int)`

### Builder

    public Builder (File path)

Constructs a builder with a file path.

Parameters
`path` | `File`: a file path to the font file This value cannot be `null`.

### Builder

    public Builder (ParcelFileDescriptor fd)

Constructs a builder with a file descriptor.

Parameters
`fd` | `ParcelFileDescriptor`: a file descriptor This value cannot be `null`.

### Builder

    public Builder (ParcelFileDescriptor fd,
                    long offset,
                    long size)

Constructs a builder with a file descriptor.

Parameters
`fd` | `ParcelFileDescriptor`: a file descriptor This value cannot be `null`.
`offset` | `long`: an offset to of the font data in the file Value is 0 or greater
`size` | `long`: a size of the font data. If -1 is passed, use until end of the file. Value is -1 or greater

### Builder

    public Builder (AssetManager am,
                    String path)

Constructs a builder from an asset manager and a file path in an asset directory.

Parameters
`am` | `AssetManager`: the application's asset manager This value cannot be `null`.
`path` | `String`: the file name of the font data in the asset directory This value cannot be `null`.

### Builder

    public Builder (Resources res,
                    int resId)

Constructs a builder from resources. Resource ID must points the font file. XML font can not be used here.

Parameters
`res` | `Resources`: the resource of this application. This value cannot be `null`.
`resId` | `int`: the resource ID of font file.

## Public methods

### build

    public Font build ()

Creates the font based on the configured values.

Returns
`Font` | the Font object This value cannot be `null`.

Throws
`IOException` |

### setFontVariationSettings

    public Font.Builder setFontVariationSettings (String variationSettings)

Sets the font variation settings.

Parameters
`variationSettings` | `String`: see `FontVariationAxis#fromFontVariationSettings(String)` This value may be `null`.

Returns
`Font.Builder` | this builder This value cannot be `null`.

Throws
`IllegalArgumentException` | If given string is not a valid font variation settings format.

### setFontVariationSettings

    public Font.Builder setFontVariationSettings (FontVariationAxis[] axes)

Sets the font variation settings.

Parameters
`axes` | `FontVariationAxis`: an array of font variation axis tag-value pairs This value may be `null`.

Returns
`Font.Builder` | this builder This value cannot be `null`.

### setSlant

    public Font.Builder setSlant (int slant)

Sets italic information of the font. Tells the system the style of the given font. If this function is not called, the system will resolve the style by reading font tables. For example, if you want to use italic font as upright font, call `setSlant(FontStyle.FONT_SLANT_UPRIGHT)` explicitly.

Parameters
`slant` | `int`: Value is `FontStyle.FONT_SLANT_UPRIGHT`, or `FontStyle.FONT_SLANT_ITALIC`

Returns
`Font.Builder` | this builder This value cannot be `null`.

### setTtcIndex

    public Font.Builder setTtcIndex (int ttcIndex)

Sets an index of the font collection. See `R.attr.ttcIndex`.

Parameters
`ttcIndex` | `int`: An index of the font collection. If the font source is not font collection, do not call this method or specify 0. Value is 0 or greater

Returns
`Font.Builder` | this builder This value cannot be `null`.

### setWeight

    public Font.Builder setWeight (int weight)

Sets weight of the font. Tells the system the weight of the given font. If this function is not called, the system will resolve the weight value by reading font tables. Here are pairs of the common names and their values.

Value | Name | Android Definition
--- | --- | ---
100 | Thin | `FontStyle#FONT_WEIGHT_THIN`
200 | Extra Light (Ultra Light) | `FontStyle#FONT_WEIGHT_EXTRA_LIGHT`
300 | Light | `FontStyle#FONT_WEIGHT_LIGHT`
400 | Normal (Regular) | `FontStyle#FONT_WEIGHT_NORMAL`
500 | Medium | `FontStyle#FONT_WEIGHT_MEDIUM`
600 | Semi Bold (Demi Bold) | `FontStyle#FONT_WEIGHT_SEMI_BOLD`
700 | Bold | `FontStyle#FONT_WEIGHT_BOLD`
800 | Extra Bold (Ultra Bold) | `FontStyle#FONT_WEIGHT_EXTRA_BOLD`
900 | Black (Heavy) | `FontStyle#FONT_WEIGHT_BLACK`

Parameters
`weight` | `int`: a weight value Value is between FontStyle.FONT_WEIGHT_MIN and FontStyle.FONT_WEIGHT_MAX inclusive

Returns
`Font.Builder` | this builder This value cannot be `null`.

See also:

- `FontStyle.FONT_WEIGHT_THIN`
- `FontStyle.FONT_WEIGHT_EXTRA_LIGHT`
- `FontStyle.FONT_WEIGHT_LIGHT`
- `FontStyle.FONT_WEIGHT_NORMAL`
- `FontStyle.FONT_WEIGHT_MEDIUM`
- `FontStyle.FONT_WEIGHT_SEMI_BOLD`
- `FontStyle.FONT_WEIGHT_BOLD`
- `FontStyle.FONT_WEIGHT_EXTRA_BOLD`
- `FontStyle.FONT_WEIGHT_BLACK`

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*