geomerative 0.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/LICENSE +662 -0
- data/LICENSE.md +9 -0
- data/README.md +2 -0
- data/Rakefile +37 -0
- data/examples/README.md +7 -0
- data/examples/data/FreeSans.ttf +0 -0
- data/examples/data/ReplicaBold.ttf +0 -0
- data/examples/data/bot1.svg +160 -0
- data/examples/hello_svg_to_pdf.rb +26 -0
- data/examples/hello_world.rb +23 -0
- data/examples/physics_type.rb +77 -0
- data/examples/rotate_first_letter.rb +28 -0
- data/geomerative.gemspec +32 -0
- data/lib/geomerative.rb +12 -0
- data/lib/geomerative/version.rb +3 -0
- data/pom.xml +110 -0
- data/src/geomerative/FastRClip.java +2715 -0
- data/src/geomerative/RClip.java +2892 -0
- data/src/geomerative/RClosest.java +64 -0
- data/src/geomerative/RCommand.java +1941 -0
- data/src/geomerative/RContour.java +348 -0
- data/src/geomerative/RFont.java +583 -0
- data/src/geomerative/RG.java +753 -0
- data/src/geomerative/RGeomElem.java +1075 -0
- data/src/geomerative/RGroup.java +888 -0
- data/src/geomerative/RMatrix.java +401 -0
- data/src/geomerative/RMesh.java +420 -0
- data/src/geomerative/RPath.java +1095 -0
- data/src/geomerative/RPoint.java +419 -0
- data/src/geomerative/RPolygon.java +1110 -0
- data/src/geomerative/RRectangle.java +91 -0
- data/src/geomerative/RSVG.java +976 -0
- data/src/geomerative/RShape.java +2045 -0
- data/src/geomerative/RStrip.java +221 -0
- data/src/geomerative/RStyle.java +469 -0
- data/src/org/apache/batik/svggen/font/.SVGFont.java.swp +0 -0
- data/src/org/apache/batik/svggen/font/Font.java +188 -0
- data/src/org/apache/batik/svggen/font/Glyph.java +113 -0
- data/src/org/apache/batik/svggen/font/Messages.java.bak +72 -0
- data/src/org/apache/batik/svggen/font/Point.java +38 -0
- data/src/org/apache/batik/svggen/font/RandomAccessFileEmulator.java +15 -0
- data/src/org/apache/batik/svggen/font/table/ClassDef.java +42 -0
- data/src/org/apache/batik/svggen/font/table/ClassDefFormat1.java +55 -0
- data/src/org/apache/batik/svggen/font/table/ClassDefFormat2.java +49 -0
- data/src/org/apache/batik/svggen/font/table/CmapFormat.java +81 -0
- data/src/org/apache/batik/svggen/font/table/CmapFormat0.java +60 -0
- data/src/org/apache/batik/svggen/font/table/CmapFormat2.java +48 -0
- data/src/org/apache/batik/svggen/font/table/CmapFormat4.java +147 -0
- data/src/org/apache/batik/svggen/font/table/CmapFormat6.java +60 -0
- data/src/org/apache/batik/svggen/font/table/CmapIndexEntry.java +84 -0
- data/src/org/apache/batik/svggen/font/table/CmapTable.java +87 -0
- data/src/org/apache/batik/svggen/font/table/Coverage.java +50 -0
- data/src/org/apache/batik/svggen/font/table/CoverageFormat1.java +59 -0
- data/src/org/apache/batik/svggen/font/table/CoverageFormat2.java +56 -0
- data/src/org/apache/batik/svggen/font/table/CvtTable.java +48 -0
- data/src/org/apache/batik/svggen/font/table/Device.java +63 -0
- data/src/org/apache/batik/svggen/font/table/DirectoryEntry.java +73 -0
- data/src/org/apache/batik/svggen/font/table/Feature.java +56 -0
- data/src/org/apache/batik/svggen/font/table/FeatureList.java +70 -0
- data/src/org/apache/batik/svggen/font/table/FeatureRecord.java +52 -0
- data/src/org/apache/batik/svggen/font/table/FeatureTags.java +30 -0
- data/src/org/apache/batik/svggen/font/table/FpgmTable.java +38 -0
- data/src/org/apache/batik/svggen/font/table/GlyfCompositeComp.java +165 -0
- data/src/org/apache/batik/svggen/font/table/GlyfCompositeDescript.java +160 -0
- data/src/org/apache/batik/svggen/font/table/GlyfDescript.java +79 -0
- data/src/org/apache/batik/svggen/font/table/GlyfSimpleDescript.java +155 -0
- data/src/org/apache/batik/svggen/font/table/GlyfTable.java +111 -0
- data/src/org/apache/batik/svggen/font/table/GlyphDescription.java +39 -0
- data/src/org/apache/batik/svggen/font/table/GposTable.java +80 -0
- data/src/org/apache/batik/svggen/font/table/GsubTable.java +118 -0
- data/src/org/apache/batik/svggen/font/table/HeadTable.java +159 -0
- data/src/org/apache/batik/svggen/font/table/HheaTable.java +109 -0
- data/src/org/apache/batik/svggen/font/table/HmtxTable.java +99 -0
- data/src/org/apache/batik/svggen/font/table/KernSubtable.java +58 -0
- data/src/org/apache/batik/svggen/font/table/KernSubtableFormat0.java +65 -0
- data/src/org/apache/batik/svggen/font/table/KernSubtableFormat2.java +56 -0
- data/src/org/apache/batik/svggen/font/table/KernTable.java +64 -0
- data/src/org/apache/batik/svggen/font/table/KerningPair.java +53 -0
- data/src/org/apache/batik/svggen/font/table/LangSys.java +58 -0
- data/src/org/apache/batik/svggen/font/table/LangSysRecord.java +52 -0
- data/src/org/apache/batik/svggen/font/table/Ligature.java +57 -0
- data/src/org/apache/batik/svggen/font/table/LigatureSet.java +55 -0
- data/src/org/apache/batik/svggen/font/table/LigatureSubst.java +40 -0
- data/src/org/apache/batik/svggen/font/table/LigatureSubstFormat1.java +63 -0
- data/src/org/apache/batik/svggen/font/table/LocaTable.java +72 -0
- data/src/org/apache/batik/svggen/font/table/Lookup.java +77 -0
- data/src/org/apache/batik/svggen/font/table/LookupList.java +68 -0
- data/src/org/apache/batik/svggen/font/table/LookupSubtable.java +27 -0
- data/src/org/apache/batik/svggen/font/table/LookupSubtableFactory.java +31 -0
- data/src/org/apache/batik/svggen/font/table/MaxpTable.java +124 -0
- data/src/org/apache/batik/svggen/font/table/NameRecord.java +98 -0
- data/src/org/apache/batik/svggen/font/table/NameTable.java +67 -0
- data/src/org/apache/batik/svggen/font/table/Os2Table.java +232 -0
- data/src/org/apache/batik/svggen/font/table/Panose.java +108 -0
- data/src/org/apache/batik/svggen/font/table/PostTable.java +379 -0
- data/src/org/apache/batik/svggen/font/table/PrepTable.java +38 -0
- data/src/org/apache/batik/svggen/font/table/Program.java +49 -0
- data/src/org/apache/batik/svggen/font/table/RangeRecord.java +57 -0
- data/src/org/apache/batik/svggen/font/table/Script.java +72 -0
- data/src/org/apache/batik/svggen/font/table/ScriptList.java +78 -0
- data/src/org/apache/batik/svggen/font/table/ScriptRecord.java +52 -0
- data/src/org/apache/batik/svggen/font/table/ScriptTags.java +28 -0
- data/src/org/apache/batik/svggen/font/table/SingleSubst.java +47 -0
- data/src/org/apache/batik/svggen/font/table/SingleSubstFormat1.java +67 -0
- data/src/org/apache/batik/svggen/font/table/SingleSubstFormat2.java +67 -0
- data/src/org/apache/batik/svggen/font/table/Table.java +204 -0
- data/src/org/apache/batik/svggen/font/table/TableDirectory.java +94 -0
- data/src/org/apache/batik/svggen/font/table/TableFactory.java +121 -0
- metadata +206 -0
@@ -0,0 +1,73 @@
|
|
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.IOException;
|
21
|
+
import org.apache.batik.svggen.font.*;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* @version $Id: DirectoryEntry.java,v 1.3 2004/08/18 07:15:20 vhardy Exp $
|
25
|
+
* @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
|
26
|
+
*/
|
27
|
+
public class DirectoryEntry {
|
28
|
+
|
29
|
+
private final int tag;
|
30
|
+
private final int checksum;
|
31
|
+
private final int offset;
|
32
|
+
private final int length;
|
33
|
+
private final Table table = null;
|
34
|
+
|
35
|
+
protected DirectoryEntry(RandomAccessFileEmulator raf) throws IOException {
|
36
|
+
tag = raf.readInt();
|
37
|
+
checksum = raf.readInt();
|
38
|
+
offset = raf.readInt();
|
39
|
+
length = raf.readInt();
|
40
|
+
}
|
41
|
+
|
42
|
+
public int getChecksum() {
|
43
|
+
return checksum;
|
44
|
+
}
|
45
|
+
|
46
|
+
public int getLength() {
|
47
|
+
return length;
|
48
|
+
}
|
49
|
+
|
50
|
+
public int getOffset() {
|
51
|
+
return offset;
|
52
|
+
}
|
53
|
+
|
54
|
+
public int getTag() {
|
55
|
+
return tag;
|
56
|
+
}
|
57
|
+
|
58
|
+
@Override
|
59
|
+
public String toString() {
|
60
|
+
return new StringBuilder()
|
61
|
+
.append((char)((tag>>24)&0xff))
|
62
|
+
.append((char)((tag>>16)&0xff))
|
63
|
+
.append((char)((tag>>8)&0xff))
|
64
|
+
.append((char)((tag)&0xff))
|
65
|
+
.append(", offset: ")
|
66
|
+
.append(offset)
|
67
|
+
.append(", length: ")
|
68
|
+
.append(length)
|
69
|
+
.append(", checksum: 0x")
|
70
|
+
.append(Integer.toHexString(checksum))
|
71
|
+
.toString();
|
72
|
+
}
|
73
|
+
}
|
@@ -0,0 +1,56 @@
|
|
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.IOException;
|
21
|
+
import org.apache.batik.svggen.font.*;
|
22
|
+
|
23
|
+
/**
|
24
|
+
*
|
25
|
+
* @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
|
26
|
+
* @version $Id: Feature.java,v 1.3 2004/08/18 07:15:20 vhardy Exp $
|
27
|
+
*/
|
28
|
+
public class Feature {
|
29
|
+
|
30
|
+
private final int featureParams;
|
31
|
+
private final int lookupCount;
|
32
|
+
private final int[] lookupListIndex;
|
33
|
+
|
34
|
+
/** Creates new Feature
|
35
|
+
* @param raf
|
36
|
+
* @param offset
|
37
|
+
* @throws java.io.IOException */
|
38
|
+
protected Feature(RandomAccessFileEmulator raf, int offset) throws IOException {
|
39
|
+
raf.seek(offset);
|
40
|
+
featureParams = raf.readUnsignedShort();
|
41
|
+
lookupCount = raf.readUnsignedShort();
|
42
|
+
lookupListIndex = new int[lookupCount];
|
43
|
+
for (int i = 0; i < lookupCount; i++) {
|
44
|
+
lookupListIndex[i] = raf.readUnsignedShort();
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
public int getLookupCount() {
|
49
|
+
return lookupCount;
|
50
|
+
}
|
51
|
+
|
52
|
+
public int getLookupListIndex(int i) {
|
53
|
+
return lookupListIndex[i];
|
54
|
+
}
|
55
|
+
|
56
|
+
}
|
@@ -0,0 +1,70 @@
|
|
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.IOException;
|
21
|
+
import org.apache.batik.svggen.font.*;
|
22
|
+
|
23
|
+
/**
|
24
|
+
*
|
25
|
+
* @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
|
26
|
+
* @version $Id: FeatureList.java,v 1.4 2004/08/18 07:15:20 vhardy Exp $
|
27
|
+
*/
|
28
|
+
public class FeatureList {
|
29
|
+
|
30
|
+
private final int featureCount;
|
31
|
+
private final FeatureRecord[] featureRecords;
|
32
|
+
private final Feature[] features;
|
33
|
+
|
34
|
+
/** Creates new FeatureList
|
35
|
+
* @param raf
|
36
|
+
* @param offset
|
37
|
+
* @throws java.io.IOException
|
38
|
+
*/
|
39
|
+
public FeatureList(RandomAccessFileEmulator raf, int offset) throws IOException {
|
40
|
+
raf.seek(offset);
|
41
|
+
featureCount = raf.readUnsignedShort();
|
42
|
+
featureRecords = new FeatureRecord[featureCount];
|
43
|
+
features = new Feature[featureCount];
|
44
|
+
for (int i = 0; i < featureCount; i++) {
|
45
|
+
featureRecords[i] = new FeatureRecord(raf);
|
46
|
+
}
|
47
|
+
for (int i = 0; i < featureCount; i++) {
|
48
|
+
features[i] = new Feature(raf, offset + featureRecords[i].getOffset());
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
public Feature findFeature(LangSys langSys, String tag) {
|
53
|
+
if (tag.length() != 4) {
|
54
|
+
return null;
|
55
|
+
}
|
56
|
+
int tagVal = ((tag.charAt(0)<<24)
|
57
|
+
| (tag.charAt(1)<<16)
|
58
|
+
| (tag.charAt(2)<<8)
|
59
|
+
| tag.charAt(3));
|
60
|
+
for (int i = 0; i < featureCount; i++) {
|
61
|
+
if (featureRecords[i].getTag() == tagVal) {
|
62
|
+
if (langSys.isFeatureIndexed(i)) {
|
63
|
+
return features[i];
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
return null;
|
68
|
+
}
|
69
|
+
|
70
|
+
}
|
@@ -0,0 +1,52 @@
|
|
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.IOException;
|
21
|
+
import org.apache.batik.svggen.font.*;
|
22
|
+
|
23
|
+
/**
|
24
|
+
*
|
25
|
+
* @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
|
26
|
+
* @version $Id: FeatureRecord.java,v 1.3 2004/08/18 07:15:20 vhardy Exp $
|
27
|
+
*/
|
28
|
+
public class FeatureRecord {
|
29
|
+
|
30
|
+
private final int tag;
|
31
|
+
private final int offset;
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Creates new FeatureRecord
|
35
|
+
*
|
36
|
+
* @param raf
|
37
|
+
* @throws java.io.IOException
|
38
|
+
*/
|
39
|
+
public FeatureRecord(RandomAccessFileEmulator raf) throws IOException {
|
40
|
+
tag = raf.readInt();
|
41
|
+
offset = raf.readUnsignedShort();
|
42
|
+
}
|
43
|
+
|
44
|
+
public int getTag() {
|
45
|
+
return tag;
|
46
|
+
}
|
47
|
+
|
48
|
+
public int getOffset() {
|
49
|
+
return offset;
|
50
|
+
}
|
51
|
+
|
52
|
+
}
|
@@ -0,0 +1,30 @@
|
|
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
|
+
/**
|
21
|
+
* Definition of Feature tags
|
22
|
+
*
|
23
|
+
* @version $Id: FeatureTags.java,v 1.3 2004/08/18 07:15:20 vhardy Exp $
|
24
|
+
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
|
25
|
+
*/
|
26
|
+
public interface FeatureTags {
|
27
|
+
String FEATURE_TAG_INIT = "init";
|
28
|
+
String FEATURE_TAG_MEDI = "medi";
|
29
|
+
String FEATURE_TAG_FINA = "fina";
|
30
|
+
}
|
@@ -0,0 +1,38 @@
|
|
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.IOException;
|
21
|
+
import org.apache.batik.svggen.font.*;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* @version $Id: FpgmTable.java,v 1.3 2004/08/18 07:15:20 vhardy Exp $
|
25
|
+
* @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
|
26
|
+
*/
|
27
|
+
public class FpgmTable extends Program implements Table {
|
28
|
+
|
29
|
+
protected FpgmTable(DirectoryEntry de,RandomAccessFileEmulator raf) throws IOException {
|
30
|
+
raf.seek(de.getOffset());
|
31
|
+
readInstructions(raf, de.getLength());
|
32
|
+
}
|
33
|
+
|
34
|
+
@Override
|
35
|
+
public int getType() {
|
36
|
+
return fpgm;
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,165 @@
|
|
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: GlyfCompositeComp.java,v 1.4 2004/08/18 07:15:20 vhardy Exp $
|
24
|
+
* @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
|
25
|
+
*/
|
26
|
+
public class GlyfCompositeComp {
|
27
|
+
|
28
|
+
public static final short ARG_1_AND_2_ARE_WORDS = 0x0001;
|
29
|
+
public static final short ARGS_ARE_XY_VALUES = 0x0002;
|
30
|
+
public static final short ROUND_XY_TO_GRID = 0x0004;
|
31
|
+
public static final short WE_HAVE_A_SCALE = 0x0008;
|
32
|
+
public static final short MORE_COMPONENTS = 0x0020;
|
33
|
+
public static final short WE_HAVE_AN_X_AND_Y_SCALE = 0x0040;
|
34
|
+
public static final short WE_HAVE_A_TWO_BY_TWO = 0x0080;
|
35
|
+
public static final short WE_HAVE_INSTRUCTIONS = 0x0100;
|
36
|
+
public static final short USE_MY_METRICS = 0x0200;
|
37
|
+
|
38
|
+
private final int firstIndex;
|
39
|
+
private final int firstContour;
|
40
|
+
private final short argument1;
|
41
|
+
private final short argument2;
|
42
|
+
private final short flags;
|
43
|
+
private final short glyphIndex;
|
44
|
+
private double xscale = 1.0;
|
45
|
+
private double yscale = 1.0;
|
46
|
+
private double scale01 = 0.0;
|
47
|
+
private double scale10 = 0.0;
|
48
|
+
private int xtranslate = 0;
|
49
|
+
private int ytranslate = 0;
|
50
|
+
private int point1 = 0;
|
51
|
+
private int point2 = 0;
|
52
|
+
|
53
|
+
protected GlyfCompositeComp(int firstIndex, int firstContour, ByteArrayInputStream bais) {
|
54
|
+
this.firstIndex = firstIndex;
|
55
|
+
this.firstContour = firstContour;
|
56
|
+
flags = (short)(bais.read()<<8 | bais.read());
|
57
|
+
glyphIndex = (short)(bais.read()<<8 | bais.read());
|
58
|
+
|
59
|
+
// Get the arguments as just their raw values
|
60
|
+
if ((flags & ARG_1_AND_2_ARE_WORDS) != 0) {
|
61
|
+
argument1 = (short)(bais.read()<<8 | bais.read());
|
62
|
+
argument2 = (short)(bais.read()<<8 | bais.read());
|
63
|
+
} else {
|
64
|
+
argument1 = (short) bais.read();
|
65
|
+
argument2 = (short) bais.read();
|
66
|
+
}
|
67
|
+
|
68
|
+
// Assign the arguments according to the flags
|
69
|
+
if ((flags & ARGS_ARE_XY_VALUES) != 0) {
|
70
|
+
xtranslate = argument1;
|
71
|
+
ytranslate = argument2;
|
72
|
+
} else {
|
73
|
+
point1 = argument1;
|
74
|
+
point2 = argument2;
|
75
|
+
}
|
76
|
+
|
77
|
+
// Get the scale values (if any)
|
78
|
+
if ((flags & WE_HAVE_A_SCALE) != 0) {
|
79
|
+
int i = (short)(bais.read()<<8 | bais.read());
|
80
|
+
xscale = yscale = (double) i / (double) 0x4000;
|
81
|
+
} else if ((flags & WE_HAVE_AN_X_AND_Y_SCALE) != 0) {
|
82
|
+
short i = (short)(bais.read()<<8 | bais.read());
|
83
|
+
xscale = (double) i / (double) 0x4000;
|
84
|
+
i = (short)(bais.read()<<8 | bais.read());
|
85
|
+
yscale = (double) i / (double) 0x4000;
|
86
|
+
} else if ((flags & WE_HAVE_A_TWO_BY_TWO) != 0) {
|
87
|
+
int i = (short)(bais.read()<<8 | bais.read());
|
88
|
+
xscale = (double) i / (double) 0x4000;
|
89
|
+
i = (short)(bais.read()<<8 | bais.read());
|
90
|
+
scale01 = (double) i / (double) 0x4000;
|
91
|
+
i = (short)(bais.read()<<8 | bais.read());
|
92
|
+
scale10 = (double) i / (double) 0x4000;
|
93
|
+
i = (short)(bais.read()<<8 | bais.read());
|
94
|
+
yscale = (double) i / (double) 0x4000;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
public int getFirstIndex() {
|
99
|
+
return firstIndex;
|
100
|
+
}
|
101
|
+
|
102
|
+
public int getFirstContour() {
|
103
|
+
return firstContour;
|
104
|
+
}
|
105
|
+
|
106
|
+
public short getArgument1() {
|
107
|
+
return argument1;
|
108
|
+
}
|
109
|
+
|
110
|
+
public short getArgument2() {
|
111
|
+
return argument2;
|
112
|
+
}
|
113
|
+
|
114
|
+
public short getFlags() {
|
115
|
+
return flags;
|
116
|
+
}
|
117
|
+
|
118
|
+
public short getGlyphIndex() {
|
119
|
+
return glyphIndex;
|
120
|
+
}
|
121
|
+
|
122
|
+
public double getScale01() {
|
123
|
+
return scale01;
|
124
|
+
}
|
125
|
+
|
126
|
+
public double getScale10() {
|
127
|
+
return scale10;
|
128
|
+
}
|
129
|
+
|
130
|
+
public double getXScale() {
|
131
|
+
return xscale;
|
132
|
+
}
|
133
|
+
|
134
|
+
public double getYScale() {
|
135
|
+
return yscale;
|
136
|
+
}
|
137
|
+
|
138
|
+
public int getXTranslate() {
|
139
|
+
return xtranslate;
|
140
|
+
}
|
141
|
+
|
142
|
+
public int getYTranslate() {
|
143
|
+
return ytranslate;
|
144
|
+
}
|
145
|
+
|
146
|
+
/**
|
147
|
+
* Transforms an x-coordinate of a point for this component.
|
148
|
+
* @param x The x-coordinate of the point to transform
|
149
|
+
* @param y The y-coordinate of the point to transform
|
150
|
+
* @return The transformed x-coordinate
|
151
|
+
*/
|
152
|
+
public int scaleX(int x, int y) {
|
153
|
+
return Math.round((float)(x * xscale + y * scale10));
|
154
|
+
}
|
155
|
+
|
156
|
+
/**
|
157
|
+
* Transforms a y-coordinate of a point for this component.
|
158
|
+
* @param x The x-coordinate of the point to transform
|
159
|
+
* @param y The y-coordinate of the point to transform
|
160
|
+
* @return The transformed y-coordinate
|
161
|
+
*/
|
162
|
+
public int scaleY(int x, int y) {
|
163
|
+
return Math.round((float)(x * scale01 + y * yscale));
|
164
|
+
}
|
165
|
+
}
|