text,widget,opentype: change text.Face.Shape to return a clip.PathSpec

With this change, the Shape function returns a clip.PathSpec
instead of a clip.Outline op. It is then possible to create
a clip.Outline or clip.Stroke op to fill the text path or
draw its stroke.

Signed-off-by: Christophe Meessen <meessen@cppm.in2p3.fr>
This commit is contained in:
Christophe Meessen
2021-12-16 17:15:01 +01:00
committed by Elias Naur
parent 3db11cbaad
commit a34e239c04
8 changed files with 25 additions and 28 deletions
+4 -4
View File
@@ -18,7 +18,7 @@ type Shaper interface {
// LayoutString is Layout for strings.
LayoutString(font Font, size fixed.Int26_6, maxWidth int, str string) []Line
// Shape a line of text and return a clipping operation for its outline.
Shape(font Font, size fixed.Int26_6, layout Layout) clip.Op
Shape(font Font, size fixed.Int26_6, layout Layout) clip.PathSpec
}
// A FontFace is a Font and a matching Face.
@@ -121,7 +121,7 @@ func (c *Cache) LayoutString(font Font, size fixed.Int26_6, maxWidth int, str st
// Shape is a caching implementation of the Shaper interface. Shape assumes that the layout
// argument is unchanged from a call to Layout or LayoutString.
func (c *Cache) Shape(font Font, size fixed.Int26_6, layout Layout) clip.Op {
func (c *Cache) Shape(font Font, size fixed.Int26_6, layout Layout) clip.PathSpec {
cache := c.lookup(font)
return cache.shape(size, layout)
}
@@ -143,9 +143,9 @@ func (f *faceCache) layout(ppem fixed.Int26_6, maxWidth int, str string) []Line
return l
}
func (f *faceCache) shape(ppem fixed.Int26_6, layout Layout) clip.Op {
func (f *faceCache) shape(ppem fixed.Int26_6, layout Layout) clip.PathSpec {
if f == nil {
return clip.Op{}
return clip.PathSpec{}
}
pk := pathKey{
ppem: ppem,