Skip to content

Generate a Font Information CSV File ​

Usage ​

Run the following commands in the gen-font-info directory:

shell
npm install
node index.js <input-path> [output-path] [output-override=true]

Parameters ​

  • input-path: Path to font files. Supported forms:

    1. Font file URL that returns a font file with content-type of application/octet-stream.

    2. Font list URL that returns JSON with content-type of application/json, in the format ["font-a-url", "font-b-url", ...].

    3. Local font file path (absolute or relative).

    4. Local font folder path. All font files in this folder and subfolders are processed. Supports absolute and relative paths.

  • output-path: Path for the generated CSV file. Defaults to fontInfo.csv in the current directory.

  • output-override: Whether to overwrite an existing CSV file. Defaults to true. If false, new font information is appended to the existing CSV.

Examples ​

Font file URL ​

shell
node index.js http://localhost:8080/fonts/Bradhitc_M.ttf ./fontInfo.csv

Font list URL ​

shell
node index.js http://localhost:8080/fonts.json ./fontInfo.csv

Local font file path ​

shell
# Relative path 
node index.js ./fonts/arial.ttf ./fontInfo.csv
node index.js ./fonts ./fontInfo.csv
# Absolute path
# win
node index.js  D:\fonts\Bradhitc_M.ttf E:\fontInfo.csv
node index.js  D:\fonts E:\fontInfo.csv
# linux, mac
node index.js  /home/fonts/Bradhitc_M.ttf /home/fontInfo.csv
node index.js  /home/fonts /home/fontInfo.csv

output-override ​

shell
node index.js  /home/fonts /home/fontInfo.csv false
node index.js  /home/fonts false