fuchsia.fonts

PROTOCOLS

FontSetEventListener

Defined in fuchsia.fonts/events.fidl

Protocol for listening to possible events that may occur in the Provider's set of fonts.

Register a listener using Provider.RegisterFontSetEventListener.

OnFontSetUpdated

The set of fonts available in the Provider has changed. See FontSetUpdatedEvent.

Request

NameType
event FontSetUpdatedEvent

Response

NameType

Provider

Defined in fuchsia.fonts/font_provider.fidl

Provider of digital font files and metadata.

TODO(I18N-12): Remove deprecated methods and move to provider.fidl.

GetFont

Deprecated. See GetTypeface.

Returns font that matches specified request.

Request

NameType
request Request

Response

NameType
response Response?

GetFamilyInfo

Deprecated. See GetFontFamilyInfo.

Returns information for the specified font family or null if there is no family with the specified name. This function respects family name aliases and ignores case, so request for "robotoSLAB" will return FamilyInfo for "Roboto Slab".

Request

NameType
family string[128]

Response

NameType
family_info FamilyInfo?

GetTypeface

Returns a typeface that matches the specified request, or an empty table if no matching face is found. (The latter is more likely to happen if TypefaceRequestFlags.EXACT_FAMILY is used to disable fallbacks.)

Request

NameType
request TypefaceRequest

Response

NameType
response TypefaceResponse

GetFontFamilyInfo

Returns information for the specified font family, or an empty table if there is no family with the specified name.

This function respects family name aliases and ignores case. For example, "RobotoSlab" is an alias for the canonical name "Roboto Slab". A request for "robotoSLAB" would return the FontFamilyInfo for "Roboto Slab" due to the case-insensitivity and alias resolution.

Request

NameType
family FamilyName

Response

NameType
family_info FontFamilyInfo

RegisterFontSetEventListener

Register a listener to be notified when the set of available fonts or mappings has changed. A client can register as many listeners as it wishes.

To unregister, close the channel.

Request

NameType
listener FontSetEventListener

Response

NameType

STRUCTS

Request

Defined in fuchsia.fonts/font_provider.fidl

Deprecated. See FaceRequest.

NameTypeDescriptionDefault
family string[128]? Desired font family name, e.g. "Roboto". Font family search is case-insensitive. In case when there is no specified family or the specified family doesn't have glyph for the requested `character` then a font from another family may be returned. This behavior can be disabled using `REQUEST_FLAG_NO_FALLBACK`. No default
weight uint32 For example, 400 is normal, 700 is bold. 400
width uint32 Numeric values matching OS/2 & Windows Metrics usWidthClass table. https://www.microsoft.com/typography/otspec/os2.htm For example, 5 is normal. 5
slant Slant Slant.UPRIGHT
language vector<string>[8]? BCP47 language tags in order of preference. See https://tools.ietf.org/html/bcp47 . No default
character uint32 Codepoint for the character that must be present in the returned font or 0. Caller that specify this field are expected to extract character set from the result and cache it in order to avoid calling the API more than necessary. 0
fallback_group FallbackGroup Fallback group preference. Caller can leave this field set to NONE. In that case the font provider will use fallback group of the specified font family. FallbackGroup.NONE
flags uint32 0

Response

Defined in fuchsia.fonts/font_provider.fidl

NameTypeDescriptionDefault
buffer fuchsia.mem/Buffer No default
buffer_id uint32 Buffer identifier for the buffer. Responses with the same buffer_id are guaranteed to contain the same data in the buffer. Clients may use this value to detect if they already have the font cached in parsed form. No default
font_index uint32 Font index within `buffer`. Used for font formats that may contain more than one font per file, e.g. TTC (TrueType Collection). No default

Style

Defined in fuchsia.fonts/font_provider.fidl

Deprecated. See Style2.

NameTypeDescriptionDefault
weight uint32 No default
width uint32 No default
slant Slant No default

FamilyInfo

Defined in fuchsia.fonts/font_provider.fidl

Deprecated. See FontFamilyInfo.

Information about font family that can be requested using GetFamilyInfo().

NameTypeDescriptionDefault
name string[128] Canonical font family name. Note that this may be different from the value passed to GetFamilyInfo() because GetFamilyInfo() also resolves font aliases and ignores case. For example GetFamilyInfo("robotoslab") will FamilyInfo.name = "Robot Slab". No default
styles vector<Style>[300] Unordered list of all available styles in the family. No default

FamilyName

