geomerative 0.1.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/LICENSE +662 -0
  4. data/LICENSE.md +9 -0
  5. data/README.md +2 -0
  6. data/Rakefile +37 -0
  7. data/examples/README.md +7 -0
  8. data/examples/data/FreeSans.ttf +0 -0
  9. data/examples/data/ReplicaBold.ttf +0 -0
  10. data/examples/data/bot1.svg +160 -0
  11. data/examples/hello_svg_to_pdf.rb +26 -0
  12. data/examples/hello_world.rb +23 -0
  13. data/examples/physics_type.rb +77 -0
  14. data/examples/rotate_first_letter.rb +28 -0
  15. data/geomerative.gemspec +32 -0
  16. data/lib/geomerative.rb +12 -0
  17. data/lib/geomerative/version.rb +3 -0
  18. data/pom.xml +110 -0
  19. data/src/geomerative/FastRClip.java +2715 -0
  20. data/src/geomerative/RClip.java +2892 -0
  21. data/src/geomerative/RClosest.java +64 -0
  22. data/src/geomerative/RCommand.java +1941 -0
  23. data/src/geomerative/RContour.java +348 -0
  24. data/src/geomerative/RFont.java +583 -0
  25. data/src/geomerative/RG.java +753 -0
  26. data/src/geomerative/RGeomElem.java +1075 -0
  27. data/src/geomerative/RGroup.java +888 -0
  28. data/src/geomerative/RMatrix.java +401 -0
  29. data/src/geomerative/RMesh.java +420 -0
  30. data/src/geomerative/RPath.java +1095 -0
  31. data/src/geomerative/RPoint.java +419 -0
  32. data/src/geomerative/RPolygon.java +1110 -0
  33. data/src/geomerative/RRectangle.java +91 -0
  34. data/src/geomerative/RSVG.java +976 -0
  35. data/src/geomerative/RShape.java +2045 -0
  36. data/src/geomerative/RStrip.java +221 -0
  37. data/src/geomerative/RStyle.java +469 -0
  38. data/src/org/apache/batik/svggen/font/.SVGFont.java.swp +0 -0
  39. data/src/org/apache/batik/svggen/font/Font.java +188 -0
  40. data/src/org/apache/batik/svggen/font/Glyph.java +113 -0
  41. data/src/org/apache/batik/svggen/font/Messages.java.bak +72 -0
  42. data/src/org/apache/batik/svggen/font/Point.java +38 -0
  43. data/src/org/apache/batik/svggen/font/RandomAccessFileEmulator.java +15 -0
  44. data/src/org/apache/batik/svggen/font/table/ClassDef.java +42 -0
  45. data/src/org/apache/batik/svggen/font/table/ClassDefFormat1.java +55 -0
  46. data/src/org/apache/batik/svggen/font/table/ClassDefFormat2.java +49 -0
  47. data/src/org/apache/batik/svggen/font/table/CmapFormat.java +81 -0
  48. data/src/org/apache/batik/svggen/font/table/CmapFormat0.java +60 -0
  49. data/src/org/apache/batik/svggen/font/table/CmapFormat2.java +48 -0
  50. data/src/org/apache/batik/svggen/font/table/CmapFormat4.java +147 -0
  51. data/src/org/apache/batik/svggen/font/table/CmapFormat6.java +60 -0
  52. data/src/org/apache/batik/svggen/font/table/CmapIndexEntry.java +84 -0
  53. data/src/org/apache/batik/svggen/font/table/CmapTable.java +87 -0
  54. data/src/org/apache/batik/svggen/font/table/Coverage.java +50 -0
  55. data/src/org/apache/batik/svggen/font/table/CoverageFormat1.java +59 -0
  56. data/src/org/apache/batik/svggen/font/table/CoverageFormat2.java +56 -0
  57. data/src/org/apache/batik/svggen/font/table/CvtTable.java +48 -0
  58. data/src/org/apache/batik/svggen/font/table/Device.java +63 -0
  59. data/src/org/apache/batik/svggen/font/table/DirectoryEntry.java +73 -0
  60. data/src/org/apache/batik/svggen/font/table/Feature.java +56 -0
  61. data/src/org/apache/batik/svggen/font/table/FeatureList.java +70 -0
  62. data/src/org/apache/batik/svggen/font/table/FeatureRecord.java +52 -0
  63. data/src/org/apache/batik/svggen/font/table/FeatureTags.java +30 -0
  64. data/src/org/apache/batik/svggen/font/table/FpgmTable.java +38 -0
  65. data/src/org/apache/batik/svggen/font/table/GlyfCompositeComp.java +165 -0
  66. data/src/org/apache/batik/svggen/font/table/GlyfCompositeDescript.java +160 -0
  67. data/src/org/apache/batik/svggen/font/table/GlyfDescript.java +79 -0
  68. data/src/org/apache/batik/svggen/font/table/GlyfSimpleDescript.java +155 -0
  69. data/src/org/apache/batik/svggen/font/table/GlyfTable.java +111 -0
  70. data/src/org/apache/batik/svggen/font/table/GlyphDescription.java +39 -0
  71. data/src/org/apache/batik/svggen/font/table/GposTable.java +80 -0
  72. data/src/org/apache/batik/svggen/font/table/GsubTable.java +118 -0
  73. data/src/org/apache/batik/svggen/font/table/HeadTable.java +159 -0
  74. data/src/org/apache/batik/svggen/font/table/HheaTable.java +109 -0
  75. data/src/org/apache/batik/svggen/font/table/HmtxTable.java +99 -0
  76. data/src/org/apache/batik/svggen/font/table/KernSubtable.java +58 -0
  77. data/src/org/apache/batik/svggen/font/table/KernSubtableFormat0.java +65 -0
  78. data/src/org/apache/batik/svggen/font/table/KernSubtableFormat2.java +56 -0
  79. data/src/org/apache/batik/svggen/font/table/KernTable.java +64 -0
  80. data/src/org/apache/batik/svggen/font/table/KerningPair.java +53 -0
  81. data/src/org/apache/batik/svggen/font/table/LangSys.java +58 -0
  82. data/src/org/apache/batik/svggen/font/table/LangSysRecord.java +52 -0
  83. data/src/org/apache/batik/svggen/font/table/Ligature.java +57 -0
  84. data/src/org/apache/batik/svggen/font/table/LigatureSet.java +55 -0
  85. data/src/org/apache/batik/svggen/font/table/LigatureSubst.java +40 -0
  86. data/src/org/apache/batik/svggen/font/table/LigatureSubstFormat1.java +63 -0
  87. data/src/org/apache/batik/svggen/font/table/LocaTable.java +72 -0
  88. data/src/org/apache/batik/svggen/font/table/Lookup.java +77 -0
  89. data/src/org/apache/batik/svggen/font/table/LookupList.java +68 -0
  90. data/src/org/apache/batik/svggen/font/table/LookupSubtable.java +27 -0
  91. data/src/org/apache/batik/svggen/font/table/LookupSubtableFactory.java +31 -0
  92. data/src/org/apache/batik/svggen/font/table/MaxpTable.java +124 -0
  93. data/src/org/apache/batik/svggen/font/table/NameRecord.java +98 -0
  94. data/src/org/apache/batik/svggen/font/table/NameTable.java +67 -0
  95. data/src/org/apache/batik/svggen/font/table/Os2Table.java +232 -0
  96. data/src/org/apache/batik/svggen/font/table/Panose.java +108 -0
  97. data/src/org/apache/batik/svggen/font/table/PostTable.java +379 -0
  98. data/src/org/apache/batik/svggen/font/table/PrepTable.java +38 -0
  99. data/src/org/apache/batik/svggen/font/table/Program.java +49 -0
  100. data/src/org/apache/batik/svggen/font/table/RangeRecord.java +57 -0
  101. data/src/org/apache/batik/svggen/font/table/Script.java +72 -0
  102. data/src/org/apache/batik/svggen/font/table/ScriptList.java +78 -0
  103. data/src/org/apache/batik/svggen/font/table/ScriptRecord.java +52 -0
  104. data/src/org/apache/batik/svggen/font/table/ScriptTags.java +28 -0
  105. data/src/org/apache/batik/svggen/font/table/SingleSubst.java +47 -0
  106. data/src/org/apache/batik/svggen/font/table/SingleSubstFormat1.java +67 -0
  107. data/src/org/apache/batik/svggen/font/table/SingleSubstFormat2.java +67 -0
  108. data/src/org/apache/batik/svggen/font/table/Table.java +204 -0
  109. data/src/org/apache/batik/svggen/font/table/TableDirectory.java +94 -0
  110. data/src/org/apache/batik/svggen/font/table/TableFactory.java +121 -0
  111. metadata +206 -0
