{"id":22511553,"url":"https://github.com/codepunkt/wasm-layout-text","last_synced_at":"2025-06-10T21:10:59.638Z","repository":{"id":57103121,"uuid":"325519027","full_name":"codepunkt/wasm-layout-text","owner":"codepunkt","description":null,"archived":false,"fork":false,"pushed_at":"2021-04-10T08:00:41.000Z","size":276,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-28T15:19:09.637Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/codepunkt.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":"2020-12-30T10:18:41.000Z","updated_at":"2023-10-03T21:27:24.000Z","dependencies_parsed_at":"2022-08-20T23:20:38.433Z","dependency_job_id":null,"html_url":"https://github.com/codepunkt/wasm-layout-text","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepunkt%2Fwasm-layout-text","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepunkt%2Fwasm-layout-text/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepunkt%2Fwasm-layout-text/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepunkt%2Fwasm-layout-text/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codepunkt","download_url":"https://codeload.github.com/codepunkt/wasm-layout-text/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepunkt%2Fwasm-layout-text/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259152603,"owners_count":22813217,"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-12-07T02:13:13.805Z","updated_at":"2025-06-10T21:10:57.863Z","avatar_url":"https://github.com/codepunkt.png","language":"Rust","readme":"# @codepunkt/wasm-layout-text\n\n## Key features\n\nThis package layouts text and returns the result as an `UInt8Array` of pixels. It supports:\n\n- custom image dimensions\n- custom (TrueType) font, font size and color\n- text positioning, custom text bounding box\n- any combination of vertical and horizontal alignment\n\n## Usage\n\nThe package provides a `render` function that returns an `UInt8Array` of pixels:\n\n```js\nconst { readFileSync } = require(\"fs\");\nconst { join } = require(\"path\");\nconst wlt = require(\"@codepunkt/wasm-layout-text\");\n\nconst font = readFileSync(join(__dirname, \"myfont.ttf\"));\n\nconst buffer = wlt.render(\n  // text, size, color, ttf font buffer\n  new wlt.Text(\"Hello world\", 64, new wlt.RgbColor(91, 214, 123), font),\n  // image dimension\n  new wlt.Dimension(1200, 630),\n  // text bounds\n  new wlt.Dimension(1100, 530),\n  // text position\n  new wlt.Position(50, 50),\n  // text alignment\n  new wlt.Alignment(wlt.HorizontalAlign.Left, wlt.VerticalAlign.Top)\n);\n```\n\nYou can then use [Jimp](https://github.com/oliver-moran/jimp) or other image processing libraries to\n\n- load this buffer\n- combine it with other buffers (such as a background image or additional text generated by this package)\n- save to image file\n\n## Contributing\n\nContributions are welcome! A JavaScript usage example with Jimp is available in the `example` directory.\n\nThere are a few `make` tasks, most notably:\n\n- `make build`: will build rust code from `./src` to JavaScript code in `./pkg` (using [wasm-pack](https://github.com/rustwasm/wasm-pack))\n- `make node`: executes the `example` code with Node.js and uses the local JavaScript package from `.pkg` to render all alignment permutations (expects the `./pkg` folder to exist)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodepunkt%2Fwasm-layout-text","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodepunkt%2Fwasm-layout-text","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodepunkt%2Fwasm-layout-text/lists"}