{"id":17231981,"url":"https://github.com/pushfoo/fontknife","last_synced_at":"2025-04-14T01:53:25.608Z","repository":{"id":63893513,"uuid":"527800191","full_name":"pushfoo/Fontknife","owner":"pushfoo","description":"Rasterize only the glyphs you need. Cut out everything else.","archived":false,"fork":false,"pushed_at":"2025-02-23T04:45:16.000Z","size":430,"stargazers_count":5,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T01:53:12.366Z","etag":null,"topics":[],"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/pushfoo.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":"2022-08-23T02:12:18.000Z","updated_at":"2025-02-23T04:45:19.000Z","dependencies_parsed_at":"2024-05-12T01:27:28.591Z","dependency_job_id":"b080f66c-3d03-4217-b00f-35626af5906c","html_url":"https://github.com/pushfoo/Fontknife","commit_stats":{"total_commits":203,"total_committers":3,"mean_commits":67.66666666666667,"dds":"0.054187192118226646","last_synced_commit":"4979a00576c890d70763de055f8bf0b90a57c239"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushfoo%2FFontknife","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushfoo%2FFontknife/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushfoo%2FFontknife/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushfoo%2FFontknife/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pushfoo","download_url":"https://codeload.github.com/pushfoo/Fontknife/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248809032,"owners_count":21164895,"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":[],"created_at":"2024-10-15T05:00:12.003Z","updated_at":"2025-04-14T01:53:25.590Z","avatar_url":"https://github.com/pushfoo.png","language":"Python","readme":"# Fontknife\n[![License](https://img.shields.io/badge/License-BSD_3-Clause.svg)](https://opensource.org/licenses/BSD-3-Clause)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://makeapullrequest.com)\n[![Tests (main)](https://github.com/pushfoo/Fontknife/actions/workflows/test.yaml/badge.svg?branch=main)](https://github.com/pushfoo/Fontknife/actions/workflows/test.yaml?branch=main)\n[![Documentation (main)](https://readthedocs.org/projects/fontknife/badge/?version=main)](https://fontknife.readthedocs.io/en/main/?badge=main)\n[![Documentation (stable)](https://readthedocs.org/projects/fontknife/badge/?version=stable)](https://fontknife.readthedocs.io/en/stable/?badge=stable)\n\n\n**Q**: How do I convert a font into a sprite sheet?\u003cbr/\u003e\n**A**: `fontknife convert`\n\n| Goal                            |                                  End Result                                  | Command                                                                |\n|---------------------------------|:----------------------------------------------------------------------------:|------------------------------------------------------------------------|\n| Rasterize a font's ASCII glyphs |            ![Tom Thumb's ASCII Characters](./docs/tom-thumb.png)             | `fontknife convert supported.font spritesheet.png`                     |\n| Generate filler assets          | ![The cool sunglasses and flexed bicep emoji as a png](./docs/flex_cool.png) | `fontknife convert -P 48 -G \"💪😎\" NotoEmoji-Regular.ttf arm_cool.png` |\n\nFor more detailed explanations, see [Practical Examples](#practical-examples).\n\n## Install Instructions\n\n### Users\n\nIf you only want to convert fonts, follow these steps:\n\n1. Have [Python](https://python.org) 3.9+ installed\n2. Make sure you've [created](https://docs.python.org/3/library/venv.html#creating-virtual-enviroments)\n   and [activated](https://docs.python.org/3/library/venv.html#how-venvs-work)\n   a virtual environment (or use [pipx](https://pypa.github.io/pipx/))\n3. `pip install`\n4. Run `fontknife convert --help`\n\nIf the last command prints help text, you're ready to go! Read it for more information about supported features.\n\n### Developers / Contributors\n\nSee [CONTRIBUTING.md](https://github.com/pushfoo/fontknife/blob/master/CONTRIBUTING.md).\n\n## Current Features\n\n* Read multiple font formats (TTF, BDF, PCF, 1-bit sprite sheets)\n* Read arbitrary unicode glyphs from supported fonts, including\n  [multi-character emoji](https://unicode.org/emoji/charts/emoji-zwj-sequences.html)\n* Export 1-bit sprite sheets to multiple image formats (PNG, BMP, JPG)\n* Guess common formats from file extensions\n* Simpler than GUI font editors\n* Can be used as a library in custom Python scripts\n* Assembly code generation (Partial support for [Octo](https://github.com/JohnEarnest/Octo))\n\nPlease remember:\n\n1. This is alpha quality software, so there will be bugs and breaking changes\n2. The [Future Features](#future-features) section lists known areas for improvements\n3. The project accepts [pull requests](https://github.com/pushfoo/fontknife/pulls)\n\n\n## Why did you make this?\n\n1. It helps developers [iterate faster](https://www.youtube.com/watch?v=rDjrOaoHz9s).\n2. A refactor of an abandoned projected turned into something else.\n\n## Practical Examples\n\n### 1. Export Specific Glyphs / Make Game Assets\n\n**Scenario**: You need filler assets for a farming game, ASAP.\u003cbr/\u003e\n**Solution**:\n\n1. Download an appropriately licensed emoji font, such as\n[Noto Emoji](https://fonts.google.com/noto/specimen/Noto+Emoji),\n2. Run the following command\n    ```commandline\n    fontknife convert -P 48 -G \"🌽🍇🍎🍏🫐🍓🍒🍐🍅🥕🥔🥒🍑🥑🧅🍈\" NotoEmoji-Regular.ttf fruits_and_veggies.png\n    ```\n3. Double check \u0026 color the results with your preferred image editor\n\n   ![Fruit and vegetable emoji exported as a PNG sprite sheet](./docs/fruits_and_veggies.png)\n\n### 3. Generate Octo Assembly\n\n_Note: This feature is mostly broken legacy code inherited from\nan earlier project._\n\nYou can generate a width table and sprite data table as valid\n[Octo](https://github.com/JohnEarnest/Octo) source if your font meets\nthe following requirements:\n\n1. All glyphs can render as 8px x 8px or smaller\n2. There are 256 or fewer glyphs in the font\n\nFor example, run the following to generate tables of widths and sprite data\nfor [Tom Thumb](https://robey.lag.net/2010/01/23/tiny-monospace-font.html)\nas Octo source:\n\n```commandline\nfontknife emit-code tom-thumb.bdf tom-thumb.8o\n```\n\nThe data tables should be usable, but the attached drawing routines are not:\n\n1. Their underlying logic is broken\n2. They predate Octo's idiomatic [`:stringmode` macro](http://johnearnest.github.io/Octo/docs/Manual.html#strings)\n\n\n## Future features\n\nFeatures in this section will be added if:\n\n1. A PR is made addressing it\n2. I have time / interest\n\nThe features below are in descending order, from highest to lowest priority:\n\n| Feature                                                        | Questions / Blockers                 | Easiest known approach                                                        |\n|----------------------------------------------------------------|--------------------------------------|-------------------------------------------------------------------------------|\n| Better documentation                                           |                                      | Sphinx + RTD, in progress                                                     |\n| Fix automatic sheet sizing                                     |                                      |                                                                               |\n| Export with transparent background color                       | Outline detection                    | Improve cli color parsing, replace `#000` default with `#0000`                |\n| Add foreground color control                                   |                                      | Same as above                                                                 |\n| Export to folder of files per glyph                            | File naming                          | Use the unicode [code point](https://en.wikipedia.org/wiki/Code_point)        |\n| Support for automatically reading TTF glyph tables             |                                      | Use [fonttools](https://github.com/fonttools/fonttools) to read the TTF table |\n| Fix ugly caching behavior                                      |                                      | Delete / disable caching entirely                                             |\n| Better scaling flags, including downsampling                   |                                      | Recommend imagemagick or image editors                                        |\n| Additional font formats (see [Future Formats](#future-formats) |                                      | Time / interest                                                               |\n| C header code generation                                       |                                      | Time / interest                                                               |\n| Refactor or remove Octo generation                             |                                      | Move it to a downstream project                                               |\n| Better interface for glyph subset selection                    | Good design unclear                  | Write doc on using fontknife in scripts                                       |\n| Color TTF support                                              | Pillow has bad support for color TTF | Unknown, help welcome!                                                        |\n\n### Future Formats\n\nPotential font formats to support:\n\n* [FNT](https://web.archive.org/web/20110513200924/http://support.microsoft.com/kb/65123) and other old Windows formats\n* [UXF](https://wiki.xxiivv.com/site/ufx_format.html)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpushfoo%2Ffontknife","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpushfoo%2Ffontknife","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpushfoo%2Ffontknife/lists"}