Defined in fuchsia.fonts/provider.fidl

The name of a family of fonts.

Examples: "Roboto", "Noto Serif".

NameTypeDescriptionDefault
name string[128] The characters that make up the name. No default

ENUMS

FallbackGroup

Type: uint32

Defined in fuchsia.fonts/font_provider.fidl

Deprecated. See GenericFontFamily.

NameValueDescription
NONE 0
SERIF 1
SANS_SERIF 2
MONOSPACE 3
CURSIVE 4
FANTASY 5

Slant

Type: uint32

Defined in fuchsia.fonts/styles.fidl

The type of slant of a type face.

NameValueDescription
UPRIGHT 1 The default; upright glyphs.
ITALIC 2 Specially designed, slanted and slightly calligraphic glyphs.
OBLIQUE 3 Skewed glyphs. Oblique usually means an geometric transformation of the upright variant, rather than a custom-designed variant.

Width

Type: uint32

Defined in fuchsia.fonts/styles.fidl

Horizontal width class of the glyphs.

See https://docs.microsoft.com/en-us/typography/opentype/spec/os2#uswidthclass.

NameValueDescription
ULTRA_CONDENSED 1 50% of normal width
EXTRA_CONDENSED 2 62.5% of normal width
CONDENSED 3 75% of normal width
SEMI_CONDENSED 4 87.5% of normal width
NORMAL 5 Normal width
SEMI_EXPANDED 6 112.5% of normal width
EXPANDED 7 125% of normal width
EXTRA_EXPANDED 8 150% of normal width
ULTRA_EXPANDED 9 200% of normal width

GenericFontFamily

Type: uint32

Defined in fuchsia.fonts/styles.fidl

Generic groups of font families that can serve as fallbacks for a specific family.

Every font family belongs to some generic font family (see examples below).

If an exact requested family is unavailable but a fallback group is specified in the request, the provider may return some other family that belongs to the fallback group. For example, if the client requests the "Arial" family with a SANS_SERIF fallback, and "Arial" is unavailable, the provider may return another available sans serif family, such as "Roboto Regular", instead.

See also: https://www.w3.org/TR/css-fonts-4/#generic-font-families

NameValueDescription
SERIF 1 Glyphs have little "serifs", hooks, or notches at the ends of most strokes. Examples: Georgia, Noto Serif, Times New Roman.
SANS_SERIF 2 Glyphs that have no serifs at the ends of most strokes. Examples: Arial, Noto Sans, Roboto, Tahoma.
MONOSPACE 3 Fixed-width fonts. Examples: Consolas, Courier New, Inconsolata.
CURSIVE 4 Handwritten or cursive fonts. Examples: Brush Script, Comic Sans, Lucida Calligraphy.
FANTASY 5 Decorative fonts. Examples: Impact, Papyrus.
SYSTEM_UI 6 The default user interface font on the target platform. This is included for completeness with the CSS specification; font manifests should not declare that a font belongs to the `SYSTEM_UI` generic family, but instead should declare a more specific option (e.g. `SERIF` for Roboto). Not commonly used.
EMOJI 7 Fonts that are used specifically for rendering emoji code points. Examples: Noto Color Emoji.
MATH 8 Fonts that are used primarily for rendering mathematical expressions. Not commonly used.
FANGSONG 9 A group of Chinese fonts between serif and cursive, often used for official Chinese Government documents. Not commonly used.

TABLES

FontSetUpdatedEvent

Defined in fuchsia.fonts/events.fidl

An event indicating that the set of fonts available in the Provider has changed. This is most frequently caused by an ephemeral font being downloaded and cached. Clients should consider re-requesting fonts and re-rendering any displayed text.

OrdinalNameTypeDescription

TypefaceRequest

Defined in fuchsia.fonts/provider.fidl

Parameters for requesting a typeface.

OrdinalNameTypeDescription
1 query TypefaceQuery Parameters for looking up a typeface.
2 flags TypefaceRequestFlags Flags for how to process the request, such as which kinds of substitutions are permitted.

TypefaceQuery

Defined in fuchsia.fonts/provider.fidl

Parameters for looking up a typeface.

