tree: 224898b8c5a80ed248a76a7372a4cad03a0e2a1a [path history] [tgz]
  1. src/
  2. tests/
  3. BUILD.gn
  4. README.md
src/fonts/tools/manifest_generator/README.md

Font Manifest Generator

The font manifest generator creates a .font_manifest.json file for use by the font server.

To see usage instructions, run

./out/default/host_x64/font_manifest_generator --help

Inputs

1. *.font_catalog.json

Contains a human-written listing of font families, assets, and typefaces. See schema.

One .font_catalog.json file exists for each CIPD font repo.

These files are expected to reside in the Fuchsia source tree.

2. *.font_pkgs.json

Contains a listing of font asset names (e.g. "Roboto-Bold.ttf", safe package name suffixes (e.g. "roboto-bold-ttf"), and the relative path of the asset within the font directory.

One .font_pkgs.json file exists for each CIPD font repo. It is generated by a recipe and checked out as a prebuilt, along with font files.

3. *.all_fonts.json and *.local_fonts.json

Contains a listing of all font asset names and those that are local. all_fonts must be a superset of local_fonts. all_fonts are made available as ephemeral packages, while local_fonts are additionally bundled into the font server's /config/data directory in the OTA image.

These file determines which font assets from the catalogs actually end up in the generated manifest.

These files are generated by the GN font_collection template. There should be one pair per product target.

4. *.fontcfg.json

Contains a human-written set of product-specific font settings. See schema.

Currently, the main purpose of this file is to define a specific fallback chain, i.e. a preferred sequence of typefaces to use when an exact match for the client's typeface request is not available.

The fallback chain is defined manually. Some guidelines to follow:

  • Include at least one font for every supported script. (The set of supported scripts varies by product.)
  • Try to cover at least the sans-serif, serif, and monospace font families.
  • When there is overlapping coverage, put more specific assets higher in the list. For example, all of the Noto Sans script-specific fonts have glyphs for the ASCII range, but the Noto Sans Latin variant should go first.
  • When there is overlapping coverage, put smaller font files higher in the list. This reduces UI jank when loading fallback fonts.

Tip

To check which typefaces in a font_collection are not yet included in the fallback chain, run the manifest generator with -v (or --verbose). You can do this by temporarily changing the arguments in font_manifest.gni.

One .fontcfg.json (or .fontcfg.json5) file should be checked in for every GN font_collection() invocation.

5. Font directory

This is usually a directory in //prebuilt/third_party, and it is where the CIPD checkout places all of the font asset files and the *.font_pkgs.json files.

The manifest generator must read the font files to collect the set of code points for each typeface.

Testing

  1. Make sure your fx set arguments include --with //bundles:tests.
  2. Execute fx build
  3. Execute:
fx run-host-tests font_manifest_generator_bin_test \
font_manifest_generator_integration_tests