font/sfnt: implement rrcurveto.
Change-Id: I2e24293568b296dd916b2ef6a9c1113ffd5f9253
Reviewed-on: https://go-review.googlesource.com/34171
Reviewed-by: Dave Day <djd@golang.org>
diff --git a/font/sfnt/postscript.go b/font/sfnt/postscript.go
index 93f5490..d5d6d9a 100644
--- a/font/sfnt/postscript.go
+++ b/font/sfnt/postscript.go
@@ -548,7 +548,7 @@
5: {-1, "rlineto", t2CRlineto},
6: {-1, "hlineto", t2CHlineto},
7: {-1, "vlineto", t2CVlineto},
- 8: {}, // rrcurveto.
+ 8: {-1, "rrcurveto", t2CRrcurveto},
9: {}, // Reserved.
10: {}, // callsubr.
11: {}, // return.
@@ -834,6 +834,23 @@
return i
}
+func t2CRrcurveto(p *psInterpreter) error {
+ if !p.type2Charstrings.seenWidth || p.stack.top < 6 || p.stack.top%6 != 0 {
+ return errInvalidCFFTable
+ }
+ for i := int32(0); i != p.stack.top; i += 6 {
+ t2CAppendCubeto(p,
+ p.stack.a[i+0],
+ p.stack.a[i+1],
+ p.stack.a[i+2],
+ p.stack.a[i+3],
+ p.stack.a[i+4],
+ p.stack.a[i+5],
+ )
+ }
+ return nil
+}
+
func t2CEndchar(p *psInterpreter) error {
t2CReadWidth(p, 0)
if p.stack.top != 0 || len(p.instructions) != 0 {
diff --git a/font/sfnt/sfnt_test.go b/font/sfnt/sfnt_test.go
index 68ef19c..fe43d32 100644
--- a/font/sfnt/sfnt_test.go
+++ b/font/sfnt/sfnt_test.go
@@ -126,6 +126,20 @@
lineTo(300, 800),
lineTo(100, 800),
}, {
+ // Q
+ // - contour #0
+ moveTo(657, 237),
+ lineTo(289, 387),
+ lineTo(519, 615),
+ // - contour #1
+ moveTo(792, 169),
+ cubeTo(867, 263, 926, 502, 791, 665),
+ cubeTo(645, 840, 380, 831, 228, 673),
+ cubeTo(71, 509, 110, 231, 242, 93),
+ cubeTo(369, -39, 641, 18, 722, 93),
+ lineTo(802, 3),
+ lineTo(864, 83),
+ }, {
// uni4E2D
// - contour #0
moveTo(141, 520),
diff --git a/font/testdata/CFFTest.otf b/font/testdata/CFFTest.otf
index 1f10cfc..a21738b 100644
--- a/font/testdata/CFFTest.otf
+++ b/font/testdata/CFFTest.otf
Binary files differ
diff --git a/font/testdata/CFFTest.sfd b/font/testdata/CFFTest.sfd
index f0d3ce9..6a5b79a 100644
--- a/font/testdata/CFFTest.sfd
+++ b/font/testdata/CFFTest.sfd
@@ -19,7 +19,7 @@
OS2_WeightWidthSlopeOnly: 0
OS2_UseTypoMetrics: 1
CreationTime: 1479626795
-ModificationTime: 1480661567
+ModificationTime: 1481282599
PfmFamily: 17
TTFWeight: 400
TTFWidth: 5
@@ -48,11 +48,11 @@
DisplaySize: -24
AntiAlias: 1
FitToEm: 1
-WinInfo: 19712 32 23
+WinInfo: 64 32 11
BeginPrivate: 0
EndPrivate
TeXData: 1 0 0 346030 173015 115343 0 1048576 115343 783286 444596 497025 792723 393216 433062 380633 303038 157286 324010 404750 52429 2506097 1059062 262144
-BeginChars: 65536 3
+BeginChars: 65536 4
StartChar: zero
Encoding: 48 48 0
@@ -120,5 +120,29 @@
EndSplineSet
Validated: 1
EndChar
+
+StartChar: Q
+Encoding: 81 81 3
+Width: 1000
+VWidth: 0
+Flags: W
+LayerCount: 2
+Fore
+SplineSet
+657 237 m 0
+ 519 615 l 0
+ 289 387 l 0
+ 657 237 l 0
+792 169 m 1
+ 864 83 l 25
+ 802 3 l 21
+ 722 93 l 1
+ 641 18 369 -39 242 93 c 0
+ 110 231 71 509 228 673 c 24
+ 380 831 645 840 791 665 c 0
+ 926 502 867 263 792 169 c 1
+EndSplineSet
+Validated: 33
+EndChar
EndChars
EndSplineFont