{"id":13528208,"url":"https://github.com/mooman219/fontdue","last_synced_at":"2025-05-12T15:22:25.706Z","repository":{"id":38325858,"uuid":"200122012","full_name":"mooman219/fontdue","owner":"mooman219","description":"The fastest font renderer in the world, written in pure rust.","archived":false,"fork":false,"pushed_at":"2025-02-12T10:26:53.000Z","size":36357,"stargazers_count":1513,"open_issues_count":35,"forks_count":76,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-04-23T17:13:24.938Z","etag":null,"topics":["font","opentype","rasterizer","rust","truetype","ui"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mooman219.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2019-08-01T21:34:19.000Z","updated_at":"2025-04-23T11:41:24.000Z","dependencies_parsed_at":"2025-03-04T17:20:39.602Z","dependency_job_id":null,"html_url":"https://github.com/mooman219/fontdue","commit_stats":{"total_commits":262,"total_committers":27,"mean_commits":9.703703703703704,"dds":0.1297709923664122,"last_synced_commit":"c2d634ac9e98c386896acc3d15031c789f786d89"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mooman219%2Ffontdue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mooman219%2Ffontdue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mooman219%2Ffontdue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mooman219%2Ffontdue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mooman219","download_url":"https://codeload.github.com/mooman219/fontdue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250477810,"owners_count":21437049,"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":["font","opentype","rasterizer","rust","truetype","ui"],"created_at":"2024-08-01T06:02:18.548Z","updated_at":"2025-04-23T17:13:32.757Z","avatar_url":"https://github.com/mooman219.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Fontdue\n\n[![Test](https://github.com/mooman219/fontdue/actions/workflows/build.yml/badge.svg)](https://github.com/mooman219/fontdue/actions)\n[![Documentation](https://docs.rs/fontdue/badge.svg)](https://docs.rs/fontdue)\n[![Crates.io](https://img.shields.io/crates/v/fontdue.svg)](https://crates.io/crates/fontdue)\n[![License](https://img.shields.io/crates/l/fontdue.svg)](https://github.com/mooman219/fontdue/blob/master/LICENSE)\n\nFontdue is a simple, `no_std` (does not use the standard library for portability), pure Rust, TrueType (`.ttf/.ttc`) \u0026 OpenType (`.otf`) font rasterizer and layout tool. It strives to make interacting with fonts as fast as possible, and currently has the lowest end to end latency for a font rasterizer.\n\n## Roadmap\n`fontdue` is designed to be a replacement for `rusttype` [(link)](https://gitlab.redox-os.org/redox-os/rusttype), `ab_glyph` [(link)](https://github.com/alexheretic/ab-glyph), parts of `glyph_brush` [(link)](https://github.com/alexheretic/glyph-brush/tree/master/glyph-brush), and `glyph_brush_layout` [(link)](https://github.com/alexheretic/glyph-brush/tree/master/layout). This is a class of font libraries that don't tackle shaping.\n\nIt's unlikely I'll have time to integrate with a shaping library. If you need a more complete font engine you should check out the wonderful [Cosmic Text](https://github.com/pop-os/cosmic-text) project, which is a very complete pure rust text library.\n\nA **non-goal** of this library is to be allocation free and have a fast, \"zero cost\" initial load. This library _does_ make allocations and depends on the `alloc` crate. Fonts are fully parsed on creation and relevant information is stored in a more convenient to access format. Unlike other font libraries, the font structures have no lifetime dependencies since it allocates its own space.\n\n## Example\n\n[Live demo](https://mooman219.github.io/fontdue/). This demo is a web-assembly build of `fontdue` rasterizing to a browser canvas. It provides a side by side of characters being rasterized between `fontdue` and the browser's canvas text api provided with the same parameters.\n\nSome other examples can be found under ./dev/examples.\n\n### Rasterization\nThe rasterization API should not see major changes in the near future.\n```rust\n// Read the font data.\nlet font = include_bytes!(\"../resources/Roboto-Regular.ttf\") as \u0026[u8];\n// Parse it into the font type.\nlet font = fontdue::Font::from_bytes(font, fontdue::FontSettings::default()).unwrap();\n// Rasterize and get the layout metrics for the letter 'g' at 17px.\nlet (metrics, bitmap) = font.rasterize('g', 17.0);\n```\n\n### Layout\nThe layout API is immature and may see breaking changes. The layout `fontdue` provides is naïve and is only designed to be on par with existing libraries like `glyph_brush`.\n```rust\n// Read the font data.\nlet font = include_bytes!(\"../resources/fonts/Roboto-Regular.ttf\") as \u0026[u8];\n// Parse it into the font type.\nlet roboto_regular = Font::from_bytes(font, fontdue::FontSettings::default()).unwrap();\n// The list of fonts that will be used during layout.\nlet fonts = \u0026[roboto_regular];\n// Create a layout context. Laying out text needs some heap allocations; reusing this context\n// reduces the need to reallocate space. We inform layout of which way the Y axis points here.\nlet mut layout = Layout::new(CoordinateSystem::PositiveYUp);\n// By default, layout is initialized with the default layout settings. This call is redundant, but\n// demonstrates setting the value with your custom settings.\nlayout.reset(\u0026LayoutSettings {\n    ..LayoutSettings::default()\n});\n// The text that will be laid out, its size, and the index of the font in the font list to use for\n// that section of text.\nlayout.append(fonts, \u0026TextStyle::new(\"Hello \", 35.0, 0));\nlayout.append(fonts, \u0026TextStyle::new(\"world!\", 40.0, 0));\n// Prints the layout for \"Hello world!\"\nprintln!(\"{:?}\", layout.glyphs());\n\n// If you wanted to attached metadata based on the TextStyle to the glyphs returned in the\n// glyphs() function, you can use the TextStyle::with_metadata function. In this example, the\n// Layout type is now parameterized with u8 (Layout\u003cu8\u003e). All styles need to share the same\n// metadata type.\nlet mut layout = Layout::new(CoordinateSystem::PositiveYUp);\nlayout.append(fonts, \u0026TextStyle::with_user_data(\"Hello \", 35.0, 0, 10u8));\nlayout.append(fonts, \u0026TextStyle::with_user_data(\"world!\", 40.0, 0, 20u8));\nprintln!(\"{:?}\", layout.glyphs());\n```\n\n## Performance\n\n### Rasterization\n\nThese benchmarks measure the time it takes to generate the glyph metrics and bitmap for the text \"Sphinx of black quartz, judge my vow.\" over a range of sizes. The lower the line in the graph the better.\n\n![Rasterize benchmarks](/images/rasterize_glyf.png)\n\n![Rasterize benchmarks](/images/rasterize_cff.png)\n\n### Layout\n\nThis benchmark measures the time it takes to layout latin characters of sample text with wrapping on word boundaries.\n\n![Layout benchmarks](/images/layout.png)\n\n## License\n\nLicensed under any one of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n * Zlib license ([LICENSE-ZLIB](LICENSE-ZLIB) or http://opensource.org/licenses/Zlib)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be multi-licensed as above, without any additional terms or conditions.\n\n## Notices\n\n### Maintenance\n\nPlease bear with me on new features or quirks that you find. Bugs will take priority, but I don't have as much time as I would like to work on fontdue so please be patient, this is a solo project.\n\n### TrueType \u0026 OpenType Table Support\n\nFontdue depends on `ttf-parser` ([link](https://github.com/RazrFalcon/ttf-parser)) for parsing fonts, which supports a wide range of TrueType and OpenType features.\n\n### Attribution\n\n`Fontdue` started as a vaguely more production ready fork of `font-rs` [(link)](https://github.com/raphlinus/font-rs) because of how fast it made rasterization look, and how simple the `rusttype` [(link)](https://gitlab.redox-os.org/redox-os/rusttype) crate made font parsing look. Since then, I've read a lot of font specification and modern rasterization techniques, rewriting `fontdue` from the ground up in the process into its own unique beast.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmooman219%2Ffontdue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmooman219%2Ffontdue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmooman219%2Ffontdue/lists"}