{"id":14968203,"url":"https://github.com/tomeraberbach/postcss-fontpie","last_synced_at":"2025-04-09T12:08:54.045Z","repository":{"id":169144638,"uuid":"640364186","full_name":"TomerAberbach/postcss-fontpie","owner":"TomerAberbach","description":"A PostCSS plugin for optimizing font loading layout shifts using fontpie!","archived":false,"fork":false,"pushed_at":"2024-10-15T03:43:53.000Z","size":1487,"stargazers_count":51,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-06T03:58:55.890Z","etag":null,"topics":["cls","css","fontpie","fonts","npm-module","npm-package","postcss","postcss-plugin"],"latest_commit_sha":null,"homepage":"https://npm.im/postcss-fontpie","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TomerAberbach.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"contributing.md","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,"publiccode":null,"codemeta":null}},"created_at":"2023-05-13T20:53:47.000Z","updated_at":"2024-10-15T03:40:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"d70e16f4-1701-48ea-adaa-07fe5498b3ee","html_url":"https://github.com/TomerAberbach/postcss-fontpie","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":"0.030303030303030276","last_synced_commit":"02a2c0fe98388b546b89efec9d098c30b1d0f7f7"},"previous_names":["tomeraberbach/postcss-fontpie"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Fpostcss-fontpie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Fpostcss-fontpie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Fpostcss-fontpie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Fpostcss-fontpie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomerAberbach","download_url":"https://codeload.github.com/TomerAberbach/postcss-fontpie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036067,"owners_count":21037092,"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":["cls","css","fontpie","fonts","npm-module","npm-package","postcss","postcss-plugin"],"created_at":"2024-09-24T13:39:31.611Z","updated_at":"2025-04-09T12:08:54.022Z","avatar_url":"https://github.com/TomerAberbach.png","language":"TypeScript","funding_links":["https://github.com/sponsors/TomerAberbach"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  postcss-fontpie\n\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://npmjs.org/package/postcss-fontpie\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/npm/v/postcss-fontpie\" alt=\"version\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/TomerAberbach/postcss-fontpie/actions\"\u003e\n    \u003cimg src=\"https://github.com/TomerAberbach/postcss-fontpie/workflows/CI/badge.svg\" alt=\"CI\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/sponsors/TomerAberbach\"\u003e\n    \u003cimg src=\"https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=%23fe8e86\" alt=\"Sponsor\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  A \u003ca href=\"https://github.com/postcss/postcss\"\u003ePostCSS\u003c/a\u003e plugin for optimizing font loading layout shifts using \u003ca href=\"https://github.com/pixel-point/fontpie\"\u003e\u003ccode\u003efontpie\u003c/code\u003e\u003c/a\u003e!\n\u003c/div\u003e\n\n## Features\n\n- **Automated:** Generates fallback font metrics to match any custom web font!\n- **Flexible:** Handles font type (sans serif, serif, and monospace), weight,\n  and style\n- **Robust:** Powered by the superb\n  [`fontpie`](https://github.com/pixel-point/fontpie)\n\n## Install\n\n```sh\n$ npm i postcss-fontpie\n```\n\n## Usage\n\n**input.css**\n\n```css\n@font-face {\n  font-family: 'Noto Serif';\n  font-weight: 400;\n  font-style: italic;\n  font-display: swap;\n  src: url(NotoSerif-Italic.ttf) format('ttf');\n}\n\n@font-face {\n  font-family: 'Roboto';\n  font-weight: 400;\n  font-style: normal;\n  font-display: swap;\n  src: url(Roboto-Regular.ttf) format('ttf');\n}\n\n@font-face {\n  font-family: 'Ubuntu Mono';\n  font-weight: 700;\n  font-style: normal;\n  font-display: swap;\n  src: url(UbuntuMono-Bold.ttf) format('ttf');\n}\n```\n\n**index.js:**\n\n```js\nimport fs from 'node:fs/promises'\nimport { join } from 'node:path'\nimport postcss from 'postcss'\nimport postcssFontpie from 'postcss-fontpie'\n\nconst inputPath = `input.css`\nconst inputCss = await fs.readFile(inputPath, `utf8`)\n\nconst outputPath = `output.css`\nconst outputCss = (\n  await postcss([\n    postcssFontpie({\n      // A mapping from `font-family` to its font type (`sans-serif`, `serif`, or `mono`).\n      fontTypes: {\n        'Noto Serif': `serif`,\n        Roboto: `sans-serif`,\n        'Ubuntu Mono': `mono`,\n      },\n\n      // An optional function that transforms a font face to a path to the font\n      // file.\n      resolveFilename: fontFace =\u003e join(`./path/to/fonts`, fontFace.src),\n    }),\n  ]).process(css, { from: inputPath, to: outputPath })\n).css\nawait fs.writeFile(outputPath, outputCss)\n```\n\n**output.css**:\n\n```css\n@font-face {\n  font-family: 'Noto Serif Fallback';\n  font-style: italic;\n  font-weight: 400;\n  src: local(Times New Roman Italic);\n  ascent-override: 91.94%;\n  descent-override: 25.2%;\n  line-gap-override: 0%;\n  size-adjust: 116.25%;\n}\n\n@font-face {\n  font-family: 'Noto Serif';\n  font-weight: 400;\n  font-style: italic;\n  font-display: swap;\n  src: url(NotoSerif-Italic.ttf) format('ttf');\n}\n\n@font-face {\n  font-family: 'Roboto Fallback';\n  font-style: normal;\n  font-weight: 400;\n  src: local(Arial);\n  ascent-override: 92.49%;\n  descent-override: 24.34%;\n  line-gap-override: 0%;\n  size-adjust: 100.3%;\n}\n\n@font-face {\n  font-family: 'Roboto';\n  font-weight: 400;\n  font-style: normal;\n  font-display: swap;\n  src: url(Roboto-Regular.ttf) format('ttf');\n}\n\n@font-face {\n  font-family: 'Ubuntu Mono Fallback';\n  font-style: normal;\n  font-weight: 700;\n  src: local(Courier New Bold);\n  ascent-override: 99.62%;\n  descent-override: 20.4%;\n  line-gap-override: 0%;\n  size-adjust: 83.32%;\n}\n\n@font-face {\n  font-family: 'Ubuntu Mono';\n  font-weight: 700;\n  font-style: normal;\n  font-display: swap;\n  src: url(UbuntuMono-Bold.ttf) format('ttf');\n}\n```\n\nThe plugin can also be used in `postcss.config.js`. See\n[`fontpie`](https://github.com/pixel-point/fontpie) for font format support and\nbrowser compatibility.\n\n## Contributing\n\nStars are always welcome!\n\nFor bugs and feature requests,\n[please create an issue](https://github.com/TomerAberbach/postcss-fontpie/issues/new).\n\nFor pull requests, please read the\n[contributing guidelines](https://github.com/TomerAberbach/postcss-fontpie/blob/main/contributing.md).\n\n## License\n\n[Apache License 2.0](https://github.com/TomerAberbach/postcss-fontpie/blob/main/license)\n\nThis is not an official Google product.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomeraberbach%2Fpostcss-fontpie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomeraberbach%2Fpostcss-fontpie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomeraberbach%2Fpostcss-fontpie/lists"}