{"id":51672814,"url":"https://github.com/pgaskin/go-hbsubset","last_synced_at":"2026-07-15T02:07:20.194Z","repository":{"id":368508674,"uuid":"1285490564","full_name":"pgaskin/go-hbsubset","owner":"pgaskin","description":"Go bindings for HarfBuzz's font subsetter (hb-subset) without cgo.","archived":false,"fork":false,"pushed_at":"2026-06-30T21:39:35.000Z","size":1498,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-30T23:22:12.341Z","etag":null,"topics":["otf","sfnt","ttf","wasm","wasm2go","webfont"],"latest_commit_sha":null,"homepage":"","language":"Go","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/pgaskin.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-30T21:26:30.000Z","updated_at":"2026-06-30T21:39:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pgaskin/go-hbsubset","commit_stats":null,"previous_names":["pgaskin/go-hbsubset"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/pgaskin/go-hbsubset","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaskin%2Fgo-hbsubset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaskin%2Fgo-hbsubset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaskin%2Fgo-hbsubset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaskin%2Fgo-hbsubset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgaskin","download_url":"https://codeload.github.com/pgaskin/go-hbsubset/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaskin%2Fgo-hbsubset/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35487065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-15T02:00:06.706Z","response_time":131,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["otf","sfnt","ttf","wasm","wasm2go","webfont"],"created_at":"2026-07-15T02:07:19.743Z","updated_at":"2026-07-15T02:07:20.187Z","avatar_url":"https://github.com/pgaskin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-hbsubset\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/pgaskin/go-hbsubset.svg)](https://pkg.go.dev/github.com/pgaskin/go-hbsubset)\n[![Test](https://github.com/pgaskin/go-hbsubset/actions/workflows/test.yml/badge.svg)](https://github.com/pgaskin/go-hbsubset/actions/workflows/test.yml)\n[![Attest hbsubset build](https://github.com/pgaskin/go-hbsubset/actions/workflows/attest.yml/badge.svg)](https://github.com/pgaskin/go-hbsubset/actions/workflows/attest.yml)\n\nGo bindings for [HarfBuzz](https://github.com/harfbuzz/harfbuzz)'s font subsetter (`hb-subset`) without cgo.\n\nThis library wraps a WebAssembly build of HarfBuzz transpiled to Go using [wasm2go](https://github.com/ncruces/wasm2go).\n\n\u003e [!WARNING]\n\u003e\n\u003e These bindings are still experimental and are subject to change. They have not been tested extensively yet.\n\nThe wasm2go blob is fully [reproducible](./src/Dockerfile) and [verified](https://github.com/pgaskin/go-hbsubset/attestations).\n\nTo have working IDE integration while working on the bindings, use `bear -- make -C src distclean download all CXX=/path/to/wasi-sdk/bin/wasm32-wasip1-clang++ WASM_OPT=/path/to/binaryen/bin/wasm-opt` to download the Harfbuzz source and generate the `compile_commands.json`.\n\n## Usage\n\nTo subset a single font:\n\n```go\nimport \"github.com/pgaskin/go-hbsubset\"\n\nout, err := hbsubset.Subset(font, 0, \u0026hbsubset.Options{\n    Unicodes: []rune(\"some text\"),\n})\n```\n\nYou can specify other options too:\n\n```go\nimport (\n    \"github.com/pgaskin/go-gfsubsets\"\n    \"golang.org/x/text/unicode/rangetable\"\n)\n\nout, err := hbsubset.Subset(data, 0, \u0026hbsubset.Options{\n    UnicodeRanges: rangetable.Merge(\n        gfsubsets.Latin,\n        \u0026unicode.RangeTable{\n            R16: []unicode.Range16{\n                {Stride: 1, Lo: '\\u2002', Hi: '\\u201E'}, // spaces, smart punctuation\n                {Stride: 1, Lo: '\\u2022', Hi: '\\u2022'}, // bullet\n                {Stride: 1, Lo: '\\u2026', Hi: '\\u2026'}, // ellipsis\n            },\n        },\n    ),\n    PinAllAxesToDefault: true,\n    AxisRanges: map[hbsubset.Tag]hbsubset.AxisRange{\n        hbsubset.MakeTag(\"wght\"): {Min: 100, Max: 900, Default: 400},\n    },\n    LayoutFeatures: []hbsubset.Tag{\n        hbsubset.MakeTag(\"kern\"),\n        hbsubset.MakeTag(\"mkmk\"),\n        hbsubset.MakeTag(\"size\"),\n        hbsubset.MakeTag(\"liga\"),\n    },\n    NameIDs: []hbsubset.NameID{\n        hbsubset.NameUniqueID,\n        hbsubset.NameCopyright,\n        hbsubset.NameFontFamily,\n        hbsubset.NameFontSubfamily,\n        hbsubset.NameTypographicFamily,\n        hbsubset.NameTypographicSubfamily,\n        hbsubset.NameFullName,\n        hbsubset.NameMacFullName,\n        hbsubset.NamePostscriptName,\n        hbsubset.NameManufacturer,\n        hbsubset.NameDescription,\n        hbsubset.NameVariationsPSPrefix,\n    },\n    LayoutScripts: []hbsubset.Tag{\n        hbsubset.MakeTag(\"latn\"), // latin\n    },\n    NameLanguages: []uint32{\n        1033, // english\n    },\n})\n```\n\nYou can reuse a font for multiple subsets (this also lets you access the font metadata):\n\n```go\nface, err := hbsubset.NewFace(font, 0)\nif err != nil {\n    return err\n}\nface.Preprocess()\n\nfor _, page := range pages {\n    out, err := face.Subset(\u0026hbsubset.Options{Unicodes: page})\n    // ...\n}\n```\n\nYou can use `SubsetWithMapping` to get the renumbered glyphs.\n\n```go\nout, m, err := hbsubset.SubsetWithMapping(font, \u0026hbsubset.Options{\n    Unicodes: []rune(\"Hi\"),\n})\n\nnew, ok := m.NewGlyph(oldGID)\n\nfor old, new := range m.Glyphs() {\n    // ...\n}\n```\n\nThere are also some helpers to get relevant info (names, axes, glyph mappings, etc) from the font before subsetting (see the docs and [faceinfo.go](./faceinfo.go)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgaskin%2Fgo-hbsubset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgaskin%2Fgo-hbsubset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgaskin%2Fgo-hbsubset/lists"}