~whereswaldon/gio-x

59c1ef31395fd7b87862e1f05f29e20023c9e411 — Chris Waldon 5 months ago b853331
go.*,component,styledtext,richtext,markdown: update font usage

This commit updates gio-x's use of the text shaping API to use the new symbols
defined in package gioui.org/font instead of the old ones in gioui.org/text.
It handles the breaking changes from gioui.org@f77bf9a42.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
M component/discloser.go => component/discloser.go +3 -3
@@ 64,9 64,9 @@ func Discloser(th *material.Theme, state *DiscloserState) DiscloserStyle {
//
// The structure of the resulting discloser is:
//
//     control | summary
//     -----------------
//     detail
//	control | summary
//	-----------------
//	detail
//
// If d.ControlSide is set to Right, the control will appear after the summary
// instead of before it.

M component/nav_drawer.go => component/nav_drawer.go +3 -3
@@ 5,10 5,10 @@ import (
	"image/color"
	"time"

	"gioui.org/font"
	"gioui.org/io/pointer"
	"gioui.org/layout"
	"gioui.org/op/clip"
	"gioui.org/text"
	"gioui.org/unit"
	"gioui.org/widget"
	"gioui.org/widget/material"


@@ 112,7 112,7 @@ func (n *renderNavItem) layoutContent(gtx layout.Context, th *material.Theme) la
			layout.Rigid(func(gtx C) D {
				label := material.Label(th, unit.Sp(14), n.Name)
				label.Color = contentColor
				label.Font.Weight = text.Bold
				label.Font.Weight = font.Bold
				return layout.Center.Layout(gtx, TruncatingLabelStyle(label).Layout)
			}),
		)


@@ 218,7 218,7 @@ func (m *NavDrawer) LayoutContents(gtx layout.Context, th *material.Theme, anim 
						gtx.Constraints.Max.Y = gtx.Dp(unit.Dp(36))
						gtx.Constraints.Min = gtx.Constraints.Max
						title := material.Label(th, unit.Sp(18), m.Title)
						title.Font.Weight = text.Bold
						title.Font.Weight = font.Bold
						return layout.SW.Layout(gtx, title.Layout)
					}),
					layout.Rigid(func(gtx C) D {

M go.mod => go.mod +2 -2
@@ 3,7 3,7 @@ module gioui.org/x
go 1.18

require (
	gioui.org v0.0.0-20230401135047-e768fe347a73
	gioui.org v0.0.0-20230418224039-a7c9ca99f3be
	git.sr.ht/~jackmordaunt/go-toast v1.0.0
	git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0
	github.com/andybalholm/stroke v0.0.0-20221221101821-bd29b49d73f0


@@ 21,5 21,5 @@ require (
	gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 // indirect
	gioui.org/shader v1.0.6 // indirect
	github.com/go-ole/go-ole v1.2.6 // indirect
	github.com/go-text/typesetting v0.0.0-20230329143336-a38d00edd832 // indirect
	github.com/go-text/typesetting v0.0.0-20230413204129-b4f0492bf7ae // indirect
)

M go.sum => go.sum +5 -5
@@ 1,6 1,6 @@
eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d h1:ARo7NCVvN2NdhLlJE9xAbKweuI9L6UgfTbYb0YwPacY=
gioui.org v0.0.0-20230401135047-e768fe347a73 h1:07hK27qHktByzic7em44RDYkP+eEVtM4YCUFOyXMoUs=
gioui.org v0.0.0-20230401135047-e768fe347a73/go.mod h1:7nNGoqbKQrlMpF4SGrQWYEMr9MuSXlVTCl2qRkZDsjA=
gioui.org v0.0.0-20230418224039-a7c9ca99f3be h1:TS+39qH1t6THprhFqWz0SedSip2mQ42oA49GFHXFMhc=
gioui.org v0.0.0-20230418224039-a7c9ca99f3be/go.mod h1:8CFQM/4LurRd9G3NUYdacFb9j2pK0LrAyVO2mAZo4mw=
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 h1:AGDDxsJE1RpcXTAxPG2B4jrwVUJGFDjINIPi1jtO6pc=
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=


@@ 16,9 16,9 @@ github.com/esiqveland/notify v0.11.0 h1:0WJ/xW+3Ln8uRBYntG7f0XihXxnlOaQTdha1yyzX
github.com/esiqveland/notify v0.11.0/go.mod h1:63UbVSaeJwF0LVJARHFuPgUAoM7o1BEvCZyknsuonBc=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-text/typesetting v0.0.0-20230329143336-a38d00edd832 h1:yV4rFdcvwZXE0lZZ3EoBWjVysHyVo8DLY8VihDciNN0=
github.com/go-text/typesetting v0.0.0-20230329143336-a38d00edd832/go.mod h1:zvWM81wAVW6QfVDI6yxfbCuoLnobSYTuMsrXU/u11y8=
github.com/go-text/typesetting-utils v0.0.0-20230326210548-458646692de6 h1:zAAA1U4ykFwqPbcj6YDxvq3F2g0wc/ngPfLJjkR/8zs=
github.com/go-text/typesetting v0.0.0-20230413204129-b4f0492bf7ae h1:LCcaQgYrnS+sx9Tc3oGUvbRBRt+5oFnKWakaxeAvNVI=
github.com/go-text/typesetting v0.0.0-20230413204129-b4f0492bf7ae/go.mod h1:KmrpWuSMFcO2yjmyhGpnBGQHSKAoEgMTSSzvLDzCuEA=
github.com/go-text/typesetting-utils v0.0.0-20230412163830-89e4bcfa3ecc h1:9Kf84pnrmmjdRzZIkomfjowmGUhHs20jkrWYw/I6CYc=
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.0.6 h1:mkgN1ofwASrYnJ5W6U/BxG15eXXXjirgZc7CLqkcaro=
github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=

M markdown/markdown.go => markdown/markdown.go +7 -7
@@ 14,7 14,7 @@ import (
	"regexp"
	"strings"

	"gioui.org/text"
	"gioui.org/font"
	"gioui.org/unit"
	"gioui.org/x/richtext"



@@ 26,7 26,7 @@ import (

// Config defines settings used by the renderer.
type Config struct {
	DefaultFont text.Font
	DefaultFont font.Font
	// Defaults to 12 if unset.
	DefaultSize unit.Sp
	// If unset, each level will be 1.2 times larger than the previous.


@@ 72,7 72,7 @@ func (g *gioNodeRenderer) UpdateCurrentColor(c color.NRGBA) {
// current text's corresponding attribute will be updated to match.
// If the provided font is the zero value, the current font will be
// reset to the zero value as well.
func (g *gioNodeRenderer) UpdateCurrentFont(f text.Font) {
func (g *gioNodeRenderer) UpdateCurrentFont(f font.Font) {
	reset := true
	if f.Style != 0 {
		reset = false


@@ 292,15 292,15 @@ func (g *gioNodeRenderer) renderEmphasis(w util.BufWriter, source []byte, node a

	if entering {
		if n.Level == 2 {
			g.Current.Font.Weight = text.Bold
			g.Current.Font.Weight = font.Bold
		} else {
			g.Current.Font.Style = text.Italic
			g.Current.Font.Style = font.Italic
		}
	} else {
		if n.Level == 2 {
			g.Current.Font.Weight = text.Normal
			g.Current.Font.Weight = font.Normal
		} else {
			g.Current.Font.Style = text.Regular
			g.Current.Font.Style = font.Regular
		}
	}
	return ast.WalkContinue, nil

M richtext/richtext.go => richtext/richtext.go +2 -1
@@ 5,6 5,7 @@ import (
	"image/color"
	"time"

	"gioui.org/font"
	"gioui.org/gesture"
	"gioui.org/io/pointer"
	"gioui.org/layout"


@@ 138,7 139,7 @@ func (i *InteractiveText) Events() (*InteractiveSpan, []Event) {

// SpanStyle describes the appearance of a span of styled text.
type SpanStyle struct {
	Font           text.Font
	Font           font.Font
	Size           unit.Sp
	Color          color.NRGBA
	Content        string

M styledtext/styledtext.go => styledtext/styledtext.go +2 -1
@@ 6,6 6,7 @@ import (
	"image/color"
	"unicode/utf8"

	"gioui.org/font"
	"gioui.org/layout"
	"gioui.org/op"
	"gioui.org/op/paint"


@@ 16,7 17,7 @@ import (

// SpanStyle describes the appearance of a span of styled text.
type SpanStyle struct {
	Font    text.Font
	Font    font.Font
	Size    unit.Sp
	Color   color.NRGBA
	Content string