summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/image
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2018-01-16 12:03:31 -0500
committerGitHub <noreply@github.com>2018-01-16 12:03:31 -0500
commit2fa7c464f019f67c5c0494aaf5ac0f5ecc1ee7a7 (patch)
treee08ff912e1924c06939f314168c3362d6f1ec0de /vendor/golang.org/x/image
parentf5c8a71698d0a7a16c68be220e49fe64bfee7f5c (diff)
downloadchat-2fa7c464f019f67c5c0494aaf5ac0f5ecc1ee7a7.tar.gz
chat-2fa7c464f019f67c5c0494aaf5ac0f5ecc1ee7a7.tar.bz2
chat-2fa7c464f019f67c5c0494aaf5ac0f5ecc1ee7a7.zip
Updated dependencies and added avct/uasurfer (#8089)
* Updated dependencies and added avct/uasurfer * Added uasurfer to NOTICE.txt
Diffstat (limited to 'vendor/golang.org/x/image')
-rw-r--r--vendor/golang.org/x/image/draw/gen.go5
-rw-r--r--vendor/golang.org/x/image/draw/impl.go10
-rw-r--r--vendor/golang.org/x/image/draw/scale_test.go11
-rw-r--r--vendor/golang.org/x/image/font/opentype/face.go103
-rw-r--r--vendor/golang.org/x/image/font/opentype/face_test.go90
-rw-r--r--vendor/golang.org/x/image/font/opentype/opentype.go7
6 files changed, 220 insertions, 6 deletions
diff --git a/vendor/golang.org/x/image/draw/gen.go b/vendor/golang.org/x/image/draw/gen.go
index 65a712350..822bb6a50 100644
--- a/vendor/golang.org/x/image/draw/gen.go
+++ b/vendor/golang.org/x/image/draw/gen.go
@@ -877,8 +877,9 @@ func relName(s string) string {
const (
codeRoot = `
func (z $receiver) Scale(dst Image, dr image.Rectangle, src image.Image, sr image.Rectangle, op Op, opts *Options) {
- // Try to simplify a Scale to a Copy.
- if dr.Size() == sr.Size() {
+ // Try to simplify a Scale to a Copy when DstMask is not specified.
+ // If DstMask is not nil, Copy will call Scale back with same dr and sr, and cause stack overflow.
+ if dr.Size() == sr.Size() && (opts == nil || opts.DstMask == nil) {
Copy(dst, dr.Min, src, sr, op, opts)
return
}
diff --git a/vendor/golang.org/x/image/draw/impl.go b/vendor/golang.org/x/image/draw/impl.go
index 637887be6..75498adbd 100644
--- a/vendor/golang.org/x/image/draw/impl.go
+++ b/vendor/golang.org/x/image/draw/impl.go
@@ -11,8 +11,9 @@ import (
)
func (z nnInterpolator) Scale(dst Image, dr image.Rectangle, src image.Image, sr image.Rectangle, op Op, opts *Options) {
- // Try to simplify a Scale to a Copy.
- if dr.Size() == sr.Size() {
+ // Try to simplify a Scale to a Copy when DstMask is not specified.
+ // If DstMask is not nil, Copy will call Scale back with same dr and sr, and cause stack overflow.
+ if dr.Size() == sr.Size() && (opts == nil || opts.DstMask == nil) {
Copy(dst, dr.Min, src, sr, op, opts)
return
}
@@ -1048,8 +1049,9 @@ func (nnInterpolator) transform_Image_Image_Src(dst Image, dr, adr image.Rectang
}
func (z ablInterpolator) Scale(dst Image, dr image.Rectangle, src image.Image, sr image.Rectangle, op Op, opts *Options) {
- // Try to simplify a Scale to a Copy.
- if dr.Size() == sr.Size() {
+ // Try to simplify a Scale to a Copy when DstMask is not specified.
+ // If DstMask is not nil, Copy will call Scale back with same dr and sr, and cause stack overflow.
+ if dr.Size() == sr.Size() && (opts == nil || opts.DstMask == nil) {
Copy(dst, dr.Min, src, sr, op, opts)
return
}
diff --git a/vendor/golang.org/x/image/draw/scale_test.go b/vendor/golang.org/x/image/draw/scale_test.go
index 5e184c24e..ea41940cd 100644
--- a/vendor/golang.org/x/image/draw/scale_test.go
+++ b/vendor/golang.org/x/image/draw/scale_test.go
@@ -551,6 +551,17 @@ func TestRectDstMask(t *testing.T) {
}
}
+func TestDstMaskSameSizeCopy(t *testing.T) {
+ bounds := image.Rect(0, 0, 42, 42)
+ src := image.Opaque
+ dst := image.NewRGBA(bounds)
+ mask := image.NewRGBA(bounds)
+
+ Copy(dst, image.ZP, src, bounds, Src, &Options{
+ DstMask: mask,
+ })
+}
+
// TODO: delete this wrapper type once Go 1.5 is released, where an
// image.Rectangle implements image.Image.
type rectImage image.Rectangle
diff --git a/vendor/golang.org/x/image/font/opentype/face.go b/vendor/golang.org/x/image/font/opentype/face.go
new file mode 100644
index 000000000..88c28da88
--- /dev/null
+++ b/vendor/golang.org/x/image/font/opentype/face.go
@@ -0,0 +1,103 @@
+// Copyright 2017 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 opentype
+
+import (
+ "image"
+
+ "golang.org/x/image/font"
+ "golang.org/x/image/font/sfnt"
+ "golang.org/x/image/math/fixed"
+)
+
+// FaceOptions describes the possible options given to NewFace when
+// creating a new font.Face from a sfnt.Font.
+type FaceOptions struct {
+ Size float64 // Size is the font size in points
+ DPI float64 // DPI is the dots per inch resolution
+ Hinting font.Hinting // Hinting selects how to quantize a vector font's glyph nodes
+}
+
+func defaultFaceOptions() *FaceOptions {
+ return &FaceOptions{
+ Size: 12,
+ DPI: 72,
+ Hinting: font.HintingNone,
+ }
+}
+
+// Face implements the font.Face interface for sfnt.Font values.
+type Face struct {
+ f *sfnt.Font
+ hinting font.Hinting
+ scale fixed.Int26_6
+
+ buf sfnt.Buffer
+}
+
+// NewFace returns a new font.Face for the given sfnt.Font.
+// if opts is nil, sensible defaults will be used.
+func NewFace(f *sfnt.Font, opts *FaceOptions) (font.Face, error) {
+ if opts == nil {
+ opts = defaultFaceOptions()
+ }
+ face := &Face{
+ f: f,
+ hinting: opts.Hinting,
+ scale: fixed.Int26_6(0.5 + (opts.Size * opts.DPI * 64 / 72)),
+ }
+ return face, nil
+}
+
+// Close satisfies the font.Face interface.
+func (f *Face) Close() error {
+ return nil
+}
+
+// Metrics satisfies the font.Face interface.
+func (f *Face) Metrics() font.Metrics {
+ m, err := f.f.Metrics(&f.buf, f.scale, f.hinting)
+ if err != nil {
+ return font.Metrics{}
+ }
+ return m
+}
+
+// Kern satisfies the font.Face interface.
+func (f *Face) Kern(r0, r1 rune) fixed.Int26_6 {
+ x0 := f.index(r0)
+ x1 := f.index(r1)
+ k, err := f.f.Kern(&f.buf, x0, x1, fixed.Int26_6(f.f.UnitsPerEm()), f.hinting)
+ if err != nil {
+ return 0
+ }
+ return k
+}
+
+// Glyph satisfies the font.Face interface.
+func (f *Face) Glyph(dot fixed.Point26_6, r rune) (dr image.Rectangle, mask image.Image, maskp image.Point, advance fixed.Int26_6, ok bool) {
+ panic("not implemented")
+}
+
+// GlyphBounds satisfies the font.Face interface.
+func (f *Face) GlyphBounds(r rune) (bounds fixed.Rectangle26_6, advance fixed.Int26_6, ok bool) {
+ advance, ok = f.GlyphAdvance(r)
+ if !ok {
+ return bounds, advance, ok
+ }
+ panic("not implemented")
+}
+
+// GlyphAdvance satisfies the font.Face interface.
+func (f *Face) GlyphAdvance(r rune) (advance fixed.Int26_6, ok bool) {
+ idx := f.index(r)
+ advance, err := f.f.GlyphAdvance(&f.buf, idx, f.scale, f.hinting)
+ return advance, err == nil
+}
+
+func (f *Face) index(r rune) sfnt.GlyphIndex {
+ x, _ := f.f.GlyphIndex(&f.buf, r)
+ return x
+}
diff --git a/vendor/golang.org/x/image/font/opentype/face_test.go b/vendor/golang.org/x/image/font/opentype/face_test.go
new file mode 100644
index 000000000..224b0f2fa
--- /dev/null
+++ b/vendor/golang.org/x/image/font/opentype/face_test.go
@@ -0,0 +1,90 @@
+// Copyright 2017 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 opentype
+
+import (
+ "testing"
+
+ "golang.org/x/image/font"
+ "golang.org/x/image/font/gofont/goregular"
+ "golang.org/x/image/font/sfnt"
+ "golang.org/x/image/math/fixed"
+)
+
+var (
+ regular font.Face
+)
+
+func init() {
+ font, err := sfnt.Parse(goregular.TTF)
+ if err != nil {
+ panic(err)
+ }
+
+ regular, err = NewFace(font, defaultFaceOptions())
+ if err != nil {
+ panic(err)
+ }
+}
+
+func TestFaceGlyphAdvance(t *testing.T) {
+ for _, test := range []struct {
+ r rune
+ want fixed.Int26_6
+ }{
+ {' ', 213},
+ {'A', 512},
+ {'Á', 512},
+ {'Æ', 768},
+ {'i', 189},
+ {'x', 384},
+ } {
+ got, ok := regular.GlyphAdvance(test.r)
+ if !ok {
+ t.Errorf("could not get glyph advance width for %q", test.r)
+ continue
+ }
+
+ if got != test.want {
+ t.Errorf("%q: glyph advance width=%d. want=%d", test.r, got, test.want)
+ continue
+ }
+ }
+}
+
+func TestFaceKern(t *testing.T) {
+ // FIXME(sbinet) there is no kerning with gofont/goregular
+ for _, test := range []struct {
+ r1, r2 rune
+ want fixed.Int26_6
+ }{
+ {'A', 'A', 0},
+ {'A', 'V', 0},
+ {'V', 'A', 0},
+ {'A', 'v', 0},
+ {'W', 'a', 0},
+ {'W', 'i', 0},
+ {'Y', 'i', 0},
+ {'f', '(', 0},
+ {'f', 'f', 0},
+ {'f', 'i', 0},
+ {'T', 'a', 0},
+ {'T', 'e', 0},
+ } {
+ got := regular.Kern(test.r1, test.r2)
+ if got != test.want {
+ t.Errorf("(%q, %q): glyph kerning=%d. want=%d", test.r1, test.r2, got, test.want)
+ continue
+ }
+ }
+}
+
+func TestFaceMetrics(t *testing.T) {
+ want := font.Metrics{Height: 768, Ascent: 726, Descent: 162}
+ got := regular.Metrics()
+ if got != want {
+ t.Fatalf("metrics failed. got=%#v. want=%#v", got, want)
+ }
+}
diff --git a/vendor/golang.org/x/image/font/opentype/opentype.go b/vendor/golang.org/x/image/font/opentype/opentype.go
new file mode 100644
index 000000000..452e952b8
--- /dev/null
+++ b/vendor/golang.org/x/image/font/opentype/opentype.go
@@ -0,0 +1,7 @@
+// Copyright 2017 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 opentype implements the font.Face interface based on SFNT
+// font file formats.
+package opentype // import "golang.org/x/image/font/opentype"