OrdinalNameTypeDescription
1 family FamilyName Desired font family name, e.g. "Roboto". Font family search is case-insensitive. Note: In cases where the specified family doesn't exist, or the specified family doesn't have a glyph for the requested `code_point`, a face from another family may be returned. This behavior can be disabled using `TypefaceRequestFlags.EXACT_FAMILY`.
2 style Style2 Style properties of the desired typeface.
3 languages vector<fuchsia.intl/LocaleId>[8] Language tags in order of preference. This allows disambiguating code points that map to different glyphs in different languages (e.g. CJK code points). See `fuchsia.intl.LocaleId`.
4 code_points vector<uint32> Optional code points for which glyphs must be present in the returned face. Callers that specify this field are expected to extract the character set from the result and cache it in order to avoid calling the API more than necessary.
5 fallback_family GenericFontFamily A generic font family to fall back to if an exact match is unavailable or does not contain the requested code point. Every font family belongs to a generic family (configured in the font manifest). If a particular font family doesn't contain a requested code point, the provider can search for the code point in other font families _in the same generic family_ as a fallback. Specifying `fallback_family` in a query allows the client to override the generic family that would be used as a fallback.

TypefaceResponse

Defined in fuchsia.fonts/provider.fidl

Response to a TypefaceRequest. Contains the digital font file and metadata corresponding to a returned typeface. Clients are expected to cache the results if they plan to reuse them.

If a matching typeface cannot be found, the table will be empty.

OrdinalNameTypeDescription
1 buffer fuchsia.mem/Buffer A memory buffer containing the bytes of a digital font file. It is the client's responsibility to identify the type of file and to parse it (usually by delegating to FreeType or a similar library).
2 buffer_id uint32 Identifier for the buffer. Responses with the same `buffer_id` are guaranteed to contain the same data in the buffer. Clients may use this value to detect if they already have the font cached in parsed form.
3 font_index uint32 Index of the returned typeface within `buffer`. Used for digital font formats that may contain more than one typeface per file, e.g. TTC (TrueType Collection).

FontFamilyInfo

Defined in fuchsia.fonts/provider.fidl

Information about a font family that can be requested using Provider.GetFontFamilyInfo().

If a matching font family is not found, the table will be empty.

OrdinalNameTypeDescription
1 name FamilyName Canonical font family name. Note that this may be different from the value passed to `GetFontFamilyInfo()` due to the resolution of font aliases, and/or differences in whitespace and capitalization.
2 styles vector<Style2>[300] Unordered list of all available styles in the family.

Style2

Defined in fuchsia.fonts/styles.fidl

Style properties that can be used when requesting or describing a type face.

OrdinalNameTypeDescription
1 slant Slant See `Slant`.
2 weight uint16 Weight or thickness of the glyphs. Allowed values are integers in the range [1, 1000], but most real-world font families only support some integer multiples of 100: {100, 200, ..., 900}. Normal text (`WEIGHT_NORMAL`) is 400; `WEIGHT_BOLD` is 700. See: https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#Common_weight_name_mapping https://docs.microsoft.com/en-us/typography/opentype/spec/os2#usweightclass
3 width Width See `Width`.

BITS

TypefaceRequestFlags

Type: uint32

NameValueDescription
EXACT_FAMILY 1 Disables font family fallback. The service won't try to search the fallback font set if the requested font family doesn't exist or if it doesn't contain the requested code point.
EXACT_STYLE 2 Disables approximate style matching. The service will only return a face that matches the requested style exactly. For example, there will be no substitutions of "medium" for a requested "semi-bold" weight, or "oblique" for a requested "italic" slant.

CONSTANTS

NameValueTypeDescription
REQUEST_FLAG_NO_FALLBACK 1 uint32 Deprecated. See `FaceRequestFlags`. Disables font fallback. The service won't try to search fallback font set if there is no requested font family or if it doesn't contain requested character.
REQUEST_FLAG_EXACT_MATCH 2 uint32 Deprecated. See `FaceRequestFlags`. Disables approximate style matching. The service will only return font that matches the requested style exactly.
MAX_FAMILY_NAME_LENGTH 128 uint32 The maximum length of a font family name.
MAX_FACE_QUERY_LANGUAGES 8 uint32 The maximum number of preferred languages allowed in a typeface query.
MAX_FAMILY_STYLES 300 uint32 The maximum number of styles that will be returned for a font family.
WEIGHT_THIN 100 uint16
WEIGHT_EXTRA_LIGHT 200 uint16
WEIGHT_LIGHT 300 uint16
WEIGHT_NORMAL 400 uint16
WEIGHT_MEDIUM 500 uint16
WEIGHT_SEMI_BOLD 600 uint16
WEIGHT_BOLD 700 uint16
WEIGHT_EXTRA_BOLD 800 uint16
WEIGHT_BLACK 900 uint16