{"id":26601150,"url":"https://github.com/fetten/woff2base64","last_synced_at":"2025-06-30T07:33:06.308Z","repository":{"id":57398802,"uuid":"80120486","full_name":"Fetten/woff2base64","owner":"Fetten","description":"Generates CSS with woff2 and woff fonts embedded as Base64","archived":false,"fork":false,"pushed_at":"2020-07-17T10:21:50.000Z","size":2161,"stargazers_count":12,"open_issues_count":1,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-20T17:54:42.223Z","etag":null,"topics":["base64","css","fonts","nodejs","npm","npm-package","woff","woff-fonts","woff2"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/Fetten.png","metadata":{"files":{"readme":"Readme.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-26T14:15:56.000Z","updated_at":"2025-01-24T10:36:38.000Z","dependencies_parsed_at":"2022-09-12T04:42:15.164Z","dependency_job_id":null,"html_url":"https://github.com/Fetten/woff2base64","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Fetten/woff2base64","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fetten%2Fwoff2base64","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fetten%2Fwoff2base64/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fetten%2Fwoff2base64/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fetten%2Fwoff2base64/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fetten","download_url":"https://codeload.github.com/Fetten/woff2base64/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fetten%2Fwoff2base64/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262731703,"owners_count":23355402,"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":["base64","css","fonts","nodejs","npm","npm-package","woff","woff-fonts","woff2"],"created_at":"2025-03-23T18:37:36.542Z","updated_at":"2025-06-30T07:33:06.261Z","avatar_url":"https://github.com/Fetten.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# woff2base64\n\nGenerates CSS font-face with woff2 and woff fonts embedded as base64.\n\n[![Build Status](https://travis-ci.org/Fetten/woff2base64.svg?branch=master)](https://travis-ci.org/Fetten/woff2base64)\n\n## Installation\n\n```\nnpm install --save woff2base64\n```\n\n## Usage\n\nwoff2base64 automatically looks up the font-weight and font-style in the given font filename (case-insensitive). \nAll [possible css values](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight) are supported.\n\nIf your font's filename contains the word _regular_, the font-weight will be set to `normal`.\n\nHowever, if you cannot change the font's filename, you can pass the weight and style for each font via \nthe `font` parameter (see below).\n\n```js\nimport fs from 'fs';\nimport woff2base64 from 'woff2base64';\nconst fonts = {\n    'Roboto-Bold.woff2': fs.readFileSync('fonts/Roboto/Roboto-Bold.woff2'),\n    'Roboto-Bold.woff':  fs.readFileSync('fonts/Roboto/Roboto-Bold.woff'),\n\t// ...\n};\nconst options = {\n    fontFamily: 'Roboto'\n};\nconst css = woff2base64(fonts, options);\n// css.woff2 = '@font-face{font-family:\"Roboto\";src:url(data:application/font-woff2;charset=utf-8;base64,...'\n// css.woff  = '@font-face{font-family:\"Roboto\";src:url(data:application/font-woff;charset=utf-8;base64,...'\n\nfs.writeFileSync('build/roboto.woff2.css', css.woff2);\nfs.writeFileSync('build/roboto.woff.css', css.woff);\n```\n\n## Parameters\n\nwoff2base64 accepts two objects: `fonts` and `options`.\n\n### fonts (required)\n\nUse woff2 and woff filenames as keys.\n\nThe value can either be a `String` containing the file content, \na `Buffer` containing the file content or an `Object`, allowing you to pass font-specific options:\n\n```js\nconst fonts = {\n    'Roboto-BoldItalic.woff2': {\n        content: fs.readFileSync('fonts/Roboto/Roboto-BoldItalic.woff2'),\n        weight: 'bold',\n        style: 'italic'\n    },\n    'Roboto-Bold.woff2': {\n        content: fs.readFileSync('fonts/Roboto/Roboto-Bold.woff2'),\n        weight: 'bold',\n        style: 'normal'\n    },\n    'Roboto-Regular.woff2': fs.readFileSync('fonts/Roboto/Roboto-Bold.woff2'),\n};\n```\n\n### Options\n\n#### fontFamily (required)\n\nThe name of the Font Family used in css.\n\nType: `String`\n\n\n#### fontFaceTemplate\n\nThe Template used to generate the css. \nUsed with Lodash's [_.template](https://lodash.com/docs/#template).\n\nType: `String`\n\nDefault:\n```\n@font-face{ font-family:\"\u003c%=family%\u003e\";src:url(\u003c%=uri%\u003e) format(\"\u003c%=format%\u003e\");font-weight:\u003c%=weight%\u003e;font-style:\u003c%=style%\u003e;}\n```\n\n#### fontUriTemplate\n\nThe Template used to generate the base64 encoded data uri. \nUsed with Lodash's [_.template](https://lodash.com/docs/#template).\n\nType: `String`\n\nDefault:\n```\ndata:\u003c%=mime%\u003e;charset=utf-8;base64,\u003c%=base64%\u003e\n```\n\n#### banner\n\nA banner that gets prepended to generated css files.\nSet to `''` to disable banner. \n\nType: `String`\n\n\n## Resources\n\n* Convert your ttf fonts to woff2 and woff with [Font Squirrel’s Webfont Generator](http://www.fontsquirrel.com/tools/webfont-generator).\n\n* See the current browser support for woff2 and woff fonts on [canisue.com](http://caniuse.com/#search=woff).\n\n* Why would you need this? Read [Better webfont loading with using localStorage and providing WOFF2 support](http://bdadam.com/blog/better-webfont-loading-with-localstorage-and-woff2.html) \nby Adam Beres-Deak.\n\n* This package is based on [fontoptim by Artem Sapegin](https://github.com/sapegin/fontoptim) with\nimprovements for font-style and font-weight recognition.\n\n## License\nReleased under the [MIT license](License.md).\n\nCopyright (c) 2017 Marcel Fetten. All rights reserved. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffetten%2Fwoff2base64","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffetten%2Fwoff2base64","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffetten%2Fwoff2base64/lists"}