{"id":51121546,"url":"https://github.com/numberoverzero/slug-ebiten","last_synced_at":"2026-06-25T03:01:08.368Z","repository":{"id":363998270,"uuid":"1262491434","full_name":"numberoverzero/slug-ebiten","owner":"numberoverzero","description":null,"archived":false,"fork":false,"pushed_at":"2026-06-11T07:29:47.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-11T09:11:45.387Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/numberoverzero.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-08T03:26:02.000Z","updated_at":"2026-06-11T07:28:02.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/numberoverzero/slug-ebiten","commit_stats":null,"previous_names":["numberoverzero/slug-ebiten"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/numberoverzero/slug-ebiten","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberoverzero%2Fslug-ebiten","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberoverzero%2Fslug-ebiten/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberoverzero%2Fslug-ebiten/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberoverzero%2Fslug-ebiten/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/numberoverzero","download_url":"https://codeload.github.com/numberoverzero/slug-ebiten/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberoverzero%2Fslug-ebiten/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34757355,"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-06-25T02:00:05.521Z","response_time":101,"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":[],"created_at":"2026-06-25T03:01:06.306Z","updated_at":"2026-06-25T03:01:08.347Z","avatar_url":"https://github.com/numberoverzero.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slug-ebiten\n\nGPU font rendering for Ebitengine using the Slug curve-coverage algorithm.\n\n## Compiling a `font.ttf` to a `font.blob`\n\nA blob is the font's glyph outlines precomputed into the curve-coverage form the\nshader reads. Compile it once with `compile.Compile`, then write the bytes to\ndisk (or embed them) so your program loads the blob instead of the `.ttf`.\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/numberoverzero/slug-ebiten/compile\"\n)\n\nfunc main() {\n\tttf, err := os.ReadFile(\"font.ttf\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t\n\tblob, err := compile.Compile(ttf, []compile.GlyphRange{{Lo: ' ', Hi: '~'}})\n\t// nil keeps every glyph in the font:\n\t// blob, err := compile.Compile(ttf, nil)\n\t\n    if err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tif err := os.WriteFile(\"font.blob\", blob, 0o644); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n```\n\n## Loading a `font.blob` to a `slug.Font`\n\n`slug.Load` turns the blob bytes into a `*slug.Font` ready to draw. Load once at\nstartup and reuse the `Font` for every frame. The blob is just bytes, so you can\nembed it in your binary:\n\n```go\nimport (\n\t_ \"embed\"\n\n\t\"github.com/numberoverzero/slug-ebiten/slug\"\n)\n\n//go:embed font.blob\nvar fontBlob []byte\n\nfunc loadFont() *slug.Font {\n\tfont, err := slug.Load(fontBlob)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn font\n}\n```\n\n## Rendering a `slug.Font` to an `ebiten.Image`\n\n`Font.Draw` lays out runs of text from a pen origin and draws them in one GPU\ncall. The `GeoM` sizes and positions the text: `Scale` is pixels per em,\n`Translate` places the baseline's left corner, and an optional `Rotate` or\n`Skew` before `Translate` acts about the pen origin. Pass several `Run`s to mix\ncolors in a single call.\n\n```go\nfunc (g *game) Draw(screen *ebiten.Image) {\n\tconst size = 48 // pixels per em\n\n\tvar geom ebiten.GeoM\n\tgeom.Scale(size, size)\n\tgeom.Translate(20, 80)\n\n\tg.font.Draw(screen, []slug.Run{\n\t\t{Text: \"Hello, \", Color: color.RGBA{R: 0x33, G: 0x66, B: 0xcc, A: 0xff}},\n\t\t{Text: \"World\"}, // no Color falls back to DrawOptions.Color\n\t}, \u0026slug.DrawOptions{GeoM: geom, Color: color.Black})\n}\n```\n\nText stays sharp at any scale, so the same blob renders crisply from caption to\nbanner size. Use `Font.Measure` to get a text run's bounding box for layout, and\n`Font.LineMetrics` for ascent, descent, and line height.\n\n\n\n## See also\n\n* Slug reference shaders: https://github.com/EricLengyel/Slug\n* Slug: a decade in review (algorithm + public-domain dedication): https://terathon.com/blog/decade-slug.html\n* Slug Library (commercial reference): https://sluglibrary.com/\n* Ebitengine: https://ebitengine.org/\n* Ebitengine shaders (Kage): https://ebitengine.org/en/documents/shader.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumberoverzero%2Fslug-ebiten","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnumberoverzero%2Fslug-ebiten","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumberoverzero%2Fslug-ebiten/lists"}