mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 17:05:38 +00:00
text,widget/material: make font collections explicit
Before this change, package font implemented a global font registry, with the usual problems of package global state. This change deletes the global registry and introduces the text.Collection type for representing a list of fonts and their faces. Collection exports Lookup that finds the closest match and its face. The existing FontRegistry is renamed to Cache to reflect its new limited functionality: a cache of shapes and measurements on top of a Collection. Then, material.NewTheme is changed to take a Collection and initialize a Cache. Updates gio#19 because multiple windows require a separate (writable) Cache per window, while (read-only) Collections may be shared. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"image/color"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/font"
|
||||
"gioui.org/layout"
|
||||
"gioui.org/op/paint"
|
||||
"gioui.org/text"
|
||||
@@ -30,9 +29,9 @@ type Theme struct {
|
||||
radioUncheckedIcon *widget.Icon
|
||||
}
|
||||
|
||||
func NewTheme() *Theme {
|
||||
func NewTheme(col *text.Collection) *Theme {
|
||||
t := &Theme{
|
||||
Shaper: font.Default(),
|
||||
Shaper: text.NewCache(col),
|
||||
}
|
||||
t.Color.Primary = rgb(0x3f51b5)
|
||||
t.Color.Text = rgb(0x000000)
|
||||
|
||||
Reference in New Issue
Block a user