shiny/font/plan9font: add an example test.

The testdata/fixed font files come from the Plan 9 Port, and were all
marked as public domain. The total size of the new testdata is 112K.

Change-Id: I8cf5de4e5abd1aec7e6550d330271f2acdc12402
Reviewed-on: https://go-review.googlesource.com/13888
Reviewed-by: Rob Pike <r@golang.org>
diff --git a/font/plan9font/example_test.go b/font/plan9font/example_test.go
new file mode 100644
index 0000000..071fcfa
--- /dev/null
+++ b/font/plan9font/example_test.go
@@ -0,0 +1,93 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package plan9font_test
+
+import (
+	"image"
+	"image/draw"
+	"io/ioutil"
+	"log"
+	"os"
+	"path"
+	"path/filepath"
+
+	"golang.org/x/exp/shiny/font"
+	"golang.org/x/exp/shiny/font/plan9font"
+	"golang.org/x/image/math/fixed"
+)
+
+func ExampleParseFont() {
+	readFile := func(name string) ([]byte, error) {
+		return ioutil.ReadFile(filepath.FromSlash(path.Join("../testdata/fixed", name)))
+	}
+	fontData, err := readFile("unicode.7x13.font")
+	if err != nil {
+		log.Fatal(err)
+	}
+	face, err := plan9font.ParseFont(fontData, readFile)
+	if err != nil {
+		log.Fatal(err)
+	}
+	// TODO: derive the ascent from the face's metrics.
+	const ascent = 11
+
+	dst := image.NewRGBA(image.Rect(0, 0, 4*7, 13))
+	draw.Draw(dst, dst.Bounds(), image.Black, image.Point{}, draw.Src)
+	d := &font.Drawer{
+		Dst:  dst,
+		Src:  image.White,
+		Face: face,
+		Dot:  fixed.P(0, ascent),
+	}
+	// Draw:
+	// 	- U+0053 LATIN CAPITAL LETTER S
+	//	- U+03A3 GREEK CAPITAL LETTER SIGMA
+	//	- U+222B INTEGRAL
+	//	- U+3055 HIRAGANA LETTER SA
+	// The testdata does not contain the CJK subfont files, so U+3055 HIRAGANA
+	// LETTER SA (さ) should be rendered as U+FFFD REPLACEMENT CHARACTER (�).
+	//
+	// The missing subfont file will trigger an "open
+	// ../testdata/shinonome/k12.3000: no such file or directory" log message.
+	// This is expected and can be ignored.
+	d.DrawString("SΣ∫さ")
+
+	// Convert the dst image to ASCII art.
+	var out []byte
+	b := dst.Bounds()
+	for y := b.Min.Y; y < b.Max.Y; y++ {
+		out = append(out, '0'+byte(y%10), ' ')
+		for x := b.Min.X; x < b.Max.X; x++ {
+			if dst.RGBAAt(x, y).R > 0 {
+				out = append(out, 'X')
+			} else {
+				out = append(out, '.')
+			}
+		}
+		// Highlight the last row before the baseline. Glyphs like 'S' without
+		// descenders should not affect any pixels whose Y coordinate is >= the
+		// baseline.
+		if y == ascent-1 {
+			out = append(out, '_')
+		}
+		out = append(out, '\n')
+	}
+	os.Stdout.Write(out)
+
+	// Output:
+	// 0 ..................X.........
+	// 1 .................X.X........
+	// 2 .XXXX..XXXXXX....X.....XXX..
+	// 3 X....X.X.........X....XX.XX.
+	// 4 X.......X........X....X.X.X.
+	// 5 X........X.......X....XXX.X.
+	// 6 .XXXX.....X......X....XX.XX.
+	// 7 .....X...X.......X....XX.XX.
+	// 8 .....X..X........X....XXXXX.
+	// 9 X....X.X.........X....XX.XX.
+	// 0 .XXXX..XXXXXX....X.....XXX.._
+	// 1 ...............X.X..........
+	// 2 ................X...........
+}
diff --git a/font/testdata/fixed/7x13.0000 b/font/testdata/fixed/7x13.0000
new file mode 100644
index 0000000..9509cdf
--- /dev/null
+++ b/font/testdata/fixed/7x13.0000
Binary files differ
diff --git a/font/testdata/fixed/7x13.0100 b/font/testdata/fixed/7x13.0100
new file mode 100644
index 0000000..0a79f55
--- /dev/null
+++ b/font/testdata/fixed/7x13.0100
Binary files differ
diff --git a/font/testdata/fixed/7x13.0200 b/font/testdata/fixed/7x13.0200
new file mode 100644
index 0000000..e25247e
--- /dev/null
+++ b/font/testdata/fixed/7x13.0200
Binary files differ
diff --git a/font/testdata/fixed/7x13.0300 b/font/testdata/fixed/7x13.0300
new file mode 100644
index 0000000..86eb33f
--- /dev/null
+++ b/font/testdata/fixed/7x13.0300
Binary files differ
diff --git a/font/testdata/fixed/7x13.0400 b/font/testdata/fixed/7x13.0400
new file mode 100644
index 0000000..43300ad
--- /dev/null
+++ b/font/testdata/fixed/7x13.0400
Binary files differ
diff --git a/font/testdata/fixed/7x13.0500 b/font/testdata/fixed/7x13.0500
new file mode 100644
index 0000000..2d93267
--- /dev/null
+++ b/font/testdata/fixed/7x13.0500
Binary files differ
diff --git a/font/testdata/fixed/7x13.0E00 b/font/testdata/fixed/7x13.0E00
new file mode 100644
index 0000000..7c51a1e
--- /dev/null
+++ b/font/testdata/fixed/7x13.0E00
Binary files differ
diff --git a/font/testdata/fixed/7x13.1000 b/font/testdata/fixed/7x13.1000
new file mode 100644
index 0000000..019698c
--- /dev/null
+++ b/font/testdata/fixed/7x13.1000
Binary files differ
diff --git a/font/testdata/fixed/7x13.1600 b/font/testdata/fixed/7x13.1600
new file mode 100644
index 0000000..f69a977
--- /dev/null
+++ b/font/testdata/fixed/7x13.1600
Binary files differ
diff --git a/font/testdata/fixed/7x13.1E00 b/font/testdata/fixed/7x13.1E00
new file mode 100644
index 0000000..3bc5068
--- /dev/null
+++ b/font/testdata/fixed/7x13.1E00
Binary files differ
diff --git a/font/testdata/fixed/7x13.1F00 b/font/testdata/fixed/7x13.1F00
new file mode 100644
index 0000000..43b320b
--- /dev/null
+++ b/font/testdata/fixed/7x13.1F00
Binary files differ
diff --git a/font/testdata/fixed/7x13.2000 b/font/testdata/fixed/7x13.2000
new file mode 100644
index 0000000..f9244e1
--- /dev/null
+++ b/font/testdata/fixed/7x13.2000
Binary files differ
diff --git a/font/testdata/fixed/7x13.2100 b/font/testdata/fixed/7x13.2100
new file mode 100644
index 0000000..c565abb
--- /dev/null
+++ b/font/testdata/fixed/7x13.2100
Binary files differ
diff --git a/font/testdata/fixed/7x13.2200 b/font/testdata/fixed/7x13.2200
new file mode 100644
index 0000000..a992d35
--- /dev/null
+++ b/font/testdata/fixed/7x13.2200
Binary files differ
diff --git a/font/testdata/fixed/7x13.2300 b/font/testdata/fixed/7x13.2300
new file mode 100644
index 0000000..8ff099d
--- /dev/null
+++ b/font/testdata/fixed/7x13.2300
Binary files differ
diff --git a/font/testdata/fixed/7x13.2400 b/font/testdata/fixed/7x13.2400
new file mode 100644
index 0000000..99927a1
--- /dev/null
+++ b/font/testdata/fixed/7x13.2400
Binary files differ
diff --git a/font/testdata/fixed/7x13.2500 b/font/testdata/fixed/7x13.2500
new file mode 100644
index 0000000..60dc224
--- /dev/null
+++ b/font/testdata/fixed/7x13.2500
Binary files differ
diff --git a/font/testdata/fixed/7x13.2600 b/font/testdata/fixed/7x13.2600
new file mode 100644
index 0000000..1b393c2
--- /dev/null
+++ b/font/testdata/fixed/7x13.2600
Binary files differ
diff --git a/font/testdata/fixed/7x13.2700 b/font/testdata/fixed/7x13.2700
new file mode 100644
index 0000000..c39a572
--- /dev/null
+++ b/font/testdata/fixed/7x13.2700
Binary files differ
diff --git a/font/testdata/fixed/7x13.2800 b/font/testdata/fixed/7x13.2800
new file mode 100644
index 0000000..c7572de
--- /dev/null
+++ b/font/testdata/fixed/7x13.2800
Binary files differ
diff --git a/font/testdata/fixed/7x13.2A00 b/font/testdata/fixed/7x13.2A00
new file mode 100644
index 0000000..71791ac
--- /dev/null
+++ b/font/testdata/fixed/7x13.2A00
Binary files differ
diff --git a/font/testdata/fixed/7x13.3000 b/font/testdata/fixed/7x13.3000
new file mode 100644
index 0000000..fb830f4
--- /dev/null
+++ b/font/testdata/fixed/7x13.3000
Binary files differ
diff --git a/font/testdata/fixed/7x13.FB00 b/font/testdata/fixed/7x13.FB00
new file mode 100644
index 0000000..3a0b30a
--- /dev/null
+++ b/font/testdata/fixed/7x13.FB00
Binary files differ
diff --git a/font/testdata/fixed/7x13.FE00 b/font/testdata/fixed/7x13.FE00
new file mode 100644
index 0000000..3989d26
--- /dev/null
+++ b/font/testdata/fixed/7x13.FE00
Binary files differ
diff --git a/font/testdata/fixed/7x13.FF00 b/font/testdata/fixed/7x13.FF00
new file mode 100644
index 0000000..78ed398
--- /dev/null
+++ b/font/testdata/fixed/7x13.FF00
Binary files differ
diff --git a/font/testdata/fixed/README b/font/testdata/fixed/README
new file mode 100644
index 0000000..a39f8a5
--- /dev/null
+++ b/font/testdata/fixed/README
@@ -0,0 +1,9 @@
+These font files were copied from the Plan 9 Port's font/fixed directory. The
+README in that directory states that: "These fonts are converted from the BDFs
+in the XFree86 distribution. They were all marked as public domain."
+
+The Plan 9 Port is at https://github.com/9fans/plan9port and the copy was made
+from commit a78b1841 (2015-08-18).
+
+The unicode.7x13.font file also refers to a ../shinonome directory, but this
+testdata does not include those subfont files.
diff --git a/font/testdata/fixed/unicode.7x13.font b/font/testdata/fixed/unicode.7x13.font
new file mode 100644
index 0000000..337b428
--- /dev/null
+++ b/font/testdata/fixed/unicode.7x13.font
@@ -0,0 +1,68 @@
+13 10
+0x0000 0x001F 7x13.2400
+0x0000 0x00FF 7x13.0000
+0x0100 0x01FF 7x13.0100
+0x0200 0x02FF 7x13.0200
+0x0300 0x03FF 7x13.0300
+0x0400 0x04FF 7x13.0400
+0x0500 0x05FF 7x13.0500
+0x0E00 0x0EFF 7x13.0E00
+0x1000 0x10FF 7x13.1000
+0x1600 0x16FF 7x13.1600
+0x1E00 0x1EFF 7x13.1E00
+0x1F00 0x1FFF 7x13.1F00
+0x2000 0x20FF 7x13.2000
+0x2100 0x21FF 7x13.2100
+0x2200 0x22FF 7x13.2200
+0x2300 0x23FF 7x13.2300
+0x2400 0x24FF 7x13.2400
+0x2500 0x25FF 7x13.2500
+0x2600 0x26FF 7x13.2600
+0x2700 0x27FF 7x13.2700
+0x2800 0x28FF 7x13.2800
+0x2A00 0x2AFF 7x13.2A00
+0x3000 0x30fe ../shinonome/k12.3000
+0x4e00 0x4ffe ../shinonome/k12.4e00
+0x5005 0x51fe ../shinonome/k12.5005
+0x5200 0x53fa ../shinonome/k12.5200
+0x5401 0x55fe ../shinonome/k12.5401
+0x5606 0x57fc ../shinonome/k12.5606
+0x5800 0x59ff ../shinonome/k12.5800
+0x5a01 0x5bff ../shinonome/k12.5a01
+0x5c01 0x5dfe ../shinonome/k12.5c01
+0x5e02 0x5fff ../shinonome/k12.5e02
+0x600e 0x61ff ../shinonome/k12.600e
+0x6200 0x63fa ../shinonome/k12.6200
+0x6406 0x65fb ../shinonome/k12.6406
+0x6602 0x67ff ../shinonome/k12.6602
+0x6802 0x69ff ../shinonome/k12.6802
+0x6a02 0x6bf3 ../shinonome/k12.6a02
+0x6c08 0x6dfb ../shinonome/k12.6c08
+0x6e05 0x6ffe ../shinonome/k12.6e05
+0x7001 0x71ff ../shinonome/k12.7001
+0x7206 0x73fe ../shinonome/k12.7206
+0x7403 0x75ff ../shinonome/k12.7403
+0x7601 0x77fc ../shinonome/k12.7601
+0x7802 0x79fb ../shinonome/k12.7802
+0x7a00 0x7bf7 ../shinonome/k12.7a00
+0x7c00 0x7dfb ../shinonome/k12.7c00
+0x7e01 0x7ffc ../shinonome/k12.7e01
+0x8000 0x81fe ../shinonome/k12.8000
+0x8201 0x83fd ../shinonome/k12.8201
+0x8403 0x85fe ../shinonome/k12.8403
+0x8602 0x87fe ../shinonome/k12.8602
+0x8805 0x89f8 ../shinonome/k12.8805
+0x8a00 0x8b9a ../shinonome/k12.8a00
+0x8c37 0x8dff ../shinonome/k12.8c37
+0x8e08 0x8ffd ../shinonome/k12.8e08
+0x9000 0x91ff ../shinonome/k12.9000
+0x920d 0x93e8 ../shinonome/k12.920d
+0x9403 0x95e5 ../shinonome/k12.9403
+0x961c 0x97ff ../shinonome/k12.961c
+0x9801 0x99ff ../shinonome/k12.9801
+0x9a01 0x9bf5 ../shinonome/k12.9a01
+0x9c04 0x9dfd ../shinonome/k12.9c04
+0x9e1a 0x9fa0 ../shinonome/k12.9e1a
+0xFB00 0xFBFF 7x13.FB00
+0xFE00 0xFEFF 7x13.FE00
+0xFF00 0xFFFF 7x13.FF00