@@ 3,6 3,7 @@
package text
import (
+ "bufio"
"fmt"
"io"
"strings"
@@ 182,6 183,12 @@ func (l *Shaper) Layout(params Parameters, minWidth, maxWidth int, lc system.Loc
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) {
+ l.layoutText(params, minWidth, maxWidth, lc, bufio.NewReader(txt), "")
+}
+
// LayoutString is Layout for strings.
func (l *Shaper) LayoutString(params Parameters, minWidth, maxWidth int, lc system.Locale, str string) {
l.layoutText(params, minWidth, maxWidth, lc, nil, str)
@@ 113,7 113,7 @@ func TestShapingNewlineHandling(t *testing.T) {
}
checkGlyphs()
- cache.Layout(Parameters{
+ cache.LayoutReader(Parameters{
Alignment: Middle,
PxPerEm: fixed.I(10),
}, 200, 200, english, strings.NewReader(tc.textInput))