~eliasnaur/gio

6937a5dd1f39997ffd028546e6c75895ef0dc46f — Chris Waldon 1 year, 8 months ago 73787b8
go.*,text: update go-text to pick up font transformation caching

This commit picks up improvements in upstream go-text that (among other things)
allow the shaper to reuse a lot of information when shaping the same font face
multiple times (using an LRU cache to keep that information available). I've
tried to pick a reasonable default LRU size of 32 faces.

My simple benchmarks indicate a definitive performance gain and reduction in
memory use across the board, which is especially noticable for complex fonts
like arabic and emoji.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
3 files changed, 4 insertions(+), 3 deletions(-)

M go.mod
M go.sum
M text/shaper.go
M go.mod => go.mod +1 -1
@@ 6,7 6,7 @@ require (
	eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d
	gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2
	gioui.org/shader v1.0.6
	github.com/go-text/typesetting v0.0.0-20230329143336-a38d00edd832
	github.com/go-text/typesetting v0.0.0-20230405155246-bf9c697c6e16
	golang.org/x/exp v0.0.0-20221012211006-4de253d81b95
	golang.org/x/exp/shiny v0.0.0-20220827204233-334a2380cb91
	golang.org/x/image v0.5.0

M go.sum => go.sum +2 -2
@@ 5,8 5,8 @@ gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 h1:AGDDxsJE1RpcXTAxPG2B4jrwVUJG
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/shader v1.0.6 h1:cvZmU+eODFR2545X+/8XucgZdTtEjR3QWW6W65b0q5Y=
gioui.org/shader v1.0.6/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
github.com/go-text/typesetting v0.0.0-20230329143336-a38d00edd832 h1:yV4rFdcvwZXE0lZZ3EoBWjVysHyVo8DLY8VihDciNN0=
github.com/go-text/typesetting v0.0.0-20230329143336-a38d00edd832/go.mod h1:zvWM81wAVW6QfVDI6yxfbCuoLnobSYTuMsrXU/u11y8=
github.com/go-text/typesetting v0.0.0-20230405155246-bf9c697c6e16 h1:DvHeDNqK8cxdZ7C6y88pt3uE7euZH7/LluzyfnUfH/Q=
github.com/go-text/typesetting v0.0.0-20230405155246-bf9c697c6e16/go.mod h1:zvWM81wAVW6QfVDI6yxfbCuoLnobSYTuMsrXU/u11y8=
github.com/go-text/typesetting-utils v0.0.0-20230326210548-458646692de6 h1:zAAA1U4ykFwqPbcj6YDxvq3F2g0wc/ngPfLJjkR/8zs=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

M text/shaper.go => text/shaper.go +1 -0
@@ 200,6 200,7 @@ func NewShaper(collection []FontFace) *Shaper {
	for _, f := range collection {
		l.shaper.Load(f)
	}
	l.shaper.shaper.SetFontCacheSize(32)
	return l
}