mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
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 <christopher.waldon.dev@gmail.com>
This commit is contained in:
+2
-5
@@ -14,8 +14,7 @@ import (
|
|||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"gioui.org/f32"
|
"gioui.org/f32"
|
||||||
"gioui.org/font"
|
"gioui.org/font/gofont"
|
||||||
"gioui.org/font/opentype"
|
|
||||||
"gioui.org/gpu"
|
"gioui.org/gpu"
|
||||||
"gioui.org/internal/ops"
|
"gioui.org/internal/ops"
|
||||||
"gioui.org/io/event"
|
"gioui.org/io/event"
|
||||||
@@ -29,7 +28,6 @@ import (
|
|||||||
"gioui.org/unit"
|
"gioui.org/unit"
|
||||||
"gioui.org/widget"
|
"gioui.org/widget"
|
||||||
"gioui.org/widget/material"
|
"gioui.org/widget/material"
|
||||||
"golang.org/x/image/font/gofont/goregular"
|
|
||||||
|
|
||||||
_ "gioui.org/app/internal/log"
|
_ "gioui.org/app/internal/log"
|
||||||
)
|
)
|
||||||
@@ -142,8 +140,7 @@ type queue struct {
|
|||||||
func NewWindow(options ...Option) *Window {
|
func NewWindow(options ...Option) *Window {
|
||||||
// Measure decoration height.
|
// Measure decoration height.
|
||||||
deco := new(widget.Decorations)
|
deco := new(widget.Decorations)
|
||||||
face, _ := opentype.Parse(goregular.TTF)
|
theme := material.NewTheme(gofont.Regular())
|
||||||
theme := material.NewTheme([]font.FontFace{{Font: font.Font{Typeface: "Go"}, Face: face}})
|
|
||||||
decoStyle := material.Decorations(theme, deco, 0, "")
|
decoStyle := material.Decorations(theme, deco, 0, "")
|
||||||
gtx := layout.Context{
|
gtx := layout.Context{
|
||||||
Ops: new(op.Ops),
|
Ops: new(op.Ops),
|
||||||
|
|||||||
Reference in New Issue
Block a user