( ´∀`)文字 Moji
How-to guides

Automate Moji with JSON

Use structured output and exit codes in scripts and pipelines.

Add --json whenever another program will parse the output:

moji "Futura" --format otf --json

Search output is an array of result objects. Each object includes:

  • name, filename, format, and weight
  • size_bytes when known
  • source and the direct url
  • trusted and the best-effort license hint
  • archive_format and archive_member when the font is inside an archive
  • the calculated score

Inspect a local font when a script needs to verify language coverage:

moji inspect Inter.woff2 --json |
  jq '.scripts[] | select(.name == "Cyrillic")'

Inspection output is one object with the file path, detected format, optional family and subfamily, glyphs, unicode_version, encoded_characters, and a scripts array. Each script entry contains its name, encoded and assigned character counts, and numeric coverage percentage. encoded_characters counts every mapped Unicode scalar, including private-use characters. Scripts with zero encoded characters are omitted.

Select a field with jq

moji "Futura" --format otf --json |
  jq -r '.[].url'

Preview an automated download

moji get "Futura bold" --dry-run --json |
  jq '.[0] | {filename, source, license}'

Check exit status

if moji get "Futura bold" --dry-run --json > selection.json; then
  jq '.[0]' selection.json
else
  echo "Moji could not select a font" >&2
  exit 1
fi

Moji writes primary data to standard output and diagnostics to standard error. Exit 0 means success, 2 means invalid command usage, and 1 means an operational failure.

On this page