{"id":43074720,"url":"https://github.com/forthgoing/subfont","last_synced_at":"2026-01-31T14:00:57.991Z","repository":{"id":334491440,"uuid":"1141725188","full_name":"forthgoing/subfont","owner":"forthgoing","description":"Subfont is an Astro drag-and-drop integration that automatically subsets your web fonts to include only the characters actually used on your pages.","archived":false,"fork":false,"pushed_at":"2026-01-25T15:41:21.000Z","size":9216,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-25T18:58:05.535Z","etag":null,"topics":["astro","font","lighthouse","optimization","performance","rust","speed","subset","web"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/forthgoing.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,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-25T10:15:07.000Z","updated_at":"2026-01-25T15:46:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/forthgoing/subfont","commit_stats":null,"previous_names":["forthgoing/subfont"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/forthgoing/subfont","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forthgoing%2Fsubfont","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forthgoing%2Fsubfont/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forthgoing%2Fsubfont/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forthgoing%2Fsubfont/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/forthgoing","download_url":"https://codeload.github.com/forthgoing/subfont/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forthgoing%2Fsubfont/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28944789,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T13:02:32.153Z","status":"ssl_error","status_checked_at":"2026-01-31T13:00:07.528Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["astro","font","lighthouse","optimization","performance","rust","speed","subset","web"],"created_at":"2026-01-31T14:00:57.219Z","updated_at":"2026-01-31T14:00:57.983Z","avatar_url":"https://github.com/forthgoing.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca id=\"readme-top\"\u003e\u003c/a\u003e\n\n![Build the web you want](.github/assets/banner.jpg \"Build the web you want\")\n\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ch3 align=\"center\"\u003eSubfont - Ultra-optimized font subsetting for Astro\u003c/h3\u003e\n  \u003cp align=\"center\"\u003e\n    Automatically subset, compress, and optimize your local fonts - dramatically smaller font files, faster paint times, better Lighthouse scores.\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/forthgoing/subfont\"\u003e\u003cstrong\u003eExplore the docs\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/forthgoing/subfont/issues/new?labels=bug\u0026template=bug-report.md\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/forthgoing/subfont/issues/new?labels=enhancement\u0026template=feature-request.md\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![npm version](https://img.shields.io/npm/v/@forthgoing/subfont?logo=npm\u0026logoColor=white\u0026color=CB3837)](https://www.npmjs.com/package/@forthgoing/subfont)\n[![Astro version compatibility](https://img.shields.io/badge/Astro-4.x+-FF5A03?logo=astro\u0026logoColor=white)](https://astro.build)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Stars](https://img.shields.io/github/stars/forthgoing/subfont?color=orange)](https://github.com/forthgoing/subfont)\n\n\u003c/div\u003e\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003cdetails\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#key-features\"\u003eKey Features\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#what-makes-it-stand-out\"\u003eWhat Makes It Stand Out\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#prerequisites\"\u003ePrerequisites\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#configuration\"\u003eConfiguration\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#how-it-works\"\u003eHow It Works\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n## About The Project\n\n**Subfont** is a powerful **Astro integration** that takes your local fonts (TTF, OTF, WOFF2) in `/src/assets/fonts`, analyzes **all actual text content** across your `.astro`, `.md`, `.mdx`, `.ts`, etc. files, and generates **WOFF2 subsets** with only the text you use.\n\nThe result? Fonts that are **often 70-95% smaller** than the originals, with zero visual difference, leading to faster page loads, lower data usage (especially on mobile), improved **Largest Contentful Paint (LCP)**, and significantly better **Lighthouse / Core Web Vitals** scores.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n### Key Features\n\n- **Only includes glyphs actually used in your site**\n- **Automatic WOFF2 conversion \u0026 compression** (TTF/OTF → highly optimized WOFF2)\n- **Original font source files** - Keeps your original fonts saved so when you use more characters in your site it automatically gets added to the optimized fonts.\n- **Variable font support**\n- **Smart caching** - only re-processes changed fonts or when content changes\n- **Font manifest generation**\n- **Full control of your fonts** Preload, display, alias, etc..\n- **Duplicate \u0026 symlink protection**\n\n### What Makes Subfont Stand Out\n\nMost font optimization tools either:\n\n- Require manual unicode-range lists\n- Depend on Google Fonts / external services\n- Don't update subsets when content changes\n- Rely on bloated python scripts or wrappers like `glyphhanger`\n\n**@forthgoing/subfont** stands out because it:\n\n- **Core fully built in Rust**.\n- **Fast and lightweight**\n- **Fully configurable**\n- **Keeps your original font files for updating your optimized fonts**\n- **Doesn't require installing anything extra**\n- **Caches intelligently using content hash + font hash + version**\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n## Getting Started\n\n### Prerequisites\n\nRequires:\n\n- Node 18+\n- Astro 4+\n- Fonts in `/src/assets/fonts`\n\nSupported source formats:\n\n- `.ttf`\n- `.otf`\n- `.woff2`\n\nWOFF is not supported and will be skipped gracefully.\n\n---\n\n## Installation\n\n1. Add the dependency:\n\n```sh\nnpm install @forthgoing/subfont\n# or\npnpm add @forthgoing/subfont\n# or\nyarn add @forthgoing/subfont\n```\n\n2. Add the plugin to `astro.config.(ts|js|mjs)`:\n\n```typescript\nimport subfont from \"@forthgoing/subfont\";\n\nexport default defineConfig({\n  integrations: [subfont()],\n});\n```\n\n3. Import tags into your `Layout.astro`:\n\n```javascript\nimport SubfontHead from \"forthgoing:subfont/head\";\nimport SubfontBody from \"forthgoing:subfont/body\";\n```\n\nUsage inside `Layout.astro`:\n\n```html\n\u003chead\u003e\n  \u003cmeta charset=\"utf-8\" /\u003e\n  \u003cSubfontHead /\u003e\n  \u003c!--- other head content---\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cSubfontBody /\u003e\n  ...\n\u003c/body\u003e\n```\n\n4. Place your fonts in `src/assets/fonts`:\n\n```\nsrc/assets/fonts/\n├── Inter-Regular.ttf\n├── Inter-Italic.ttf\n├── PragmataPro.woff2\n└── MyCustomFont-Variable.ttf\n```\n\n## Usage\n\nAfter setup, just run `npm run dev` or `npm run build`\n\nAnd use your font normally:\n\n```\nh1 {\n    font-family: 'InterRegular',\n}\n```\n\n## Configuration\n\n### Subfont config `subfont.config.ts`\n\nCreate this file at the root of your project.\n\n```typescript\n\nimport type { SubfontConfig } from \"@forthgoing/subfont\";\n\nconst config: SubfontConfig = {\n  inter: {\n    alias: \"Inter\",\n    display: \"swap\",\n    weight: \"100 900\",\n    tagPlacement: \"head\",      // \"head\" | \"body\"\n    stylePlacement: \"head\",\n    preload: true,\n  },\n  pragma: {\n    tagPlacement: \"head\",\n    weight: \"100 900\",\n    stylePlacement: \"head\",\n  },\n  // Add more font families...\n};\n\nexport default config;\n\n```\n\n### Plugin options `astro.config.ts`\n\n```typescript\nsubfont({\n  assetsFolder: \"src/assets\",      // default\n  fontsSubdir: \"fonts\",            // default = \"fonts\"\n  hashFonts: true,                 // append content hash to filename (great for caching)\n})\n```\n\n## How it works\n\n1. Scans all source files and collects used characters\n2. Computes content hash\n3. For each font:\n\n- Checks cache\n- Subsets to only used glyphs\n- Converts to WOFF2\n- Keeps your original fonts\n- Removes old variants\n\n4. Injects `\u003clink rel=\"preload\"\u003e`, `@font-face` via SubfontHead / SubfontBody\n\n## Contributing\n\nContributions are welcome!\n\n1. Fork the project\n2. Create your feature branch\n3. Commit your changes\n4. Push to the branch\n5. Open a pull request\n\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforthgoing%2Fsubfont","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforthgoing%2Fsubfont","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforthgoing%2Fsubfont/lists"}