summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/image/font/sfnt/cmap.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-04-24 20:11:36 -0400
committerJoram Wilander <jwawilander@gmail.com>2017-04-24 20:11:36 -0400
commitf5437632f486b7d0a0a181c58f113c86d032b02c (patch)
tree407388e3003a210a89f4b2128d7ad656f8b79d26 /vendor/golang.org/x/image/font/sfnt/cmap.go
parent7f68a60f8c228d5604e0566bf84cabb145d16c37 (diff)
downloadchat-f5437632f486b7d0a0a181c58f113c86d032b02c.tar.gz
chat-f5437632f486b7d0a0a181c58f113c86d032b02c.tar.bz2
chat-f5437632f486b7d0a0a181c58f113c86d032b02c.zip
Upgrading server dependancies (#6215)
Diffstat (limited to 'vendor/golang.org/x/image/font/sfnt/cmap.go')
-rw-r--r--vendor/golang.org/x/image/font/sfnt/cmap.go16
1 files changed, 3 insertions, 13 deletions
diff --git a/vendor/golang.org/x/image/font/sfnt/cmap.go b/vendor/golang.org/x/image/font/sfnt/cmap.go
index 42338f1bc..797e9d190 100644
--- a/vendor/golang.org/x/image/font/sfnt/cmap.go
+++ b/vendor/golang.org/x/image/font/sfnt/cmap.go
@@ -5,8 +5,6 @@
package sfnt
import (
- "unicode/utf8"
-
"golang.org/x/text/encoding/charmap"
)
@@ -112,20 +110,12 @@ func (f *Font) makeCachedGlyphIndexFormat0(buf []byte, offset, length uint32) ([
var table [256]byte
copy(table[:], buf[6:])
return buf, func(f *Font, b *Buffer, r rune) (GlyphIndex, error) {
- // TODO: for this closure to be goroutine-safe, the
- // golang.org/x/text/encoding/charmap API needs to allocate a new
- // Encoder and new []byte buffers, for every call to this closure, even
- // though all we want to do is to encode one rune as one byte. We could
- // possibly add some fields in the Buffer struct to re-use these
- // allocations, but a better solution is to improve the charmap API.
- var dst, src [utf8.UTFMax]byte
- n := utf8.EncodeRune(src[:], r)
- _, _, err = charmap.Macintosh.NewEncoder().Transform(dst[:], src[:n], true)
- if err != nil {
+ x, ok := charmap.Macintosh.EncodeRune(r)
+ if !ok {
// The source rune r is not representable in the Macintosh-Roman encoding.
return 0, nil
}
- return GlyphIndex(table[dst[0]]), nil
+ return GlyphIndex(table[x]), nil
}, nil
}