@@ -0,0 +1,160 @@
1
+ /*
2
+
3
+ Copyright 2001,2003 The Apache Software Foundation
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ */
18
+ package org.apache.batik.svggen.font.table;
19
+
20
+ import java.io.ByteArrayInputStream;
21
+ import java.util.ArrayList;
22
+
23
+ /**
24
+ * Glyph description for composite glyphs. Composite glyphs are made up of one
25
+ * or more simple glyphs, usually with some sort of transformation applied to
26
+ * each.
27
+ *
28
+ * @version $Id: GlyfCompositeDescript.java,v 1.5 2004/08/18 07:15:20 vhardy Exp $
29
+ * @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
30
+ */
31
+ public class GlyfCompositeDescript extends GlyfDescript {
32
+
33
+ private final ArrayList<GlyfCompositeComp> components;
34
+
35
+ public GlyfCompositeDescript(GlyfTable parentTable,
36
+ ByteArrayInputStream bais) {
37
+ super(parentTable, (short) -1, bais);
38
+ this.components = new ArrayList<>();
39
+
40
+ // Get all of the composite components
41
+ GlyfCompositeComp comp;
42
+ int firstIndex = 0;
43
+ int firstContour = 0;
44
+ do {
45
+ comp = new GlyfCompositeComp(firstIndex, firstContour, bais);
46
+ components.add(comp);
47
+
48
+ GlyphDescription desc;
49
+ desc = parentTable.getDescription(comp.getGlyphIndex());
50
+ if (desc != null) {
51
+ firstIndex += desc.getPointCount();
52
+ firstContour += desc.getContourCount();
53
+ }
54
+ } while ((comp.getFlags() & GlyfCompositeComp.MORE_COMPONENTS) != 0);
55
+
56
+ // Are there hinting intructions to read?
57
+ if ((comp.getFlags() & GlyfCompositeComp.WE_HAVE_INSTRUCTIONS) != 0) {
58
+ readInstructions(bais, (bais.read()<<8 | bais.read()));
59
+ }
60
+ }
61
+
62
+ @Override
63
+ public int getEndPtOfContours(int i) {
64
+ GlyfCompositeComp c = getCompositeCompEndPt(i);
65
+ if (c != null) {
66
+ GlyphDescription gd = parentTable.getDescription(c.getGlyphIndex());
67
+ return gd.getEndPtOfContours(i - c.getFirstContour()) + c.getFirstIndex();
68
+ }
69
+ return 0;
70
+ }
71
+
72
+ @Override
73
+ public byte getFlags(int i) {
74
+ GlyfCompositeComp c = getCompositeComp(i);
75
+ if (c != null) {
76
+ GlyphDescription gd = parentTable.getDescription(c.getGlyphIndex());
77
+ return gd.getFlags(i - c.getFirstIndex());
78
+ }
79
+ return 0;
80
+ }
81
+
82
+ @Override
83
+ public short getXCoordinate(int i) {
84
+ GlyfCompositeComp c = getCompositeComp(i);
85
+ if (c != null) {
86
+ GlyphDescription gd = parentTable.getDescription(c.getGlyphIndex());
87
+ int n = i - c.getFirstIndex();
88
+ int x = gd.getXCoordinate(n);
89
+ int y = gd.getYCoordinate(n);
90
+ short x1 = (short) c.scaleX(x, y);
91
+ x1 += c.getXTranslate();
92
+ return x1;
93
+ }
94
+ return 0;
95
+ }
96
+
97
+ @Override
98
+ public short getYCoordinate(int i) {
99
+ GlyfCompositeComp c = getCompositeComp(i);
100
+ if (c != null) {
101
+ GlyphDescription gd = parentTable.getDescription(c.getGlyphIndex());
102
+ int n = i - c.getFirstIndex();
103
+ int x = gd.getXCoordinate(n);
104
+ int y = gd.getYCoordinate(n);
105
+ short y1 = (short) c.scaleY(x, y);
106
+ y1 += c.getYTranslate();
107
+ return y1;
108
+ }
109
+ return 0;
110
+ }
111
+
112
+ @Override
113
+ public boolean isComposite() {
114
+ return true;
115
+ }
116
+
117
+ @Override
118
+ public int getPointCount() {
119
+ GlyfCompositeComp c = (GlyfCompositeComp) components.get(components.size()-1);
120
+ return c.getFirstIndex() + parentTable.getDescription(c.getGlyphIndex()).getPointCount();
121
+ }
122
+
123
+ @Override
124
+ public int getContourCount() {
125
+ GlyfCompositeComp c = (GlyfCompositeComp) components.get(components.size()-1);
126
+ return c.getFirstContour() + parentTable.getDescription(c.getGlyphIndex()).getContourCount();
127
+ }
128
+
129
+ public int getComponentIndex(int i) {
130
+ return ((GlyfCompositeComp)components.get(i)).getFirstIndex();
131
+ }
132
+
133
+ public int getComponentCount() {
134
+ return components.size();
135
+ }
136
+
137
+ protected GlyfCompositeComp getCompositeComp(int i) {
138
+ GlyfCompositeComp c;
139
+ for (Object component : components) {
140
+ c = (GlyfCompositeComp) component;
141
+ GlyphDescription gd = parentTable.getDescription(c.getGlyphIndex());
142
+ if (c.getFirstIndex() <= i && i < (c.getFirstIndex() + gd.getPointCount())) {
143
+ return c;
144
+ }
145
+ }
146
+ return null;
147
+ }
148
+
149
+ protected GlyfCompositeComp getCompositeCompEndPt(int i) {
150
+ GlyfCompositeComp c;
151
+ for (Object component : components) {
152
+ c = (GlyfCompositeComp) component;
153
+ GlyphDescription gd = parentTable.getDescription(c.getGlyphIndex());
154
+ if (c.getFirstContour() <= i && i < (c.getFirstContour() + gd.getContourCount())) {
155
+ return c;
156
+ }
157
+ }
158
+ return null;
159
+ }
160
+ }
@@ -0,0 +1,79 @@
1
+ /*
2
+
3
+ Copyright 2001 The Apache Software Foundation
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ */
18
+ package org.apache.batik.svggen.font.table;
19
+
20
+ import java.io.ByteArrayInputStream;
21
+
22
+ /**
23
+ * @version $Id: GlyfDescript.java,v 1.3 2004/08/18 07:15:21 vhardy Exp $
24
+ * @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
25
+ */
26
+ public abstract class GlyfDescript extends Program implements GlyphDescription {
27
+
28
+ // flags
29
+ public static final byte onCurve = 0x01;
30
+ public static final byte xShortVector = 0x02;
31
+ public static final byte yShortVector = 0x04;
32
+ public static final byte repeat = 0x08;
33
+ public static final byte xDual = 0x10;
34
+ public static final byte yDual = 0x20;
35
+
36
+ protected GlyfTable parentTable;
37
+ private final int numberOfContours;
38
+ private final short xMin;
39
+ private final short yMin;
40
+ private final short xMax;
41
+ private final short yMax;
42
+
43
+ protected GlyfDescript(GlyfTable parentTable, short numberOfContours, ByteArrayInputStream bais) {
44
+ this.parentTable = parentTable;
45
+ this.numberOfContours = numberOfContours;
46
+ xMin = (short)(bais.read()<<8 | bais.read());
47
+ yMin = (short)(bais.read()<<8 | bais.read());
48
+ xMax = (short)(bais.read()<<8 | bais.read());
49
+ yMax = (short)(bais.read()<<8 | bais.read());
50
+ }
51
+
52
+ public int getNumberOfContours() {
53
+ return numberOfContours;
54
+ }
55
+
56
+ @Override
57
+ public short getXMaximum() {
58
+ return xMax;
59
+ }
60
+
61
+ @Override
62
+ public short getXMinimum() {
63
+ return xMin;
64
+ }
65
+
66
+ @Override
67
+ public short getYMaximum() {
68
+ return yMax;
69
+ }
70
+
71
+ /**
72
+ *
73
+ * @return
74
+ */
75
+ @Override
76
+ public short getYMinimum() {
77
+ return yMin;
78
+ }
79
+ }
@@ -0,0 +1,155 @@
1
+ /*
2
+
3
+ Copyright 2001,2003 The Apache Software Foundation
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ */
18
+ package org.apache.batik.svggen.font.table;
19
+
20
+ import java.io.ByteArrayInputStream;
21
+
22
+ /**
23
+ * @version $Id: GlyfSimpleDescript.java,v 1.4 2004/08/18 07:15:21 vhardy Exp $
24
+ * @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
25
+ */
26
+ public class GlyfSimpleDescript extends GlyfDescript {
27
+
28
+ private final int[] endPtsOfContours;
29
+ private final byte[] flags;
30
+ private final short[] xCoordinates;
31
+ private final short[] yCoordinates;
32
+ private final int count;
33
+
34
+ public GlyfSimpleDescript(GlyfTable parentTable, short numberOfContours, ByteArrayInputStream bais) {
35
+
36
+ super(parentTable, numberOfContours, bais);
37
+
38
+ // Simple glyph description
39
+ endPtsOfContours = new int[numberOfContours];
40
+ for (int i = 0; i < numberOfContours; i++) {
41
+ endPtsOfContours[i] = (bais.read()<<8 | bais.read());
42
+ }
43
+
44
+ // The last end point index reveals the total number of points
45
+ count = endPtsOfContours[numberOfContours-1] + 1;
46
+ flags = new byte[count];
47
+ xCoordinates = new short[count];
48
+ yCoordinates = new short[count];
49
+
50
+ int instructionCount = (bais.read()<<8 | bais.read());
51
+ readInstructions(bais, instructionCount);
52
+ readFlags(count, bais);
53
+ readCoords(count, bais);
54
+ }
55
+
56
+ @Override
57
+ public int getEndPtOfContours(int i) {
58
+ return endPtsOfContours[i];
59
+ }
60
+
61
+ @Override
62
+ public byte getFlags(int i) {
63
+ return flags[i];
64
+ }
65
+
66
+ @Override
67
+ public short getXCoordinate(int i) {
68
+ return xCoordinates[i];
69
+ }
70
+
71
+ @Override
72
+ public short getYCoordinate(int i) {
73
+ return yCoordinates[i];
74
+ }
75
+
76
+ @Override
77
+ public boolean isComposite() {
78
+ return false;
79
+ }
80
+
81
+ @Override
82
+ public int getPointCount() {
83
+ return count;
84
+ }
85
+
86
+ @Override
87
+ public int getContourCount() {
88
+ return getNumberOfContours();
89
+ }
90
+ /*
91
+ public int getComponentIndex(int c) {
92
+ return 0;
93
+ }
94
+
95
+ public int getComponentCount() {
96
+ return 1;
97
+ }
98
+ */
99
+ /**
100
+ * The table is stored as relative values, but we'll store them as absolutes
101
+ */
102
+ private void readCoords(int count, ByteArrayInputStream bais) {
103
+ short x = 0;
104
+ short y = 0;
105
+ for (int i = 0; i < count; i++) {
106
+ if ((flags[i] & xDual) != 0) {
107
+ if ((flags[i] & xShortVector) != 0) {
108
+ x += (short) bais.read();
109
+ }
110
+ } else {
111
+ if ((flags[i] & xShortVector) != 0) {
112
+ x += (short) -((short) bais.read());
113
+ } else {
114
+ x += (short)(bais.read()<<8 | bais.read());
115
+ }
116
+ }
117
+ xCoordinates[i] = x;
118
+ }
119
+
120
+ for (int i = 0; i < count; i++) {
121
+ if ((flags[i] & yDual) != 0) {
122
+ if ((flags[i] & yShortVector) != 0) {
123
+ y += (short) bais.read();
124
+ }
125
+ } else {
126
+ if ((flags[i] & yShortVector) != 0) {
127
+ y += (short) -((short) bais.read());
128
+ } else {
129
+ y += (short)(bais.read()<<8 | bais.read());
130
+ }
131
+ }
132
+ yCoordinates[i] = y;
133
+ }
134
+ }
135
+
136
+ /**
137
+ * The flags are run-length encoded
138
+ */
139
+ private void readFlags(int flagCount, ByteArrayInputStream bais) {
140
+ try {
141
+ for (int index = 0; index < flagCount; index++) {
142
+ flags[index] = (byte) bais.read();
143
+ if ((flags[index] & repeat) != 0) {
144
+ int repeats = bais.read();
145
+ for (int i = 1; i <= repeats; i++) {
146
+ flags[index + i] = flags[index];
147
+ }
148
+ index += repeats;
149
+ }
150
+ }
151
+ } catch (ArrayIndexOutOfBoundsException e) {
152
+ System.out.println("error: array index out of bounds");
153
+ }
154
+ }
155
+ }
@@ -0,0 +1,111 @@
1
+ /*
2
+
3
+ Copyright 2001,2003 The Apache Software Foundation
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ */
18
+ package org.apache.batik.svggen.font.table;
19
+
20
+ import java.io.ByteArrayInputStream;
21
+ import java.io.IOException;
22
+ import org.apache.batik.svggen.font.*;
23
+
24
+ /**
25
+ * @version $Id: GlyfTable.java,v 1.4 2004/08/18 07:15:21 vhardy Exp $
26
+ * @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
27
+ */
28
+ public class GlyfTable implements Table {
29
+
30
+ private byte[] buf = null;
31
+ private GlyfDescript[] descript;
32
+
33
+ protected GlyfTable(DirectoryEntry de, RandomAccessFileEmulator raf) throws IOException {
34
+ raf.seek(de.getOffset());
35
+ buf = new byte[de.getLength()];
36
+ raf.read(buf);
37
+ /*
38
+ TableMaxp t_maxp = (TableMaxp) td.getEntryByTag(maxp).getTable();
39
+ TableLoca t_loca = (TableLoca) td.getEntryByTag(loca).getTable();
40
+ descript = new TableGlyfDescript[t_maxp.getNumGlyphs()];
41
+ for (int i = 0; i < t_maxp.getNumGlyphs(); i++) {
42
+ raf.seek(tde.getOffset() + t_loca.getOffset(i));
43
+ int len = t_loca.getOffset((short)(i + 1)) - t_loca.getOffset(i);
44
+ if (len > 0) {
45
+ short numberOfContours = raf.readShort();
46
+ if (numberOfContours < 0) {
47
+ // descript[i] = new TableGlyfCompositeDescript(this, raf);
48
+ } else {
49
+ descript[i] = new TableGlyfSimpleDescript(this, numberOfContours, raf);
50
+ }
51
+ } else {
52
+ descript[i] = null;
53
+ }
54
+ }
55
+
56
+ for (int i = 0; i < t_maxp.getNumGlyphs(); i++) {
57
+ raf.seek(tde.getOffset() + t_loca.getOffset(i));
58
+ int len = t_loca.getOffset((short)(i + 1)) - t_loca.getOffset(i);
59
+ if (len > 0) {
60
+ short numberOfContours = raf.readShort();
61
+ if (numberOfContours < 0) {
62
+ descript[i] = new TableGlyfCompositeDescript(this, raf);
63
+ }
64
+ }
65
+ }
66
+ */
67
+ }
68
+
69
+ public void init(int numGlyphs, LocaTable loca) {
70
+ if (buf == null) {
71
+ return;
72
+ }
73
+ descript = new GlyfDescript[numGlyphs];
74
+ ByteArrayInputStream bais = new ByteArrayInputStream(buf);
75
+ for (int i = 0; i < numGlyphs; i++) {
76
+ int len = loca.getOffset((short)(i + 1)) - loca.getOffset(i);
77
+ if (len > 0) {
78
+ bais.reset();
79
+ bais.skip(loca.getOffset(i));
80
+ short numberOfContours = (short)(bais.read()<<8 | bais.read());
81
+ if (numberOfContours >= 0) {
82
+ descript[i] = new GlyfSimpleDescript(this, numberOfContours, bais);
83
+ }
84
+ } else {
85
+ descript[i] = null;
86
+ }
87
+ }
88
+
89
+ for (int i = 0; i < numGlyphs; i++) {
90
+ int len = loca.getOffset((short)(i + 1)) - loca.getOffset(i);
91
+ if (len > 0) {
92
+ bais.reset();
93
+ bais.skip(loca.getOffset(i));
94
+ short numberOfContours = (short)(bais.read()<<8 | bais.read());
95
+ if (numberOfContours < 0) {
96
+ descript[i] = new GlyfCompositeDescript(this, bais);
97
+ }
98
+ }
99
+ }
100
+ buf = null;
101
+ }
102
+
103
+ public GlyfDescript getDescription(int i) {
104
+ return descript[i];
105
+ }
106
+
107
+ @Override
108
+ public int getType() {
109
+ return glyf;
110
+ }
111
+ }