widget/material: allow configuring default typeface on theme

This commit introduces the material.Theme.Face field, which will automatically
populate the Font.Typeface in every text widget created using a constructor function
in package material.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2023-06-22 15:06:22 -04:00
committed by Elias Naur
parent 6384ab6087
commit acab582487
6 changed files with 19 additions and 5 deletions
+3 -1
View File
@@ -105,13 +105,15 @@ func Overline(th *Theme, txt string) LabelStyle {
}
func Label(th *Theme, size unit.Sp, txt string) LabelStyle {
return LabelStyle{
l := LabelStyle{
Text: txt,
Color: th.Palette.Fg,
SelectionColor: f32color.MulAlpha(th.Palette.ContrastBg, 0x60),
TextSize: size,
Shaper: th.Shaper,
}
l.Font.Typeface = th.Face
return l
}
func (l LabelStyle) Layout(gtx layout.Context) layout.Dimensions {