{"id":13648241,"url":"https://github.com/bdusell/webfont-generator","last_synced_at":"2025-07-14T05:35:28.127Z","repository":{"id":24869953,"uuid":"28285637","full_name":"bdusell/webfont-generator","owner":"bdusell","description":"Locally convert fonts to web formats and generate CSS rules","archived":false,"fork":false,"pushed_at":"2019-12-28T02:26:34.000Z","size":52,"stargazers_count":194,"open_issues_count":5,"forks_count":35,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-06-12T11:02:53.190Z","etag":null,"topics":["eot","font-converter","font-face","font-face-generator","fontforge","fonts","sfntly","svg-font","ttf","woff","woff2"],"latest_commit_sha":null,"homepage":"","language":"Python","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/bdusell.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}},"created_at":"2014-12-21T02:12:36.000Z","updated_at":"2025-05-25T14:37:10.000Z","dependencies_parsed_at":"2022-07-27T16:33:28.197Z","dependency_job_id":null,"html_url":"https://github.com/bdusell/webfont-generator","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/bdusell/webfont-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fwebfont-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fwebfont-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fwebfont-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fwebfont-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bdusell","download_url":"https://codeload.github.com/bdusell/webfont-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fwebfont-generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265246012,"owners_count":23734109,"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":["eot","font-converter","font-face","font-face-generator","fontforge","fonts","sfntly","svg-font","ttf","woff","woff2"],"created_at":"2024-08-02T01:04:04.935Z","updated_at":"2025-07-14T05:35:27.847Z","avatar_url":"https://github.com/bdusell.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Web Font Generator\n------------------\n\nOne font goes in, all web fonts come out.\n\nThe purpose of this tool is to automate the generation of web-friendly font\nformats and `@font-face` CSS rules from arbitrary font files, without having to\nrely on web services or otherwise requiring a network connection. This tool can\ngenerate inline data URLs if needed.\n\nSee the\n[Using @font-face article](http://css-tricks.com/snippets/css/using-font-face/)\non CSS-Tricks.com for more information about maximizing embedded font\ncompatibility.\n\nQuickstart\n----------\n\n```sh\n./setup # Fetch and build third-party libraries\n./bin/generate-webfonts MyFont.ttf -o assets/ # Convert a font\n```\n\nUsage\n-----\n\nThe driver script is `generate-webfonts`. At its most basic, it accepts a font\nfile as its argument and spits out all of the converted fonts to a directory.\nIt can also generate CSS for the appropriate `@font-face` rule as well.\n\n    ./bin/generate-webfonts -o assets MyFont.ttf --css MyFont.css\n\nThe command above, which uses the default output formats, generates the\nfollowing files:\n\n* `MyFont.css`\n* `assets/MyFont.woff`\n* `assets/MyFont.woff2`\n* `assets/MyFont.ttf`\n* `assets/MyFont.eot`\n* `assets/MyFont.svg`\n\nThe file `MyFont.css` will contain the following:\n\n```css\n@font-face {\n  font-family: 'MyFont';\n  src: url('assets/MyFont.eot');\n  src: url('assets/MyFont.eot?#iefix') format('embedded-opentype'),\n       url('assets/MyFont.woff2') format('woff2'),\n       url('assets/MyFont.woff') format('woff'),\n       url('assets/MyFont.ttf') format('truetype'),\n       url('assets/MyFont.svg#MyFont') format('svg');\n}\n```\n\nConceptually, given a list of input files and a list of output formats, the\nconverter will attempt to satisfy all output format requirements by copying\nmatching input files and converting files to fill in the gaps. Because of\nlimitations in the underlying font converters, some intermediate formats not\nrequested may be generated.\n\nThe command will avoid generating a file in a certain output format if a file\nmatching that format is already listed as one of the inputs. In this case, the\ninput file will simply be copied to the destination directory (or left alone,\nif it is already in the output directory). If such a file is not listed in the\narguments, it will be overwritten with a newly converted file, even if it\nalready exists in the output directory.\n\nSee the options below for more advanced usage.\n\nSyntax\n------\n\nThe script `bin/generate-webfonts` accepts a list of font files as input and a\nnumber of options:\n\n### `-o --output`\n\nDestination directory for converted files. Even if only inline\nfonts are generated, a destination directory is needed to hold\nintermediate files.\n\n### `-f --format`\n\nComma-separated list of output formats. Possible formats are:\n\n* ttf\n* woff\n* woff2\n* eot\n* svg\n* otf\n\nAny format suffixed with `:inline` will cause the font to be\ninlined in the CSS file as a base64-encoded data URL, rather\nthan a URL to a file.\n\nThe default format list is `eot,woff2,woff,ttf,svg`.\n\n### `-c --css`\n\nPath for the generated CSS file. Use `-` for stdout. If omitted, no CSS is\ngenerated.\n\n### `-p --prefix`\n\nPrefix of the font paths used in the generated CSS. For example, if your\nstylesheet is served from `css/` and your fonts are served from `fonts/`, then\nyou will want to set the prefix to `../fonts/`. The default prefix is the name\nof the output directory.\n\n### `--font-family`\n\nName of the font family used in the CSS file. Default is the\nbase name of the first input file.\n\n### `--verbose`\n\nShow verbose output while running.\n\n### `-v --version`\n\nDisplay version.\n\nSupported Formats\n-----------------\n\n`generate-webfonts` supports the following font formats:\n\n* ttf\n* woff\n* woff2\n* eot\n* svg\n* otf\n\nIt can convert to and from any of the formats listed above, with one\nexception: it cannot convert eot to other formats.\n\nThird-party Tools\n-----------------\n\nThe generator leverages three third-party libraries/tools for converting fonts.\nSince no single tool supports all font formats, the generator's job is to\nfigure out a good chain of converters to use to convert between any two font\nformats. Under the hood, it's actually implemented as a shortest-paths problem\non a dependency graph.\n\nThe third-party tools used are:\n\n* [FontForge](http://fontforge.github.io/en-US/), a free, general-purpose, and\n  scriptable font editor program\n* [sfntly](https://code.google.com/p/sfntly/) by Google, an open-source Java\n  library which once powered Google Fonts\n* Google's [woff2 converter](https://github.com/google/woff2)\n\nFontForge supports reading and generating a good number of font formats,\nalthough it has no support for the eot or woff2 formats. The blazingly fast\nsfntly library can convert ttf fonts to eot or woff, covering one of these\ngaps. The woff2 converter from Google is also used to convert between the\nwoff2 and ttf formats.\n\nSetup\n-----\n\nAs mentioned above, run `./setup` to download and build the third-party\nlibraries. Running `./setup` will check out the sfntly and woff2 converter\nrepositories locally where `generate-webfonts` can find them. Install\nFontForge using your package manager or directly from their\n[website](http://fontforge.github.io/en-US/).\n\nThe setup process assumes a \\*nix environment. There is currently no support\nfor setting up this tool on Windows.\n\nThe following commands are required to run the setup script:\n* `git`\n* `java` and `javac`\n* `mvn` (Maven)\n\nThe `generate-webfonts` script itself requires Python 3.\n\nClosing Thoughts\n----------------\n\nPlease convert responsibly! Respect font creators' copyrights.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdusell%2Fwebfont-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbdusell%2Fwebfont-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdusell%2Fwebfont-generator/lists"}