{"id":27320301,"url":"https://github.com/harfbuzz/harfbuzz_rs","last_synced_at":"2025-12-12T15:25:10.352Z","repository":{"id":47506115,"uuid":"79643398","full_name":"harfbuzz/harfbuzz_rs","owner":"harfbuzz","description":"A fully safe Rust wrapper for the harfbuzz text shaping library.","archived":false,"fork":false,"pushed_at":"2024-09-24T09:17:45.000Z","size":29686,"stargazers_count":56,"open_issues_count":5,"forks_count":23,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-10T08:46:53.205Z","etag":null,"topics":["font","harfbuzz","rust","text-layout","text-shaping","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/harfbuzz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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}},"created_at":"2017-01-21T12:07:16.000Z","updated_at":"2025-03-10T11:18:39.000Z","dependencies_parsed_at":"2024-04-13T23:47:47.884Z","dependency_job_id":null,"html_url":"https://github.com/harfbuzz/harfbuzz_rs","commit_stats":{"total_commits":197,"total_committers":13,"mean_commits":"15.153846153846153","dds":0.2639593908629442,"last_synced_commit":"b3c92bf1692426f665fe536cd29ee1c38f6f4ecd"},"previous_names":["manuel-rhdt/harfbuzz_rs"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harfbuzz%2Fharfbuzz_rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harfbuzz%2Fharfbuzz_rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harfbuzz%2Fharfbuzz_rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harfbuzz%2Fharfbuzz_rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harfbuzz","download_url":"https://codeload.github.com/harfbuzz/harfbuzz_rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248550628,"owners_count":21122930,"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","harfbuzz","rust","text-layout","text-shaping","wrapper"],"created_at":"2025-04-12T09:46:33.951Z","updated_at":"2025-12-12T15:25:10.292Z","avatar_url":"https://github.com/harfbuzz.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# harfbuzz_rs\n\n[![Crates.io](https://img.shields.io/crates/v/harfbuzz_rs.svg)](https://crates.io/crates/harfbuzz_rs)\n[![Documentation](https://docs.rs/harfbuzz_rs/badge.svg)](https://docs.rs/harfbuzz_rs)\n[![Build status](https://github.com/harfbuzz/harfbuzz_rs/actions/workflows/rust.yml/badge.svg)](https://github.com/harfbuzz/harfbuzz_rs/actions/workflows/rust.yml)\n\n`harfbuzz_rs` is a high-level interface to HarfBuzz, exposing its most important\nfunctionality in a safe manner using Rust.\n\n# What is HarfBuzz?\n\nHarfBuzz is a library for performing complex text layout. It does not perform\nany drawing. This is quite a low-level operation. If you want to simply draw\nsome text on the screen you should maybe choose another more high-level library.\nHowever if you want to build a library for drawing text on some canvas or need a\nlot of control on advanced text layout then this is the right library to use.\n\n# Getting Started\n\nTo shape a simple string of text you just create a `Font` from a font file, fill\na `Buffer` with some text and call the `shape` function.\n\n```rust\nuse harfbuzz_rs::*;\n\nlet path = \"path/to/some/font_file.otf\";\nlet index = 0; //\u003c face index in the font file\nlet face = Face::from_file(path, index)?;\nlet mut font = Font::new(face);\n\nlet buffer = UnicodeBuffer::new().add_str(\"Hello World!\");\nlet output = shape(\u0026font, buffer, \u0026[]);\n\n// The results of the shaping operation are stored in the `output` buffer.\n\nlet positions = output.get_glyph_positions();\nlet infos = output.get_glyph_infos();\n\n// iterate over the shaped glyphs\nfor (position, info) in positions.iter().zip(infos) {\n    let gid = info.codepoint;\n    let cluster = info.cluster;\n    let x_advance = position.x_advance;\n    let x_offset = position.x_offset;\n    let y_offset = position.y_offset;\n\n    // Here you would usually draw the glyphs.\n    println!(\"gid{:?}={:?}@{:?},{:?}+{:?}\", gid, cluster, x_advance, x_offset, y_offset);\n}\n```\n\nThis should print out something similar to the following:\n\n```text\ngid41=0@741,0+0\ngid70=1@421,0+0\ngid77=2@258,0+0\ngid77=3@253,0+0\ngid80=4@510,0+0\ngid1=5@227,0+0\ngid56=6@874,0+0\ngid80=7@498,0+0\ngid83=8@367,0+0\ngid77=9@253,0+0\ngid69=10@528,0+0\ngid2=11@276,0+0\n```\n\nThe values of `x_advance`, `x_offset`, `y_advance` and `y_offset` are all given in so-called _font units_ by default.\nBy calling `face.upem()` you get the number of font units per [EM](\u003chttps://en.wikipedia.org/wiki/Em_(typography)\u003e) for\na specific `face`. This `upem` value can be used to scale the advances and offsets to a given font-size.\nFor example, if you want to display a font at 16 point (pt) size, that means that _1 EM = 16 pt_.\nIn this example, to convert a value, say `x_advance`, from font-units to points, we compute `((x_advance * font_size) as f64) / (upem as f64)`, where `font_size = 16` is a variable specifying the font size in points.\n\nNote that harfbuzz internally supports scaling fonts itself as well (using `font.set_scale(...)`, etc.) but in my opinion it is easier to scale the results oneself as described in the paragraph above.\n\n# Supported HarfBuzz versions\n\nThis crate is tested to work with harfbuzz versions 2.0 and higher. Older versions may work as well. I recommend statically linking the harfbuzz library provided by the `harfbuzz-sys` crate which is always up-to-date.\n\n# Optional Features\n\nIf you want to use rusttype as font functions enable the `rusttype` feature.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharfbuzz%2Fharfbuzz_rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharfbuzz%2Fharfbuzz_rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharfbuzz%2Fharfbuzz_rs/lists"}