diff --git a/widget/material/button.go b/widget/material/button.go index ecb15258..15cad855 100644 --- a/widget/material/button.go +++ b/widget/material/button.go @@ -51,7 +51,7 @@ type IconButtonStyle struct { } func Button(th *Theme, button *widget.Clickable, txt string) ButtonStyle { - return ButtonStyle{ + b := ButtonStyle{ Text: txt, Color: th.Palette.ContrastFg, CornerRadius: 4, @@ -64,6 +64,8 @@ func Button(th *Theme, button *widget.Clickable, txt string) ButtonStyle { Button: button, shaper: th.Shaper, } + b.Font.Typeface = th.Face + return b } func ButtonLayout(th *Theme, button *widget.Clickable) ButtonLayoutStyle { diff --git a/widget/material/checkbox.go b/widget/material/checkbox.go index 920a66f0..74261074 100644 --- a/widget/material/checkbox.go +++ b/widget/material/checkbox.go @@ -14,7 +14,7 @@ type CheckBoxStyle struct { } func CheckBox(th *Theme, checkBox *widget.Bool, label string) CheckBoxStyle { - return CheckBoxStyle{ + c := CheckBoxStyle{ CheckBox: checkBox, checkable: checkable{ Label: label, @@ -27,6 +27,8 @@ func CheckBox(th *Theme, checkBox *widget.Bool, label string) CheckBoxStyle { uncheckedStateIcon: th.Icon.CheckBoxUnchecked, }, } + c.checkable.Font.Typeface = th.Face + return c } // Layout updates the checkBox and displays it. diff --git a/widget/material/editor.go b/widget/material/editor.go index 57ca54c1..0b4850de 100644 --- a/widget/material/editor.go +++ b/widget/material/editor.go @@ -33,7 +33,10 @@ type EditorStyle struct { func Editor(th *Theme, editor *widget.Editor, hint string) EditorStyle { return EditorStyle{ - Editor: editor, + Editor: editor, + Font: font.Font{ + Typeface: th.Face, + }, TextSize: th.TextSize, Color: th.Palette.Fg, shaper: th.Shaper, diff --git a/widget/material/label.go b/widget/material/label.go index be0abdd0..2eb295e6 100644 --- a/widget/material/label.go +++ b/widget/material/label.go @@ -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 { diff --git a/widget/material/radiobutton.go b/widget/material/radiobutton.go index 5d2692ef..97ff6b90 100644 --- a/widget/material/radiobutton.go +++ b/widget/material/radiobutton.go @@ -17,7 +17,7 @@ type RadioButtonStyle struct { // RadioButton returns a RadioButton with a label. The key specifies // the value for the Enum. func RadioButton(th *Theme, group *widget.Enum, key, label string) RadioButtonStyle { - return RadioButtonStyle{ + r := RadioButtonStyle{ Group: group, checkable: checkable{ Label: label, @@ -32,6 +32,8 @@ func RadioButton(th *Theme, group *widget.Enum, key, label string) RadioButtonSt }, Key: key, } + r.checkable.Font.Typeface = th.Face + return r } // Layout updates enum and displays the radio button. diff --git a/widget/material/theme.go b/widget/material/theme.go index 42f31130..8f6c070f 100644 --- a/widget/material/theme.go +++ b/widget/material/theme.go @@ -7,6 +7,7 @@ import ( "golang.org/x/exp/shiny/materialdesign/icons" + "gioui.org/font" "gioui.org/text" "gioui.org/unit" "gioui.org/widget" @@ -41,6 +42,8 @@ type Theme struct { RadioChecked *widget.Icon RadioUnchecked *widget.Icon } + // Face selects the default typeface for text. + Face font.Typeface // FingerSize is the minimum touch target size. FingerSize unit.Dp