~eliasnaur/gio

aa2a948b863a4b7bfe34f1cdeb5c157d3818b740 — Chris Waldon 5 months ago dc6fbf0
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 <christopher.waldon.dev@gmail.com>
3 files changed, 3 insertions(+), 9 deletions(-)

M text/shaper.go
M text/shaper_test.go
M widget/text.go
M text/shaper.go => text/shaper.go +1 -7
@@ 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), "")
}


M text/shaper_test.go => text/shaper_test.go +1 -1
@@ 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))

M widget/text.go => widget/text.go +1 -1
@@ 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,