text: convert clip.Ops to op.CallOp

MacroOp is about to lose the ability to run a different operation list
than the one it was recorded on. Text shape caches rely on that property,
and must use the new CallOp operation added for purpose.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-12-11 22:58:08 +01:00
parent 06217c5320
commit 0768fbe590
6 changed files with 18 additions and 18 deletions
+4 -3
View File
@@ -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) {