From ea653ce3bf266fb3c3f6b917b3924b0328f5d4a4 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 22 May 2015 14:02:52 +0200 Subject: Generalize --- text.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'text.go') diff --git a/text.go b/text.go index 3ee2073..d13f766 100644 --- a/text.go +++ b/text.go @@ -2,8 +2,8 @@ package robo import ( "bufio" + "io" "log" - "os" ) type Font map[rune]Glyph @@ -15,19 +15,19 @@ type Glyph struct { type Set []Path -func PrintStdin(c *bufio.Writer, scale Unit) { +func Print(c *bufio.Writer, in io.Reader, scale Unit) { var off Point - scanner := bufio.NewScanner(os.Stdin) + scanner := bufio.NewScanner(in) for scanner.Scan() { - font.printChar(c, scanner.Text(), scale, &off) + font.putchar(c, scanner.Text(), scale, &off) } if err := scanner.Err(); err != nil { log.Fatal(err) } } -func (f Font) printChar(c *bufio.Writer, s string, scale Unit, off *Point) { +func (f Font) putchar(c *bufio.Writer, s string, scale Unit, off *Point) { for _, ch := range s { gl, ok := f[ch] if ok { -- cgit v1.2.3