From d103ed6ca97ca5a2669f6cf5fe4b3d2a9c945f26 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Wed, 17 May 2017 16:51:25 -0400 Subject: Upgrading server dependancies (#6431) --- .../x/image/font/sfnt/proprietary_test.go | 69 +++++++++++++++++++++- vendor/golang.org/x/image/font/sfnt/sfnt.go | 8 ++- vendor/golang.org/x/image/tiff/lzw/reader.go | 17 ++---- 3 files changed, 79 insertions(+), 15 deletions(-) (limited to 'vendor/golang.org/x/image') diff --git a/vendor/golang.org/x/image/font/sfnt/proprietary_test.go b/vendor/golang.org/x/image/font/sfnt/proprietary_test.go index 2df6f6ce6..dcafdd4c7 100644 --- a/vendor/golang.org/x/image/font/sfnt/proprietary_test.go +++ b/vendor/golang.org/x/image/font/sfnt/proprietary_test.go @@ -19,7 +19,11 @@ End User License Agreement (EULA) and a CAB format decoder. These tests assume that such fonts have already been installed. You may need to specify the directories for these fonts: -go test golang.org/x/image/font/sfnt -args -proprietary -adobeDir=$HOME/fonts/adobe -appleDir=$HOME/fonts/apple -microsoftDir=$HOME/fonts/microsoft +go test golang.org/x/image/font/sfnt -args -proprietary \ + -adobeDir=$HOME/fonts/adobe \ + -appleDir=$HOME/fonts/apple \ + -dejavuDir=$HOME/fonts/dejavu \ + -microsoftDir=$HOME/fonts/microsoft To only run those tests for the Microsoft fonts: @@ -72,6 +76,13 @@ var ( "directory name for the Apple proprietary fonts", ) + dejavuDir = flag.String( + "dejavuDir", + // Get the fonts from https://dejavu-fonts.github.io/ + "", + "directory name for the DejaVu proprietary fonts", + ) + microsoftDir = flag.String( "microsoftDir", "/usr/share/fonts/truetype/msttcorefonts", @@ -143,6 +154,18 @@ func TestProprietaryAppleHiragino1(t *testing.T) { testProprietary(t, "apple", "ヒラギノ角ゴシック W0.ttc?1", 9000, -1) } +func TestProprietaryDejaVuSansExtraLight(t *testing.T) { + testProprietary(t, "dejavu", "DejaVuSans-ExtraLight.ttf", 2000, -1) +} + +func TestProprietaryDejaVuSansMono(t *testing.T) { + testProprietary(t, "dejavu", "DejaVuSansMono.ttf", 3300, -1) +} + +func TestProprietaryDejaVuSerif(t *testing.T) { + testProprietary(t, "dejavu", "DejaVuSerif.ttf", 3500, -1) +} + func TestProprietaryMicrosoftArial(t *testing.T) { testProprietary(t, "microsoft", "Arial.ttf", 1200, -1) } @@ -192,6 +215,8 @@ func testProprietary(t *testing.T, proprietor, filename string, minNumGlyphs, fi dir = *adobeDir case "apple": dir = *appleDir + case "dejavu": + dir = *dejavuDir case "microsoft": dir = *microsoftDir default: @@ -375,6 +400,10 @@ var proprietaryVersions = map[string]string{ "apple/ヒラギノ角ゴシック W0.ttc?0": "11.0d7e1", "apple/ヒラギノ角ゴシック W0.ttc?1": "11.0d7e1", + "dejavu/DejaVuSans-ExtraLight.ttf": "Version 2.37", + "dejavu/DejaVuSansMono.ttf": "Version 2.37", + "dejavu/DejaVuSerif.ttf": "Version 2.37", + "microsoft/Arial.ttf": "Version 2.82", "microsoft/Arial.ttf?0": "Version 2.82", "microsoft/Comic_Sans_MS.ttf": "Version 2.10", @@ -403,6 +432,10 @@ var proprietaryFullNames = map[string]string{ "apple/ヒラギノ角ゴシック W0.ttc?0": "Hiragino Sans W0", "apple/ヒラギノ角ゴシック W0.ttc?1": ".Hiragino Kaku Gothic Interface W0", + "dejavu/DejaVuSans-ExtraLight.ttf": "DejaVu Sans ExtraLight", + "dejavu/DejaVuSansMono.ttf": "DejaVu Sans Mono", + "dejavu/DejaVuSerif.ttf": "DejaVu Serif", + "microsoft/Arial.ttf": "Arial", "microsoft/Arial.ttf?0": "Arial", "microsoft/Comic_Sans_MS.ttf": "Comic Sans MS", @@ -469,6 +502,11 @@ var proprietaryGlyphIndexTestCases = map[string]map[rune]GlyphIndex{ '\U0001f100': 0, // U+0001F100 DIGIT ZERO FULL STOP }, + "dejavu/DejaVuSerif.ttf": { + '\u0041': 36, // U+0041 LATIN CAPITAL LETTER A + '\u1e00': 1418, // U+1E00 LATIN CAPITAL LETTER A WITH RING BELOW + }, + "microsoft/Arial.ttf": { '\u0041': 36, // U+0041 LATIN CAPITAL LETTER A '\u00f1': 120, // U+00F1 LATIN SMALL LETTER N WITH TILDE @@ -930,6 +968,23 @@ var proprietaryGlyphTestCases = map[string]map[rune][]Segment{ }, }, + "dejavu/DejaVuSans-ExtraLight.ttf": { + 'i': { + // - contour #0 + moveTo(230, 1120), + lineTo(322, 1120), + lineTo(322, 0), + lineTo(230, 0), + lineTo(230, 1120), + // - contour #1 + moveTo(230, 1556), + lineTo(322, 1556), + lineTo(322, 1430), + lineTo(230, 1430), + lineTo(230, 1556), + }, + }, + "microsoft/Arial.ttf": { ',': { // - contour #0 @@ -1109,6 +1164,18 @@ type kernTestCase struct { // proprietaryKernTestCases hold a sample of each font's kerning pairs. The // numerical values can be verified by running the ttx tool. var proprietaryKernTestCases = map[string][]kernTestCase{ + "dejavu/DejaVuSans-ExtraLight.ttf": { + {2048, font.HintingNone, [2]rune{'A', 'A'}, 57}, + {2048, font.HintingNone, [2]rune{'W', 'A'}, -112}, + // U+00C1 LATIN CAPITAL LETTER A WITH ACUTE + // U+01FA LATIN CAPITAL LETTER A WITH RING ABOVE AND ACUTE + // U+1E82 LATIN CAPITAL LETTER W WITH ACUTE + {2048, font.HintingNone, [2]rune{'\u00c1', 'A'}, 57}, + // TODO: enable these next two test cases, when we support multiple + // kern subtables. + // {2048, font.HintingNone, [2]rune{'\u01fa', 'A'}, 57}, + // {2048, font.HintingNone, [2]rune{'\u1e82', 'A'}, -112}, + }, "microsoft/Arial.ttf": { {2048, font.HintingNone, [2]rune{'A', 'V'}, -152}, // U+03B8 GREEK SMALL LETTER THETA diff --git a/vendor/golang.org/x/image/font/sfnt/sfnt.go b/vendor/golang.org/x/image/font/sfnt/sfnt.go index 5cb1225ef..34587da75 100644 --- a/vendor/golang.org/x/image/font/sfnt/sfnt.go +++ b/vendor/golang.org/x/image/font/sfnt/sfnt.go @@ -869,9 +869,11 @@ func (f *Font) parseKern(buf []byte) (buf1 []byte, kernNumPairs, kernOffset int3 switch version := u16(buf); version { case 0: - // TODO: support numTables != 1. Testing that requires finding such a font. - if numTables := int(u16(buf[2:])); numTables != 1 { - return nil, 0, 0, errUnsupportedKernTable + if numTables := int(u16(buf[2:])); numTables == 0 { + return buf, 0, 0, nil + } else if numTables > 1 { + // TODO: support multiple subtables. For now, fall through and use + // only the first one. } return f.parseKernVersion0(buf, offset, length) case 1: diff --git a/vendor/golang.org/x/image/tiff/lzw/reader.go b/vendor/golang.org/x/image/tiff/lzw/reader.go index ad35819f5..51ae39f8a 100644 --- a/vendor/golang.org/x/image/tiff/lzw/reader.go +++ b/vendor/golang.org/x/image/tiff/lzw/reader.go @@ -147,6 +147,7 @@ func (d *decoder) Read(b []byte) (int, error) { // litWidth is the width in bits of literal codes. func (d *decoder) decode() { // Loop over the code stream, converting codes into decompressed bytes. +loop: for { code, err := d.read(d) if err != nil { @@ -154,8 +155,7 @@ func (d *decoder) decode() { err = io.ErrUnexpectedEOF } d.err = err - d.flush() - return + break } switch { case code < d.clear: @@ -174,9 +174,8 @@ func (d *decoder) decode() { d.last = decoderInvalidCode continue case code == d.eof: - d.flush() d.err = io.EOF - return + break loop case code <= d.hi: c, i := code, len(d.output)-1 if code == d.hi { @@ -206,8 +205,7 @@ func (d *decoder) decode() { } default: d.err = errors.New("lzw: invalid code") - d.flush() - return + break loop } d.last, d.hi = code, d.hi+1 if d.hi+1 >= d.overflow { // NOTE: the "+1" is where TIFF's LZW differs from the standard algorithm. @@ -219,13 +217,10 @@ func (d *decoder) decode() { } } if d.o >= flushBuffer { - d.flush() - return + break } } -} - -func (d *decoder) flush() { + // Flush pending output. d.toRead = d.output[:d.o] d.o = 0 } -- cgit v1.2.3-1-g7c22