From 769de21ad1e9a2315747a5eb8344c03c2a2c37c1 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 12 Dec 2023 14:43:26 +0900 Subject: [PATCH] text/v2: bug fix: some OpenType fonts didn't work NotoSansJP-VF.otf from https://github.com/notofonts/noto-cjk/releases/tag/Sans2.004 was not rendered correctly. This change fixes this issue. Updates go-text/typesetting#122 --- go.mod | 2 +- go.sum | 4 ++-- text/v2/gotextseg.go | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 21fc1e158..dde457c10 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/ebitengine/oto/v3 v3.2.0-alpha.2.0.20231021101548-b794c0292b2b github.com/ebitengine/purego v0.6.0-alpha.2 - github.com/go-text/typesetting v0.0.0-20231206174126-ce41cc83e028 + github.com/go-text/typesetting v0.0.0-20231211160022-6295f3c76f4d github.com/hajimehoshi/bitmapfont/v3 v3.0.0 github.com/hajimehoshi/go-mp3 v0.3.4 github.com/jakecoffman/cp v1.2.1 diff --git a/go.sum b/go.sum index 3957467c6..e014557f1 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/ebitengine/oto/v3 v3.2.0-alpha.2.0.20231021101548-b794c0292b2b h1:gi7 github.com/ebitengine/oto/v3 v3.2.0-alpha.2.0.20231021101548-b794c0292b2b/go.mod h1:JtMbxJHZBDXfS8BmVYwzWk9Z6r7jsjwsHzOuZrEkfs4= github.com/ebitengine/purego v0.6.0-alpha.2 h1:lYSvMtNBEjNGAzqPC5WP7bHUOxkFU3L+JZMdxK7krkw= github.com/ebitengine/purego v0.6.0-alpha.2/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ= -github.com/go-text/typesetting v0.0.0-20231206174126-ce41cc83e028 h1:Ml7tuFjpWEaaUcgzQv/yx/oLkyGAFNmgBwVEvvnElGU= -github.com/go-text/typesetting v0.0.0-20231206174126-ce41cc83e028/go.mod h1:MrLApvxyzSW0MhQqLc484jkUWYX4wsEvEqDosB5Io80= +github.com/go-text/typesetting v0.0.0-20231211160022-6295f3c76f4d h1:AFVBrIZZMhmnB8NbkKayNVz714G048XqZGmNhXjvSag= +github.com/go-text/typesetting v0.0.0-20231211160022-6295f3c76f4d/go.mod h1:MrLApvxyzSW0MhQqLc484jkUWYX4wsEvEqDosB5Io80= github.com/go-text/typesetting-utils v0.0.0-20231204162240-fa4dc564ba79 h1:3yBOzx29wog0i7TnUBMcp90EwIb+A5kqmr5vny1UOm8= github.com/hajimehoshi/bitmapfont/v3 v3.0.0 h1:r2+6gYK38nfztS/et50gHAswb9hXgxXECYgE8Nczmi4= github.com/hajimehoshi/bitmapfont/v3 v3.0.0/go.mod h1:+CxxG+uMmgU4mI2poq944i3uZ6UYFfAkj9V6WqmuvZA= diff --git a/text/v2/gotextseg.go b/text/v2/gotextseg.go index f19edebf6..4875bb4ba 100644 --- a/text/v2/gotextseg.go +++ b/text/v2/gotextseg.go @@ -115,6 +115,11 @@ func segmentsToImage(segs []api.Segment, subpixelOffset fixed.Point26_6, glyphBo } } + // Explicit closing is necessary especially for some OpenType fonts like + // NotoSansJP-VF.otf in https://github.com/notofonts/noto-cjk/releases/tag/Sans2.004. + // See also https://github.com/go-text/typesetting/issues/122. + rast.ClosePath() + dst := image.NewRGBA(image.Rect(0, 0, w, h)) rast.Draw(dst, dst.Bounds(), image.Opaque, image.Point{}) return ebiten.NewImageFromImage(dst)