Skip to content

CLI tool to generate fonts.json metadata for Nutrient PDF SDK font bundles

License

Notifications You must be signed in to change notification settings

PSPDFKit/nutrient-font-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nutrient-font-tool

Generate fonts.json metadata for Nutrient PDF SDK font bundles.

📖 Guide: Dynamic Font Loading in Nutrient Web SDK

Installation

# Run directly (no install needed)
npx @nutrient-sdk/font-tool create ./my-fonts

# Or install globally
npm install -g @nutrient-sdk/font-tool

Usage

# Generate fonts.json inside the font directory
nutrient-font-tool create ./my-fonts
# → ./my-fonts/fonts.json

# Specify custom output path
nutrient-font-tool create ./my-fonts -o ./output/fonts.json

# Pretty-print the JSON
nutrient-font-tool create ./my-fonts --pretty

The tool recursively scans the input directory for font files.

Options

Option Description
-o, --output <file> Output file (default: <input-dir>/fonts.json)
--pretty Pretty-print JSON output

Supported Formats

  • .ttf - TrueType
  • .otf - OpenType
  • .ttc - TrueType Collection
  • .otc - OpenType Collection

Output

Generates a fonts.json file with font metadata:

{
  "v": 1,
  "availableFonts": [
    {
      "name": {
        "family": "Noto Sans",
        "fullName": "Noto Sans Regular",
        "subfamily": "Regular"
      },
      "filePath": "NotoSans-Regular.ttf",
      "codePoints": [[32, 126], [160, 255], ...],
      "sha1": "abc123...",
      "allowedToEmbed": true,
      "weight": 5
    }
  ]
}

Requirements

  • Node.js 18+

Learn More

License

MIT

About

CLI tool to generate fonts.json metadata for Nutrient PDF SDK font bundles

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published