{"id":13526442,"url":"https://github.com/itgalaxy/webfont","last_synced_at":"2025-05-14T19:08:05.589Z","repository":{"id":9874927,"uuid":"62899474","full_name":"itgalaxy/webfont","owner":"itgalaxy","description":"Awesome generator of webfont","archived":false,"fork":false,"pushed_at":"2025-02-15T08:59:30.000Z","size":4593,"stargazers_count":285,"open_issues_count":47,"forks_count":71,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-14T19:08:01.871Z","etag":null,"topics":["cli","converts-ttf-fonts","eot","font","fonts","icons","svg-font","svg-icons","svgicons2svgfont","ttf","web-fonts","webfont","woff","woff2"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itgalaxy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-08T15:42:04.000Z","updated_at":"2025-03-30T00:42:56.000Z","dependencies_parsed_at":"2024-02-03T20:42:43.868Z","dependency_job_id":"e6695e9b-5980-43bd-be27-91b1acec5d9a","html_url":"https://github.com/itgalaxy/webfont","commit_stats":{"total_commits":557,"total_committers":25,"mean_commits":22.28,"dds":0.658886894075404,"last_synced_commit":"2fe39cfaf8495bb094dec83f0f0a1504eefa3cc5"},"previous_names":[],"tags_count":87,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itgalaxy%2Fwebfont","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itgalaxy%2Fwebfont/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itgalaxy%2Fwebfont/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itgalaxy%2Fwebfont/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itgalaxy","download_url":"https://codeload.github.com/itgalaxy/webfont/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254209859,"owners_count":22032897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","converts-ttf-fonts","eot","font","fonts","icons","svg-font","svg-icons","svgicons2svgfont","ttf","web-fonts","webfont","woff","woff2"],"created_at":"2024-08-01T06:01:29.802Z","updated_at":"2025-05-14T19:08:04.567Z","avatar_url":"https://github.com/itgalaxy.png","language":"TypeScript","readme":"# webfont\n\n[![NPM version](https://img.shields.io/npm/v/webfont.svg)](https://www.npmjs.org/package/webfont)\n[![Travis Build Status](https://img.shields.io/travis/itgalaxy/webfont/master.svg?label=build)](https://travis-ci.org/itgalaxy/webfont)\n[![Build status](https://ci.appveyor.com/api/projects/status/a8absovr2r44w1oc?svg=true)](https://ci.appveyor.com/project/evilebottnawi/webfont)\n\nGenerator of fonts from SVG icons.\n\n## Features\n\n- Supported font formats: `WOFF2`, `WOFF`, `EOT`, `TTF` and `SVG`;\n- Support config files: use a `JavaScript`, `JSON` or `YAML` file to specify configuration information for an entire directory and all of its subdirectories;\n- Support all popular browsers, including IE8+;\n- Allows using custom templates (example `css`, `scss`, [`styl`](https://github.com/itgalaxy/webfont/pull/164/) etc);\n- No extra dependencies as `gulp`, `grunt` or other big tools;\n- Tested on all platforms (`linux`, `windows` and `osx`);\n- CLI;\n- [Webpack plugin](https://github.com/itgalaxy/webfont-webpack-plugin).\n\n## Table Of Contents\n\n- [Webfont](#webfont)\n  - [Installation](#installation)\n  - [Usage](#usage)\n  - [Options](#options)\n  - [svgicons2svgfont](#svgicons2svgfont)\n- [Command Line Interface (CLI)](#command-line-interface)\n  - [Installation](#cli-installation)\n  - [Usage](#cli-usage)\n  - [Exit Codes](#cli-exit-codes)\n- [Related](#related)\n- [Roadmap](#roadmap)\n- [Contribution](#contribution)\n- [Changelog](#changelog)\n- [License](#license)\n\n---\n\n## Installation\n\n```shell\nnpm install --save-dev webfont\n```\n\n## Usage\n\n```js\nimport webfont from \"webfont\";\n\nwebfont({\n  files: \"src/svg-icons/**/*.svg\",\n  fontName: \"my-font-name\",\n})\n  .then((result) =\u003e {\n    // Do something with result\n    Function.prototype(result);\n    // Or return it\n    return result;\n  })\n  .catch((error) =\u003e {\n    throw error;\n  });\n```\n\nor\n\n```js\nconst webfont = require(\"webfont\").default;\n\nwebfont({\n  files: \"src/svg-icons/**/*.svg\",\n  fontName: \"my-font-name\",\n})\n  .then((result) =\u003e {\n    // Do something with result\n    Function.prototype(result);\n    // Or return it\n    return result;\n  })\n  .catch((error) =\u003e {\n    throw error;\n  });\n```\n\n### Options\n\n#### `files`\n\n- Type: `string` | `array`\n- Description: A file glob, or array of file globs. Ultimately passed to [fast-glob](https://github.com/mrmlnc/fast-glob) to figure out what files you want to get.\n- Note: `node_modules` and `bower_components` are always ignored.\n\n#### `configFile`\n\n- Type: `string`\n- Description: Path to a specific configuration file `(JSON, YAML, or CommonJS)` or the name of a module in `node_modules` that points to one.\n- Note: If you do not provide `configFile`, webfont will search up the directory tree for configuration file in the following places, in this order:\n  1. a `webfont` property in `package.json`\n  2. a `.webfontrc` file (with or without filename extension: `.json`, `.yaml`, and `.js` are available)\n  3. a `webfont.config.js` file exporting a JS `object`.\n     The search will begin in the working directory and move up the directory tree until it finds a configuration file.\n\n#### `fontName`\n\n- Type: `string`\n- Default: `webfont`\n- Description: The font family name you want.\n\n#### `formats`\n\n- Type: `array`,\n- Default: `['svg', 'ttf', 'eot', 'woff', 'woff2']`,\n- Possible values: `svg, ttf, eot, woff, woff2`,\n- Description: Font file types to generate.\n\n#### `template`\n\n- Type: `string`\n- Default: `null`\n- Possible values: `css`, `scss`, [`styl`](https://github.com/itgalaxy/webfont/pull/164/) (feel free to contribute more).\n- Note: If you want to use a custom template use this option pass in a path `string` like this:\n\n  ```js\n  webfont({\n    template: \"./path/to/my-template.css\",\n  });\n  ```\n\n  Or\n\n  ```js\n  webfont({\n    template: path.resolve(__dirname, \"./my-template.css\"),\n  });\n  ```\n\n  Or\n\n  ```js\n  webfont({\n    template: path.resolve(__dirname, \"./my-template.styl\"),\n  });\n  ```\n\n#### `templateClassName`\n\n- Type: `string`\n- Default: `null`\n- Description: Default font class name.\n\n#### `templateFontPath`\n\n- Type: `string`\n- Default: `./`\n- Description: Path to generated fonts in the `CSS` file.\n\n#### `templateFontName`\n\n- Type: `string`\n- Default: Gets is from `fontName` if not set, but you can specify any value.\n- Description: Template font family name you want.\n\n#### `ligatures`\n\n- Type: `boolean`\n- Default: `true`\n- Description: Turn on/off adding ligature unicode\n\n#### `glyphTransformFn`\n\n- Type: `function`\n- Default: `null`\n- Description: If you want to transform glyph metadata (e.g. titles of CSS classes or unicode) before transferring it in your style template for your icons, you can use this option with glyphs metadata object.\n- Example:\n\n  ```js\n  import webfont from \"webfont\";\n\n  webfont({\n    files: \"src/svg-icons/**/*.svg\",\n    glyphTransformFn: (obj) =\u003e {\n      obj.name += \"_transform\";\n      something();\n\n      return obj;\n    },\n  })\n    .then((result) =\u003e {\n      // Do something with result\n      Function.prototype(result);\n      // Or return it\n      return result;\n    })\n    .catch((error) =\u003e {\n      throw error;\n    });\n  ```\n\n#### `sort`\n\n- Type: `bool`\n- Default: `true`\n- Description: Whether you want to sort the icons sorted by name.\n\n---\n\n## svgicons2svgfont\n\n### svgicons2svgfont options\n\nThese can be appended to [webfont options](#options). These are passed directly to [svgicons2svgfont](https://github.com/nfroidure/svgicons2svgfont).\n\n#### `svgicons2svgfont.fontName`\n\n- Type: `string`\n- Default: Taken from the [webfont fontName option](#fontname)\n- Description: The font family name you want.\n\n#### `svgicons2svgfont.fontId`\n\n- Type: `string`\n- Default: The `fontName` value\n- Description: The font id you want.\n\n#### `svgicons2svgfont.fontStyle`\n\n- Type: `string`\n- Default: `''`\n- Description: The font style you want.\n\n#### `svgicons2svgfont.fontWeight`\n\n- Type: `string`\n- Default: `''`\n- Description: The font weight you want.\n\n#### `svgicons2svgfont.fixedWidth`\n\n- Type: `boolean`\n- Default: `false`\n- Description: Creates a monospace font of the width of the largest input icon.\n\n#### `svgicons2svgfont.centerHorizontally`\n\n- Type: `boolean`\n- Default: `false`\n- Description: Calculate the bounds of a glyph and center it horizontally.\n\n#### `svgicons2svgfont.normalize`\n\n- Type: `boolean`\n- Default: `false`\n- Description: Normalize icons by scaling them to the height of the highest icon.\n\n#### `svgicons2svgfont.fontHeight`\n\n- Type: `number`\n- Default: `MAX(icons.height)`\n- Description: The outputted font height (defaults to the height of the highest input icon).\n\n#### `svgicons2svgfont.round`\n\n- Type: `number`\n- Default: `10e12` Setup SVG path rounding.\n\n#### `svgicons2svgfont.descent`\n\n- Type: `number`\n- Default: `0`\n- Description: The font descent. It is useful to fix the font baseline yourself.\n- Warning: The descent is a positive value!.\n\n#### `svgicons2svgfont.ascent`\n\n- Type: `number`\n- Default: `fontHeight - descent`\n- Description: The font ascent. Use this options only if you know what you're doing. A suitable value for this is computed for you.\n\n#### `svgicons2svgfont.metadata`\n\n- Type: `string`\n- Default: `undefined`\n- Description: The font [metadata](http://www.w3.org/TR/SVG/metadata.html).\n  You can set any character data in, but this is the recommended place for a copyright mention.\n\n#### `svgicons2svgfont.log`\n\n- Type: `function`\n- Default: `console.log`\n- Description: Allows you to provide your own logging function. Set to `function(){}` to disable logging.\n\n---\n\n## Command Line Interface\n\nThe interface for command-line usage is fairly simplistic at this stage, as seen in the following usage section.\n\n### CLI Installation\n\nAdd the `cli` script to your `package.json` file's `scripts` object:\n\n```json\n{\n  \"scripts\": {\n    \"webfont\": \"node node_modules/webfont/dist/cli.js\"\n  }\n}\n```\n\nIf you're using cross-env:\n\n```json\n{\n  \"scripts\": {\n    \"webfont\": \"cross-env node_modules/webfont/dist/cli.js\"\n  }\n}\n```\n\n### CLI Usage\n\n```shell\n    Usage: webfont [input] [options]\n\n    Input: File(s) or glob(s).\n\n        If an input argument is wrapped in quotation marks, it will be passed to \"fast-glob\"\n        for cross-platform glob support.\n\n    Options:\n\n        --config\n\n            Path to a specific configuration file (JSON, YAML, or CommonJS)\n            or the name of a module in \\`node_modules\\` that points to one.\n            If no \\`--config\\` argument is provided, webfont will search for\n            configuration  files in the following places, in this order:\n               - a \\`webfont\\` property in \\`package.json\\`\n               - a \\`.webfontrc\\` file (with or without filename extension:\n                   \\`.json\\`, \\`.yaml\\`, and \\`.js\\` are available)\n               - a \\`webfont.config.js\\` file exporting a JS object\n            The search will begin in the working directory and move up the\n            directory tree until a configuration file is found.\n\n        -f, --font-name\n\n            The font family name you want, default: \"webfont\".\n\n        -h, --help\n\n            Output usage information.\n\n        -v, --version\n\n            Output the version number.\n\n        -r, --formats\n\n            Only this formats generate.\n\n        -d, --dest\n\n            Destination for generated fonts.\n\n        -m, --dest-create\n            Create destination directory if it does not exist.\n\n        -t, --template\n\n            Type of template (\\`css\\`, \\`scss\\`, \\`styl\\`) or path to custom template.\n'\n        -s, --dest-template\n\n            Destination for generated template. If not passed used \\`dest\\` argument value.\n\n        -c, --template-class-name\n\n            Class name in css template.\n\n        -p, --template-font-path\n\n            Font path in css template.\n\n        -n, --template-font-name\n\n            Font name in css template.\n\n        --no-sort\n\n            Keeps the files in the same order of entry\n\n        --verbose\n\n            Tell me everything!.\n\n    For \"svgicons2svgfont\":\n\n        --font-id\n\n            The font id you want, default as \"--font-name\".\n\n        --font-style\n\n            The font style you want.\n\n        --font-weight\n\n            The font weight you want.\n\n        --fixed-width\n\n            Creates a monospace font of the width of the largest input icon.\n\n        --center-horizontally\n\n            Calculate the bounds of a glyph and center it horizontally.\n\n        --normalize\n\n            Normalize icons by scaling them to the height of the highest icon.\n\n        --font-height\n\n            The outputted font height [MAX(icons.height)].\n\n        --round\n\n            Setup the SVG path rounding [10e12].\n\n        --descent\n\n            The font descent [0].\n\n        --ascent\n\n            The font ascent [height - descent].\n\n        --start-unicode\n\n            The start unicode codepoint for files without prefix [0xEA01].\n\n        --prepend-unicode\n\n            Prefix files with their automatically allocated unicode codepoint.\n\n        --metadata\n\n            Content of the metadata tag.\n\n        --add-hash-in-font-url\n\n            Generated font url will be : [webfont].[ext]?v=[hash]\n\n```\n\n### CLI Exit Codes\n\nThe CLI can exit the process with the following exit codes:\n\n- 0: All ok.\n- 1: Something unknown went wrong.\n- Other: related to using packages.\n\n---\n\n## Related\n\n- [Webpack plugin](https://github.com/itgalaxy/webfont-webpack-plugin) - `webpack` plugin.\n- [svgicons2svgfont](https://github.com/nfroidure/svgicons2svgfont) - Simple tool to merge multiple icons to an SVG font.\n- [svg2ttf](https://github.com/fontello/svg2ttf) - Converts SVG fonts to TTF format.\n- [ttf2eot](https://github.com/fontello/ttf2eot) - Converts TTF fonts to EOT format.\n- [ttf2woff](https://github.com/fontello/ttf2woff) - Converts TTF fonts to WOFF format.\n- [wawoff2](https://github.com/fontello/wawoff2) - Converts TTF fonts to WOFF2 and versa vice.\n\n## Roadmap\n\n- The ability to generate from any type to any type;\n- More tests, include CLI test;\n- Improved docs;\n- Reduce package size (maybe implement `ttf2woff2` with native js library);\n- Improve performance (maybe use cache for this).\n\n## Contribution\n\nFeel free to push your code if you agree with publishing under the MIT license.\n\n## Changelog\n\nCheck our [Changelog](CHANGELOG.md)\n\n## License\n\nCheck our [License](LICENSE)\n","funding_links":[],"categories":["Repository","cli","font","JavaScript"],"sub_categories":["Font"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitgalaxy%2Fwebfont","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitgalaxy%2Fwebfont","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitgalaxy%2Fwebfont/lists"}