diff --git a/font/opentype/opentype.go b/font/opentype/opentype.go index 13325883..f3110444 100644 --- a/font/opentype/opentype.go +++ b/font/opentype/opentype.go @@ -42,7 +42,7 @@ func (f *Font) Layout(ppem fixed.Int26_6, str string, opts text.LayoutOptions) * return layoutText(&f.buf, ppem, str, &opentype{Font: f.font, Hinting: font.HintingFull}, opts) } -func (f *Font) Shape(ppem fixed.Int26_6, str text.String) clip.Op { +func (f *Font) Shape(ppem fixed.Int26_6, str text.String) op.CallOp { return textPath(&f.buf, ppem, &opentype{Font: f.font, Hinting: font.HintingFull}, str) } @@ -130,7 +130,7 @@ func layoutText(buf *sfnt.Buffer, ppem fixed.Int26_6, str string, f *opentype, o return &text.Layout{Lines: lines} } -func textPath(buf *sfnt.Buffer, ppem fixed.Int26_6, f *opentype, str text.String) clip.Op { +func textPath(buf *sfnt.Buffer, ppem fixed.Int26_6, f *opentype, str text.String) op.CallOp { var lastPos f32.Point var builder clip.Path ops := new(op.Ops) @@ -188,7 +188,8 @@ func textPath(buf *sfnt.Buffer, ppem fixed.Int26_6, f *opentype, str text.String x += str.Advances[advIdx] advIdx++ } - return builder.End() + builder.End().Add(ops) + return op.CallOp{Ops: ops} } func (f *opentype) GlyphAdvance(buf *sfnt.Buffer, ppem fixed.Int26_6, r rune) (advance fixed.Int26_6, ok bool) { diff --git a/text/lru.go b/text/lru.go index f03b9300..343e7aee 100644 --- a/text/lru.go +++ b/text/lru.go @@ -3,7 +3,7 @@ package text import ( - "gioui.org/op/clip" + "gioui.org/op" "golang.org/x/image/math/fixed" ) @@ -26,7 +26,7 @@ type layoutElem struct { type path struct { next, prev *path key pathKey - val clip.Op + val op.CallOp } type layoutKey struct { @@ -81,16 +81,16 @@ func (l *layoutCache) insert(lt *layoutElem) { lt.next.prev = lt } -func (c *pathCache) Get(k pathKey) (clip.Op, bool) { +func (c *pathCache) Get(k pathKey) (op.CallOp, bool) { if v, ok := c.m[k]; ok { c.remove(v) c.insert(v) return v.val, true } - return clip.Op{}, false + return op.CallOp{}, false } -func (c *pathCache) Put(k pathKey, v clip.Op) { +func (c *pathCache) Put(k pathKey, v op.CallOp) { if c.m == nil { c.m = make(map[pathKey]*path) c.head = new(path) diff --git a/text/lru_test.go b/text/lru_test.go index 192f6392..fa5e50bf 100644 --- a/text/lru_test.go +++ b/text/lru_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "gioui.org/op/clip" + "gioui.org/op" ) func TestLayoutLRU(t *testing.T) { @@ -24,7 +24,7 @@ func TestLayoutLRU(t *testing.T) { func TestPathLRU(t *testing.T) { c := new(pathCache) put := func(i int) { - c.Put(pathKey{str: strconv.Itoa(i)}, clip.Op{}) + c.Put(pathKey{str: strconv.Itoa(i)}, op.CallOp{}) } get := func(i int) bool { _, ok := c.Get(pathKey{str: strconv.Itoa(i)}) diff --git a/text/shaper.go b/text/shaper.go index b6149a44..abcd884f 100644 --- a/text/shaper.go +++ b/text/shaper.go @@ -5,7 +5,7 @@ package text import ( "unicode/utf8" - "gioui.org/op/clip" + "gioui.org/op" "gioui.org/unit" "golang.org/x/image/math/fixed" ) @@ -46,7 +46,7 @@ func (s *Shaper) Layout(c unit.Converter, font Font, str string, opts LayoutOpti return tf.layout(fixed.I(c.Px(font.Size)), str, opts) } -func (s *Shaper) Shape(c unit.Converter, font Font, str String) clip.Op { +func (s *Shaper) Shape(c unit.Converter, font Font, str String) op.CallOp { tf := s.faceForFont(font) return tf.shape(fixed.I(c.Px(font.Size)), str) } @@ -99,9 +99,9 @@ func (t *face) layout(ppem fixed.Int26_6, str string, opts LayoutOptions) *Layou return l } -func (t *face) shape(ppem fixed.Int26_6, str String) clip.Op { +func (t *face) shape(ppem fixed.Int26_6, str String) op.CallOp { if t == nil { - return clip.Op{} + return op.CallOp{} } pk := pathKey{ ppem: ppem, diff --git a/text/text.go b/text/text.go index 5c1a5d90..9f3c59e4 100644 --- a/text/text.go +++ b/text/text.go @@ -3,7 +3,7 @@ package text import ( - "gioui.org/op/clip" + "gioui.org/op" "gioui.org/unit" "golang.org/x/image/font" "golang.org/x/image/math/fixed" @@ -60,7 +60,7 @@ type Font struct { // Face implements text layout and shaping for a particular font. type Face interface { Layout(ppem fixed.Int26_6, str string, opts LayoutOptions) *Layout - Shape(ppem fixed.Int26_6, str String) clip.Op + Shape(ppem fixed.Int26_6, str String) op.CallOp Metrics(ppem fixed.Int26_6) font.Metrics } diff --git a/widget/editor.go b/widget/editor.go index ef282c7f..8b7b07d2 100644 --- a/widget/editor.go +++ b/widget/editor.go @@ -15,7 +15,6 @@ import ( "gioui.org/io/pointer" "gioui.org/layout" "gioui.org/op" - "gioui.org/op/clip" "gioui.org/op/paint" "gioui.org/text" "gioui.org/unit" @@ -81,7 +80,7 @@ type SubmitEvent struct { type line struct { offset f32.Point - clip clip.Op + clip op.CallOp } const (