From aa2a948b863a4b7bfe34f1cdeb5c157d3818b740 Mon Sep 17 00:00:00 2001 From: Chris Waldon Date: Fri, 23 Dec 2022 08:23:08 -0500 Subject: [PATCH] text,widget: [API] drop runereader based shaping API The io.Reader based API has the potential to be significantly more efficient, and there are very few users of the runereader API. This commit simply drops it entirely in favor of the reader API. Signed-off-by: Chris Waldon --- text/shaper.go | 8 +------- text/shaper_test.go | 2 +- widget/text.go | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/text/shaper.go b/text/shaper.go index 0337b0c7..e81a9994 100644 --- a/text/shaper.go +++ b/text/shaper.go @@ -177,15 +177,9 @@ func NewShaper(collection []FontFace) *Shaper { return l } -// Layout a text according to a set of options. Results can be retrieved by -// iteratively calling NextGlyph. -func (l *Shaper) Layout(params Parameters, minWidth, maxWidth int, lc system.Locale, txt io.RuneReader) { - l.layoutText(params, minWidth, maxWidth, lc, txt, "") -} - // Layout text from an io.Reader according to a set of options. Results can be retrieved by // iteratively calling NextGlyph. -func (l *Shaper) LayoutReader(params Parameters, minWidth, maxWidth int, lc system.Locale, txt io.Reader) { +func (l *Shaper) Layout(params Parameters, minWidth, maxWidth int, lc system.Locale, txt io.Reader) { l.layoutText(params, minWidth, maxWidth, lc, bufio.NewReader(txt), "") } diff --git a/text/shaper_test.go b/text/shaper_test.go index ca8cc6d1..a150c3dc 100644 --- a/text/shaper_test.go +++ b/text/shaper_test.go @@ -113,7 +113,7 @@ func TestShapingNewlineHandling(t *testing.T) { } checkGlyphs() - cache.LayoutReader(Parameters{ + cache.Layout(Parameters{ Alignment: Middle, PxPerEm: fixed.I(10), }, 200, 200, english, strings.NewReader(tc.textInput)) diff --git a/widget/text.go b/widget/text.go index 615c679f..5c1efd83 100644 --- a/widget/text.go +++ b/widget/text.go @@ -399,7 +399,7 @@ func (e *textView) layoutText(lt *text.Shaper) { e.index = glyphIndex{} it := textIterator{viewport: image.Rectangle{Max: image.Point{X: math.MaxInt, Y: math.MaxInt}}} if lt != nil { - lt.LayoutReader(text.Parameters{ + lt.Layout(text.Parameters{ Font: e.font, PxPerEm: e.textSize, Alignment: e.Alignment,