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
This commit is contained in:
Hajime Hoshi 2023-12-12 14:43:26 +09:00
parent c903cea637
commit 769de21ad1
3 changed files with 8 additions and 3 deletions

2
go.mod
View File

@ -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

4
go.sum
View File

@ -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=

View File

@ -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)