diff --git a/truetype/runes.go b/truetype/runes.go deleted file mode 100644 index 995d1d4..0000000 --- a/truetype/runes.go +++ /dev/null @@ -1,16 +0,0 @@ -package truetype - -import ( - "bytes" - "io/ioutil" - - "golang.org/x/text/encoding/unicode" - "golang.org/x/text/transform" -) - -func decodeUTF16(b []byte) ([]byte, error) { - r := bytes.NewReader(b) - enc := unicode.UTF16(unicode.BigEndian, unicode.IgnoreBOM) - r2 := transform.NewReader(r, enc.NewDecoder()) - return ioutil.ReadAll(r2) -} diff --git a/truetype/truetype.go b/truetype/truetype.go index 78e1103..6741826 100644 --- a/truetype/truetype.go +++ b/truetype/truetype.go @@ -18,9 +18,13 @@ package truetype // import "github.com/golang/freetype/truetype" import ( + "bytes" "fmt" + "io/ioutil" "golang.org/x/image/math/fixed" + "golang.org/x/text/encoding/unicode" + "golang.org/x/text/transform" ) // An Index is a Font's index of a rune. @@ -335,7 +339,9 @@ func (f *Font) parseName() error { // assume UTF-16, try to parse it if its length is even if value[0] == 0 && length&1 == 0 { var err error - value, err = decodeUTF16(value) + + enc := unicode.UTF16(unicode.BigEndian, unicode.IgnoreBOM) + value, err = ioutil.ReadAll(transform.NewReader(bytes.NewReader(value), enc.NewDecoder())) if err != nil { return err }