{"id":18024000,"url":"https://github.com/lete114/font-minify","last_synced_at":"2025-09-21T06:20:01.467Z","repository":{"id":216131125,"uuid":"740539831","full_name":"Lete114/font-minify","owner":"Lete114","description":"Keep only used glyphs and remove unused glyphs. Generate font subsets to achieve the purpose of compression","archived":false,"fork":false,"pushed_at":"2024-02-26T15:28:08.000Z","size":6887,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T18:11:21.322Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://font-minify.vercel.app","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/Lete114.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-08T14:54:20.000Z","updated_at":"2024-09-27T14:53:33.000Z","dependencies_parsed_at":"2024-01-12T16:58:54.357Z","dependency_job_id":"4d39df04-94b6-4071-8d4c-6c2d5ec57d46","html_url":"https://github.com/Lete114/font-minify","commit_stats":null,"previous_names":["lete114/font-minify"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lete114%2Ffont-minify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lete114%2Ffont-minify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lete114%2Ffont-minify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lete114%2Ffont-minify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lete114","download_url":"https://codeload.github.com/Lete114/font-minify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245760562,"owners_count":20667886,"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":[],"created_at":"2024-10-30T07:11:38.402Z","updated_at":"2025-09-21T06:19:55.688Z","avatar_url":"https://github.com/Lete114.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# font-minify\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![bundle][bundle-src]][bundle-href]\n[![JSDocs][jsdocs-src]][jsdocs-href]\n[![License][license-src]][license-href]\n\nKeep only used glyphs and remove unused glyphs. Generate font subsets to achieve the purpose of compression\n\n## Install\n\nUsing npm:\n\n```bash\nnpm install font-minify --save-dev\n```\n\n## Usage\n\n```js\nimport fs from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { dirname, join, parse } from 'node:path'\nimport minify from 'font-minify'\n// or use CommonJS\n// const minify = require('font-minify')\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = dirname(__filename)\n\nconst TEST_STRING = `Font-Minify 你说，儿豁中国人不骗中国人`\nconst fontPath = join(__dirname, 'fonts/fontfile.ttf')\nconst buffer = fs.readFileSync(fontPath)\n\n;(async () =\u003e {\n  const ext = 'ttf'\n  const newBuffer = await minify({\n    buffer,\n    text: TEST_STRING,\n    readOptions: {\n      type: ext,\n    },\n    writeOptions: {\n      type: ext,\n    },\n  })\n\n  const fontPath = join(__dirname, 'fonts/fontfile.new.ttf')\n  fs.writeFileSync(fontPath, newBuffer)\n})()\n```\n\nIf you're going to run it in a **browser** and you're going to work with `woff2` fonts, then you should also need `dist/woff2.wasm`, and when you do, you must also pass in the path to the `woff2.wasm` file. Otherwise you can't handle the `woff2` font.\n\n```js\n// example\nimport minify from 'font-minify'\n\nconst newBuffer = await minify({\n  buffer,\n  text: TEST_STRING,\n  wasm: {\n    // The path where you store `woff2.wasm`.\n    woff2: 'woff2.wasm' // If you're using a packaging tool to build your front-end project, then you should put `woff2.wasm` in the `public` directory\n  },\n  readOptions: {\n    type: 'ttf',\n  },\n  writeOptions: {\n    type: 'woff2',\n  },\n})\n```\nIf you're using vite to build your front-end project ([Vite Static Asset Handling](https://vitejs.dev/guide/assets.html))\n```js\n// example\nimport minify from 'font-minify'\nimport woff2Wasm from 'font-minify/woff2Wasm?url'\n\nconst newBuffer = await minify({\n  buffer,\n  text: TEST_STRING,\n  wasm: {\n    woff2: woff2Wasm\n  },\n  readOptions: {\n    type: 'ttf',\n  },\n  writeOptions: {\n    type: 'woff2',\n  },\n})\n```\n\n## License\n\n[MIT](./LICENSE) License © 2024-PRESENT [Lete114](https://github.com/lete114)\n\n\u003c!-- Badges --\u003e\n\n[npm-version-src]: https://img.shields.io/npm/v/font-minify?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[npm-version-href]: https://npmjs.com/package/font-minify\n[npm-downloads-src]: https://img.shields.io/npm/dm/font-minify?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[npm-downloads-href]: https://npmjs.com/package/font-minify\n[bundle-src]: https://img.shields.io/bundlephobia/minzip/font-minify?style=flat\u0026colorA=080f12\u0026colorB=1fa669\u0026label=minzip\n[bundle-href]: https://bundlephobia.com/result?p=font-minify\n[license-src]: https://img.shields.io/github/license/lete114/font-minify.svg?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[license-href]: https://github.com/lete114/font-minify/blob/main/LICENSE\n[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[jsdocs-href]: https://www.jsdocs.io/package/font-minify\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flete114%2Ffont-minify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flete114%2Ffont-minify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flete114%2Ffont-minify/lists"}