aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drawtext/main.go3
-rw-r--r--text.go10
2 files changed, 7 insertions, 6 deletions
diff --git a/drawtext/main.go b/drawtext/main.go
index 751041c..5f02e5d 100644
--- a/drawtext/main.go
+++ b/drawtext/main.go
@@ -2,6 +2,7 @@ package main
import (
"flag"
+ "os"
"dim13.org/robo"
)
@@ -20,5 +21,5 @@ func main() {
robo.Initialize(handle, 113, robo.Portrait)
robo.A4.UpperRight(handle.Writer)
robo.Triple{100, 100, 100}.Factor(handle.Writer)
- robo.PrintStdin(handle.Writer, robo.Unit(*scale))
+ robo.Print(handle.Writer, os.Stdin, robo.Unit(*scale))
}
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 {