summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/image/font/sfnt/proprietary_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/image/font/sfnt/proprietary_test.go')
-rw-r--r--vendor/golang.org/x/image/font/sfnt/proprietary_test.go415
1 files changed, 407 insertions, 8 deletions
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 ccf013d1d..2df6f6ce6 100644
--- a/vendor/golang.org/x/image/font/sfnt/proprietary_test.go
+++ b/vendor/golang.org/x/image/font/sfnt/proprietary_test.go
@@ -80,7 +80,7 @@ var (
)
func TestProprietaryAdobeSourceCodeProOTF(t *testing.T) {
- testProprietary(t, "adobe", "SourceCodePro-Regular.otf", 1500, 34)
+ testProprietary(t, "adobe", "SourceCodePro-Regular.otf", 1500, -1)
}
func TestProprietaryAdobeSourceCodeProTTF(t *testing.T) {
@@ -88,11 +88,11 @@ func TestProprietaryAdobeSourceCodeProTTF(t *testing.T) {
}
func TestProprietaryAdobeSourceHanSansSC(t *testing.T) {
- testProprietary(t, "adobe", "SourceHanSansSC-Regular.otf", 65535, 2)
+ testProprietary(t, "adobe", "SourceHanSansSC-Regular.otf", 65535, -1)
}
func TestProprietaryAdobeSourceSansProOTF(t *testing.T) {
- testProprietary(t, "adobe", "SourceSansPro-Regular.otf", 1800, 34)
+ testProprietary(t, "adobe", "SourceSansPro-Regular.otf", 1800, -1)
}
func TestProprietaryAdobeSourceSansProTTF(t *testing.T) {
@@ -111,12 +111,36 @@ func TestProprietaryAppleGeezaPro1(t *testing.T) {
testProprietary(t, "apple", "GeezaPro.ttc?1", 1700, -1)
}
+func TestProprietaryAppleHelvetica0(t *testing.T) {
+ testProprietary(t, "apple", "Helvetica.dfont?0", 2100, -1)
+}
+
+func TestProprietaryAppleHelvetica1(t *testing.T) {
+ testProprietary(t, "apple", "Helvetica.dfont?1", 2100, -1)
+}
+
+func TestProprietaryAppleHelvetica2(t *testing.T) {
+ testProprietary(t, "apple", "Helvetica.dfont?2", 2100, -1)
+}
+
+func TestProprietaryAppleHelvetica3(t *testing.T) {
+ testProprietary(t, "apple", "Helvetica.dfont?3", 2100, -1)
+}
+
+func TestProprietaryAppleHelvetica4(t *testing.T) {
+ testProprietary(t, "apple", "Helvetica.dfont?4", 1300, -1)
+}
+
+func TestProprietaryAppleHelvetica5(t *testing.T) {
+ testProprietary(t, "apple", "Helvetica.dfont?5", 1300, -1)
+}
+
func TestProprietaryAppleHiragino0(t *testing.T) {
- testProprietary(t, "apple", "ヒラギノ角ゴシック W0.ttc?0", 9000, 6)
+ testProprietary(t, "apple", "ヒラギノ角ゴシック W0.ttc?0", 9000, -1)
}
func TestProprietaryAppleHiragino1(t *testing.T) {
- testProprietary(t, "apple", "ヒラギノ角ゴシック W0.ttc?1", 9000, 6)
+ testProprietary(t, "apple", "ヒラギノ角ゴシック W0.ttc?1", 9000, -1)
}
func TestProprietaryMicrosoftArial(t *testing.T) {
@@ -302,14 +326,26 @@ kernLoop:
continue
}
}
+
+ for x, want := range proprietaryFDSelectTestCases[qualifiedFilename] {
+ got, err := f.cached.glyphData.fdSelect.lookup(f, &buf, x)
+ if err != nil {
+ t.Errorf("fdSelect.lookup(%d): %v", x, err)
+ continue
+ }
+ if got != want {
+ t.Errorf("fdSelect.lookup(%d): got %d, want %d", x, got, want)
+ continue
+ }
+ }
}
// proprietaryNumFonts holds the expected number of fonts in each collection,
// or 1 for a single font. It is not necessarily an exhaustive list of all
// proprietary fonts tested.
var proprietaryNumFonts = map[string]int{
+ "apple/Helvetica.dfont?0": 6,
"apple/ヒラギノ角ゴシック W0.ttc?0": 2,
- "apple/ヒラギノ角ゴシック W0.ttc?1": 2,
"microsoft/Arial.ttf?0": 1,
}
@@ -330,6 +366,12 @@ var proprietaryVersions = map[string]string{
"apple/Apple Symbols.ttf": "12.0d3e10",
"apple/GeezaPro.ttc?0": "12.0d1e3",
"apple/GeezaPro.ttc?1": "12.0d1e3",
+ "apple/Helvetica.dfont?0": "12.0d1e3",
+ "apple/Helvetica.dfont?1": "12.0d1e3",
+ "apple/Helvetica.dfont?2": "12.0d1e3",
+ "apple/Helvetica.dfont?3": "12.0d1e3",
+ "apple/Helvetica.dfont?4": "12.0d1e3",
+ "apple/Helvetica.dfont?5": "12.0d1e3",
"apple/ヒラギノ角ゴシック W0.ttc?0": "11.0d7e1",
"apple/ヒラギノ角ゴシック W0.ttc?1": "11.0d7e1",
@@ -352,6 +394,12 @@ var proprietaryFullNames = map[string]string{
"apple/Apple Symbols.ttf": "Apple Symbols",
"apple/GeezaPro.ttc?0": "Geeza Pro Regular",
"apple/GeezaPro.ttc?1": "Geeza Pro Bold",
+ "apple/Helvetica.dfont?0": "Helvetica",
+ "apple/Helvetica.dfont?1": "Helvetica Bold",
+ "apple/Helvetica.dfont?2": "Helvetica Oblique",
+ "apple/Helvetica.dfont?3": "Helvetica Bold Oblique",
+ "apple/Helvetica.dfont?4": "Helvetica Light",
+ "apple/Helvetica.dfont?5": "Helvetica Light Oblique",
"apple/ヒラギノ角ゴシック W0.ttc?0": "Hiragino Sans W0",
"apple/ヒラギノ角ゴシック W0.ttc?1": ".Hiragino Kaku Gothic Interface W0",
@@ -410,6 +458,17 @@ var proprietaryGlyphIndexTestCases = map[string]map[rune]GlyphIndex{
'\u2030': 1728, // U+2030 PER MILLE SIGN
},
+ "apple/Helvetica.dfont?0": {
+ '\u0041': 36, // U+0041 LATIN CAPITAL LETTER A
+ '\u00f1': 120, // U+00F1 LATIN SMALL LETTER N WITH TILDE
+ '\u0401': 473, // U+0401 CYRILLIC CAPITAL LETTER IO
+ '\u200d': 611, // U+200D ZERO WIDTH JOINER
+ '\u20ab': 1743, // U+20AB DONG SIGN
+ '\u2229': 0, // U+2229 INTERSECTION
+ '\u04e9': 1208, // U+04E9 CYRILLIC SMALL LETTER BARRED O
+ '\U0001f100': 0, // U+0001F100 DIGIT ZERO FULL STOP
+ },
+
"microsoft/Arial.ttf": {
'\u0041': 36, // U+0041 LATIN CAPITAL LETTER A
'\u00f1': 120, // U+00F1 LATIN SMALL LETTER N WITH TILDE
@@ -442,13 +501,88 @@ var proprietaryGlyphIndexTestCases = map[string]map[rune]GlyphIndex{
// proprietaryGlyphTestCases hold a sample of each font's glyph vectors. The
// numerical values can be verified by running the ttx tool, remembering that:
-// - for PostScript glyphs, ttx coordinates are relative, and hstem / vstem
-// operators are hinting-related and can be ignored.
+// - for PostScript glyphs, ttx coordinates are relative.
// - for TrueType glyphs, ttx coordinates are absolute, and consecutive
// off-curve points implies an on-curve point at the midpoint.
var proprietaryGlyphTestCases = map[string]map[rune][]Segment{
+ "adobe/SourceHanSansSC-Regular.otf": {
+ '!': {
+ // -312 123 callsubr # 123 + bias = 230
+ // : # Arg stack is [-312].
+ // : -13 140 -119 -21 return
+ // : # Arg stack is [-312 -13 140 -119 -21].
+ // 120 callsubr # 120 + bias = 227
+ // : # Arg stack is [-312 -13 140 -119 -21].
+ // : hstemhm
+ // : 95 132 -103 75 return
+ // : # Arg stack is [95 132 -103 75].
+ // hintmask 01010000
+ // 8 callsubr # 8 + bias = 115
+ // : # Arg stack is [].
+ // : 130 221 rmoveto
+ moveTo(130, 221),
+ // : 63 hlineto
+ lineTo(193, 221),
+ // : 12 424 3 -735 callgsubr # -735 + bias = 396
+ // : : # Arg stack is [12 424 3].
+ // : : 104 rlineto
+ lineTo(205, 645),
+ lineTo(208, 749),
+ // : : -93 hlineto
+ lineTo(115, 749),
+ // : : 3 -104 rlineto
+ lineTo(118, 645),
+ // : : return
+ // : : # Arg stack is [].
+ // : return
+ // : # Arg stack is [].
+ // hintmask 01100000
+ // 106 callsubr # 106 + bias = 213
+ // : # Arg stack is [].
+ // : 43 -658 rmoveto
+ lineTo(130, 221),
+ moveTo(161, -13),
+ // : 37 29 28 41 return
+ // : # Arg stack is [37 29 28 41].
+ // hvcurveto
+ cubeTo(198, -13, 227, 15, 227, 56),
+ // hintmask 10100000
+ // 41 -29 30 -37 -36 -30 -30 -41 vhcurveto
+ cubeTo(227, 97, 198, 127, 161, 127),
+ cubeTo(125, 127, 95, 97, 95, 56),
+ // hintmask 01100000
+ // 111 callsubr # 111 + bias = 218
+ // : # Arg stack is [].
+ // : -41 30 -28 36 vhcurveto
+ cubeTo(95, 15, 125, -13, 161, -13),
+ // : endchar
+ },
+
+ '二': { // U+4E8C <CJK Ideograph> "two; twice"
+ // 23 81 510 79 hstem
+ // 60 881 cntrmask 11000000
+ // 144 693 rmoveto
+ moveTo(144, 693),
+ // -79 713 79 vlineto
+ lineTo(144, 614),
+ lineTo(857, 614),
+ lineTo(857, 693),
+ // -797 -589 rmoveto
+ lineTo(144, 693),
+ moveTo(60, 104),
+ // -81 881 81 vlineto
+ lineTo(60, 23),
+ lineTo(941, 23),
+ lineTo(941, 104),
+ // endchar
+ lineTo(60, 104),
+ },
+ },
+
"adobe/SourceSansPro-Regular.otf": {
',': {
+ // -309 -1 115 hstem
+ // 137 61 vstem
// 67 -170 rmoveto
moveTo(67, -170),
// 81 34 50 67 86 vvcurveto
@@ -461,9 +595,12 @@ var proprietaryGlyphTestCases = map[string]map[rune][]Segment{
// 1 -53 -34 -44 -57 -25 rrcurveto
cubeTo(138, -53, 104, -97, 47, -122),
// endchar
+ lineTo(67, -170),
},
'Q': {
+ // 106 -165 70 87 65 538 73 hstem
+ // 52 86 388 87 vstem
// 332 57 rmoveto
moveTo(332, 57),
// -117 -77 106 168 163 77 101 117 117 77 -101 -163 -168 -77 -106 -117 hvcurveto
@@ -492,6 +629,78 @@ var proprietaryGlyphTestCases = map[string]map[rune][]Segment{
// endchar
},
+ 'ĩ': { // U+0129 LATIN SMALL LETTER I WITH TILDE
+ // 92 callgsubr # 92 + bias = 199.
+ // : # Arg stack is [].
+ // : -312 21 85 callgsubr # 85 + bias = 192.
+ // : : # Arg stack is [-312 21].
+ // : : -21 486 -20 return
+ // : : # Arg stack is [-312 21 -21 486 -20].
+ // : return
+ // : # Arg stack is [-312 21 -21 486 -20].
+ // 111 45 callsubr # 45 + bias = 152
+ // : # Arg stack is [-312 21 -21 486 -20 111].
+ // : 60 24 60 -9 216 callgsubr # 216 + bias = 323
+ // : : # Arg stack is [-312 21 -21 486 -20 111 60 24 60 -9].
+ // : : -20 24 -20 hstemhm
+ // : : return
+ // : : # Arg stack is [].
+ // : return
+ // : # Arg stack is [].
+ // -50 55 77 82 77 55 hintmask 1101000100000000
+ // 134 callsubr # 134 + bias = 241
+ // : # Arg stack is [].
+ // : 82 hmoveto
+ moveTo(82, 0),
+ // : 82 127 callsubr # 127 + bias = 234
+ // : : # Arg stack is [82].
+ // : : 486 -82 hlineto
+ lineTo(164, 0),
+ lineTo(164, 486),
+ lineTo(82, 486),
+ // : : return
+ // : : # Arg stack is [].
+ // : return
+ // : # Arg stack is [].
+ // hintmask 1110100110000000
+ // 113 91 15 callgsubr # 15 + bias = 122
+ // : # Arg stack is [113 91].
+ // : rmoveto
+ lineTo(82, 0),
+ moveTo(195, 577),
+ // : 69 29 58 77 3 hvcurveto
+ cubeTo(264, 577, 293, 635, 296, 712),
+ // : return
+ // : # Arg stack is [].
+ // hintmask 1110010110000000
+ // -58 callsubr # -58 + bias = 49
+ // : # Arg stack is [].
+ // : -55 4 rlineto
+ lineTo(241, 716),
+ // : -46 -3 -14 -33 -29 -47 -26 84 -71 hhcurveto
+ cubeTo(238, 670, 224, 637, 195, 637),
+ cubeTo(148, 637, 122, 721, 51, 721),
+ // : return
+ // : # Arg stack is [].
+ // hintmask 1101001100000000
+ // -70 callgsubr # -70 + bias = 37
+ // : # Arg stack is [].
+ // : -69 -29 -58 -78 -3 hvcurveto
+ cubeTo(-18, 721, -47, 663, -50, 585),
+ // : 55 -3 rlineto
+ lineTo(5, 582),
+ // : 47 3 14 32 30 hhcurveto
+ cubeTo(8, 629, 22, 661, 52, 661),
+ // : return
+ // : # Arg stack is [].
+ // hintmask 1110100110000000
+ // 51 callsubr # 51 + bias = 158
+ // : # Arg stack is [].
+ // : 46 26 -84 71 hhcurveto
+ cubeTo(98, 661, 124, 577, 195, 577),
+ // : endchar
+ },
+
'ī': { // U+012B LATIN SMALL LETTER I WITH MACRON
// 92 callgsubr # 92 + bias = 199.
// : # Arg stack is [].
@@ -524,12 +733,14 @@ var proprietaryGlyphTestCases = map[string]map[rune][]Segment{
// -92 115 -60 callgsubr # -60 + bias = 47
// : # Arg stack is [-92 115].
// : rmoveto
+ lineTo(82, 0),
moveTo(-10, 601),
// : 266 57 -266 hlineto
lineTo(256, 601),
lineTo(256, 658),
lineTo(-10, 658),
// : endchar
+ lineTo(-10, 601),
},
'ĭ': { // U+012D LATIN SMALL LETTER I WITH BREVE
@@ -560,6 +771,7 @@ var proprietaryGlyphTestCases = map[string]map[rune][]Segment{
// 42 85 143 callsubr # 143 + bias = 250
// : # Arg stack is [42 85].
// : rmoveto
+ lineTo(82, 0),
moveTo(124, 571),
// : -84 callsubr # -84 + bias = 23
// : : # Arg stack is [].
@@ -587,6 +799,8 @@ var proprietaryGlyphTestCases = map[string]map[rune][]Segment{
},
'Λ': { // U+039B GREEK CAPITAL LETTER LAMDA
+ // -43 21 -21 572 84 hstem
+ // 0 515 vstem
// 0 vmoveto
moveTo(0, 0),
// 85 hlineto
@@ -606,6 +820,113 @@ var proprietaryGlyphTestCases = map[string]map[rune][]Segment{
// -96 hlineto
lineTo(209, 656),
// endchar
+ lineTo(0, 0),
+ },
+
+ 'Ḫ': { // U+1E2A LATIN CAPITAL LETTER H WITH BREVE BELOW
+ // 94 -231 55 197 157 callgsubr # 157 + bias = 264
+ // : # Arg stack is [94 -231 55 197].
+ // : -21 309 72 return
+ // : # Arg stack is [94 -231 55 197 -21 309 72].
+ // 275 254 callgsubr # 254 + bias = 361
+ // : # Arg stack is [94 -231 55 197 -21 309 72 275].
+ // : -20 hstemhm
+ // : 90 83 return
+ // : # Arg stack is [90 83].
+ // -4 352 callsubr # 352 + bias = 459
+ // : # Arg stack is [90 83 -4].
+ // : 51 210 51 return
+ // : # Arg stack is [90 83 -4 51 210 51].
+ // -3 84 hintmask 11111001
+ // 90 -40 callsubr # -40 + bias = 67
+ // : # Arg stack is [90].
+ // : -27 callgsubr # -27 + bias = 80
+ // : : # Arg stack is [90].
+ // : : hmoveto
+ moveTo(90, 0),
+ // : : 83 309 305 -309 84 return
+ // : : # Arg stack is [83 309 305 -309 84].
+ // : -41 callgsubr # -41 + bias = 66
+ // : : # Arg stack is [83 309 305 -309 84].
+ // : : 656 -84 -275 -305 275 -83 return
+ // : : # Arg stack is [83 309 305 -309 84 656 -84 -275 -305 275 -83].
+ // : hlineto
+ lineTo(173, 0),
+ lineTo(173, 309),
+ lineTo(478, 309),
+ lineTo(478, 0),
+ lineTo(562, 0),
+ lineTo(562, 656),
+ lineTo(478, 656),
+ lineTo(478, 381),
+ lineTo(173, 381),
+ lineTo(173, 656),
+ lineTo(90, 656),
+ // : return
+ // : # Arg stack is [].
+ // hintmask 11110110
+ // 235 -887 143 callsubr # 143 + bias = 250
+ // : # Arg stack is [235 -887].
+ // : rmoveto
+ lineTo(90, 0),
+ moveTo(325, -231),
+ // : -84 callsubr # -84 + bias = 23
+ // : : # Arg stack is [].
+ // : : 107 44 77 74 5 hvcurveto
+ cubeTo(432, -231, 476, -154, 481, -80),
+ // : : -51 8 rlineto
+ lineTo(430, -72),
+ // : : -51 -8 -32 -53 -65 hhcurveto
+ cubeTo(422, -123, 390, -176, 325, -176),
+ // : : -65 -32 53 51 -8 hvcurveto
+ cubeTo(260, -176, 228, -123, 220, -72),
+ // : : -51 -22 callsubr # -22 + bias = 85
+ // : : : # Arg stack is [-51].
+ // : : : -8 rlineto
+ lineTo(169, -80),
+ // : : : -74 5 44 -77 107 hhcurveto
+ cubeTo(174, -154, 218, -231, 325, -231),
+ // : : : return
+ // : : : # Arg stack is [].
+ // : : return
+ // : : # Arg stack is [].
+ // : return
+ // : # Arg stack is [].
+ // endchar
+ },
+ },
+
+ "apple/Helvetica.dfont?0": {
+ 'i': {
+ // - contour #0
+ moveTo(132, 1066),
+ lineTo(315, 1066),
+ lineTo(315, 0),
+ lineTo(132, 0),
+ lineTo(132, 1066),
+ // - contour #1
+ moveTo(132, 1469),
+ lineTo(315, 1469),
+ lineTo(315, 1265),
+ lineTo(132, 1265),
+ lineTo(132, 1469),
+ },
+ },
+
+ "apple/Helvetica.dfont?1": {
+ 'i': {
+ // - contour #0
+ moveTo(426, 1220),
+ lineTo(137, 1220),
+ lineTo(137, 1483),
+ lineTo(426, 1483),
+ lineTo(426, 1220),
+ // - contour #1
+ moveTo(137, 1090),
+ lineTo(426, 1090),
+ lineTo(426, 0),
+ lineTo(137, 0),
+ lineTo(137, 1090),
},
},
@@ -819,3 +1140,81 @@ var proprietaryKernTestCases = map[string][]kernTestCase{
{2048, font.HintingNone, [2]rune{'\uf041', '\uf042'}, 0},
},
}
+
+// proprietaryFDSelectTestCases hold a sample of each font's Font Dict Select
+// (FDSelect) map. The numerical values can be verified by grepping the output
+// of the ttx tool:
+//
+// grep CharString.*fdSelectIndex SourceHanSansSC-Regular.ttx
+//
+// will print lines like this:
+//
+// <CharString name="cid00100" fdSelectIndex="15">
+// <CharString name="cid00101" fdSelectIndex="15">
+// <CharString name="cid00102" fdSelectIndex="3">
+// <CharString name="cid00103" fdSelectIndex="15">
+//
+// As for what the values like 3 or 15 actually mean, grepping that ttx file
+// for "FontName" gives this list:
+//
+// 0: <FontName value="SourceHanSansSC-Regular-Alphabetic"/>
+// 1: <FontName value="SourceHanSansSC-Regular-AlphabeticDigits"/>
+// 2: <FontName value="SourceHanSansSC-Regular-Bopomofo"/>
+// 3: <FontName value="SourceHanSansSC-Regular-Dingbats"/>
+// 4: <FontName value="SourceHanSansSC-Regular-DingbatsDigits"/>
+// 5: <FontName value="SourceHanSansSC-Regular-Generic"/>
+// 6: <FontName value="SourceHanSansSC-Regular-HDingbats"/>
+// 7: <FontName value="SourceHanSansSC-Regular-HHangul"/>
+// 8: <FontName value="SourceHanSansSC-Regular-HKana"/>
+// 9: <FontName value="SourceHanSansSC-Regular-HWidth"/>
+// 10: <FontName value="SourceHanSansSC-Regular-HWidthCJK"/>
+// 11: <FontName value="SourceHanSansSC-Regular-HWidthDigits"/>
+// 12: <FontName value="SourceHanSansSC-Regular-Hangul"/>
+// 13: <FontName value="SourceHanSansSC-Regular-Ideographs"/>
+// 14: <FontName value="SourceHanSansSC-Regular-Kana"/>
+// 15: <FontName value="SourceHanSansSC-Regular-Proportional"/>
+// 16: <FontName value="SourceHanSansSC-Regular-ProportionalCJK"/>
+// 17: <FontName value="SourceHanSansSC-Regular-ProportionalDigits"/>
+// 18: <FontName value="SourceHanSansSC-Regular-VKana"/>
+//
+// As a sanity check, the cmap table maps U+3127 BOPOMOFO LETTER I to the glyph
+// named "cid65353", proprietaryFDSelectTestCases here maps 65353 to Font Dict
+// 2, and the list immediately above maps 2 to "Bopomofo".
+var proprietaryFDSelectTestCases = map[string]map[GlyphIndex]int{
+ "adobe/SourceHanSansSC-Regular.otf": {
+ 0: 5,
+ 1: 15,
+ 2: 15,
+ 16: 15,
+ 17: 17,
+ 26: 17,
+ 27: 15,
+ 100: 15,
+ 101: 15,
+ 102: 3,
+ 103: 15,
+ 777: 4,
+ 1000: 3,
+ 2000: 3,
+ 3000: 13,
+ 4000: 13,
+ 20000: 13,
+ 48000: 12,
+ 59007: 1,
+ 59024: 0,
+ 59087: 8,
+ 59200: 7,
+ 59211: 6,
+ 60000: 13,
+ 63000: 16,
+ 63039: 9,
+ 63060: 11,
+ 63137: 10,
+ 65353: 2,
+ 65486: 14,
+ 65505: 18,
+ 65506: 5,
+ 65533: 5,
+ 65534: 5,
+ },
+}