From 880cd27f59cac112e0dc10d0feea38b7fb85a57e Mon Sep 17 00:00:00 2001 From: Chris Waldon Date: Thu, 20 Apr 2023 10:29:14 -0400 Subject: [PATCH] app: use more efficient window decoration font load This commit switches to the new Regular() collection method in gofont, ensuring that the regular face is only ever loaded once. Signed-off-by: Chris Waldon --- app/window.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/window.go b/app/window.go index 69704083..f32dd5e8 100644 --- a/app/window.go +++ b/app/window.go @@ -14,8 +14,7 @@ import ( "unicode/utf8" "gioui.org/f32" - "gioui.org/font" - "gioui.org/font/opentype" + "gioui.org/font/gofont" "gioui.org/gpu" "gioui.org/internal/ops" "gioui.org/io/event" @@ -29,7 +28,6 @@ import ( "gioui.org/unit" "gioui.org/widget" "gioui.org/widget/material" - "golang.org/x/image/font/gofont/goregular" _ "gioui.org/app/internal/log" ) @@ -142,8 +140,7 @@ type queue struct { func NewWindow(options ...Option) *Window { // Measure decoration height. deco := new(widget.Decorations) - face, _ := opentype.Parse(goregular.TTF) - theme := material.NewTheme([]font.FontFace{{Font: font.Font{Typeface: "Go"}, Face: face}}) + theme := material.NewTheme(gofont.Regular()) decoStyle := material.Decorations(theme, deco, 0, "") gtx := layout.Context{ Ops: new(op.Ops), -- 2.45.2