{"id":16125673,"url":"https://github.com/dy/add-font","last_synced_at":"2025-10-06T14:13:15.628Z","repository":{"id":57173145,"uuid":"66524223","full_name":"dy/add-font","owner":"dy","description":"Attach font to the page by url or from array buffer","archived":false,"fork":false,"pushed_at":"2017-04-14T16:41:48.000Z","size":12,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-20T17:48:23.936Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dy.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-25T04:19:24.000Z","updated_at":"2021-06-30T08:34:24.000Z","dependencies_parsed_at":"2022-08-24T13:31:01.841Z","dependency_job_id":null,"html_url":"https://github.com/dy/add-font","commit_stats":null,"previous_names":["dfcreative/add-font"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dy/add-font","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fadd-font","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fadd-font/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fadd-font/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fadd-font/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dy","download_url":"https://codeload.github.com/dy/add-font/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fadd-font/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278621885,"owners_count":26017260,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-10-09T21:30:35.249Z","updated_at":"2025-10-06T14:13:15.576Z","avatar_url":"https://github.com/dy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# add-font [![unstable](http://badges.github.io/stability-badges/dist/unstable.svg)](http://github.com/badges/stability-badges)\n\nRegister new font-face for the current web page by URL or from ArrayBuffer.\n\n[![npm install add-font](https://nodei.co/npm/add-font.png?mini=true)](https://npmjs.org/package/add-font/)\n\n```js\nconst addFont = require('add-font');\n\n//CSS URL inserts the \u003clink\u003e to head\naddFont('//cdn.jsdelivr.net/font-hack/2.020/css/hack.min.css');\n\n//Font URL w/o extension inserts eot, woff2, woff, ttf, svg and otf versions\naddFont('//cdn.jsdelivr.net/font-hack/2.020/fonts/eot/latin/hack-regular-latin-webfont',\n\t`font-family: Hack; font-weight: normal;`);\n\n//Font URL with extension inserts only target font file\naddFont('./wavefont.otf', 'wavefont');\n\n//ArrayBuffer will insert raw data as a font\naddFont(myFont.toArrayBuffer(), `font-weight: bold; font-family: my-font-${id};`);\n```\n\n## API\n\n**`addFont(cssUrl)`**\u003cbr/\u003e\n**`addFont(fontUrl, cssString|fontName)`**\u003cbr/\u003e\n**`addFont(fontUrlList, cssString|fontName)`**\u003cbr/\u003e\n**`addFont(arrayBuffer, cssString|fontName)`**\n\nAttach font to the page, apply additional parameters, which are whether font name or `@font-face` properties, eg `font-family: \u003cx\u003e; font-style: \u003cy\u003e; font-weight: \u003cz\u003e`.\n\n## Motivation\n\nThe package is created for [wavefont](https://github.com/dfcreative/wavefont) test.\nIt is here mostly to save arrayBuffer font code snippet.\nIt may be useful for font-related tests or in theory for font design tools.\nFor regular sites for css fonts just insert `\u003clink\u003e`, for specific font use `insert-styles` with `@font-face`.\n\n## Related\n\n* [google-fonts](https://github.com/hughsk/google-fonts) — easy-peasy google fonts by name.\n* [webfontloader](https://github.com/typekit/webfontloader) — solution for all possible font include cases.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fadd-font","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdy%2Fadd-font","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fadd-font/lists"}