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.
- 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,55 @@
|
|
|
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: ClassDefFormat1.java,v 1.3 2004/08/18 07:15:19 vhardy Exp $
|
|
27
|
+
*/
|
|
28
|
+
public class ClassDefFormat1 extends ClassDef {
|
|
29
|
+
|
|
30
|
+
private final int startGlyph;
|
|
31
|
+
private final int glyphCount;
|
|
32
|
+
private final int[] classValues;
|
|
33
|
+
|
|
34
|
+
/** Creates new ClassDefFormat1
|
|
35
|
+
* @param raf
|
|
36
|
+
* @throws java.io.IOException */
|
|
37
|
+
public ClassDefFormat1(RandomAccessFileEmulator raf) throws IOException {
|
|
38
|
+
startGlyph = raf.readUnsignedShort();
|
|
39
|
+
glyphCount = raf.readUnsignedShort();
|
|
40
|
+
classValues = new int[glyphCount];
|
|
41
|
+
for (int i = 0; i < glyphCount; i++) {
|
|
42
|
+
classValues[i] = raf.readUnsignedShort();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @return
|
|
49
|
+
*/
|
|
50
|
+
@Override
|
|
51
|
+
public int getFormat() {
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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: ClassDefFormat2.java,v 1.3 2004/08/18 07:15:19 vhardy Exp $
|
|
27
|
+
*/
|
|
28
|
+
public class ClassDefFormat2 extends ClassDef {
|
|
29
|
+
|
|
30
|
+
private final int classRangeCount;
|
|
31
|
+
private final RangeRecord[] classRangeRecords;
|
|
32
|
+
|
|
33
|
+
/** Creates new ClassDefFormat2
|
|
34
|
+
* @param raf
|
|
35
|
+
* @throws java.io.IOException */
|
|
36
|
+
public ClassDefFormat2(RandomAccessFileEmulator raf) throws IOException {
|
|
37
|
+
classRangeCount = raf.readUnsignedShort();
|
|
38
|
+
classRangeRecords = new RangeRecord[classRangeCount];
|
|
39
|
+
for (int i = 0; i < classRangeCount; i++) {
|
|
40
|
+
classRangeRecords[i] = new RangeRecord(raf);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Override
|
|
45
|
+
public int getFormat() {
|
|
46
|
+
return 2;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
* @version $Id: CmapFormat.java,v 1.4 2004/09/01 09:35:23 deweese Exp $
|
|
26
|
+
* @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
|
|
27
|
+
*/
|
|
28
|
+
public abstract class CmapFormat {
|
|
29
|
+
|
|
30
|
+
protected int format;
|
|
31
|
+
protected int length;
|
|
32
|
+
protected int version;
|
|
33
|
+
|
|
34
|
+
protected CmapFormat(RandomAccessFileEmulator raf) throws IOException {
|
|
35
|
+
length = raf.readUnsignedShort();
|
|
36
|
+
version = raf.readUnsignedShort();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
protected static CmapFormat create(int format, RandomAccessFileEmulator raf)
|
|
40
|
+
throws IOException {
|
|
41
|
+
switch(format) {
|
|
42
|
+
case 0:
|
|
43
|
+
return new CmapFormat0(raf);
|
|
44
|
+
case 2:
|
|
45
|
+
return new CmapFormat2(raf);
|
|
46
|
+
case 4:
|
|
47
|
+
return new CmapFormat4(raf);
|
|
48
|
+
case 6:
|
|
49
|
+
return new CmapFormat6(raf);
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public int getFormat() {
|
|
55
|
+
return format;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public int getLength() {
|
|
59
|
+
return length;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public int getVersion() {
|
|
63
|
+
return version;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public abstract int mapCharCode(int charCode);
|
|
67
|
+
|
|
68
|
+
public abstract int getFirst();
|
|
69
|
+
public abstract int getLast();
|
|
70
|
+
|
|
71
|
+
@Override
|
|
72
|
+
public String toString() {
|
|
73
|
+
return new StringBuilder()
|
|
74
|
+
.append("format: ")
|
|
75
|
+
.append(format)
|
|
76
|
+
.append(", length: ")
|
|
77
|
+
.append(length)
|
|
78
|
+
.append(", version: ")
|
|
79
|
+
.append(version).toString();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
* Simple Macintosh cmap table, mapping only the ASCII character set to glyphs.
|
|
25
|
+
*
|
|
26
|
+
* @version $Id: CmapFormat0.java,v 1.4 2004/09/01 09:35:23 deweese Exp $
|
|
27
|
+
* @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
|
|
28
|
+
*/
|
|
29
|
+
public class CmapFormat0 extends CmapFormat {
|
|
30
|
+
|
|
31
|
+
private final int[] glyphIdArray = new int[256];
|
|
32
|
+
private int first, last;
|
|
33
|
+
|
|
34
|
+
protected CmapFormat0(RandomAccessFileEmulator raf) throws IOException {
|
|
35
|
+
super(raf);
|
|
36
|
+
format = 0;
|
|
37
|
+
first = -1;
|
|
38
|
+
for (int i = 0; i < 256; i++) {
|
|
39
|
+
glyphIdArray[i] = raf.readUnsignedByte();
|
|
40
|
+
if (glyphIdArray[i] > 0) {
|
|
41
|
+
if (first == -1) first = i;
|
|
42
|
+
last = i;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Override
|
|
48
|
+
public int getFirst() { return first; }
|
|
49
|
+
@Override
|
|
50
|
+
public int getLast() { return last; }
|
|
51
|
+
|
|
52
|
+
@Override
|
|
53
|
+
public int mapCharCode(int charCode) {
|
|
54
|
+
if (0 <= charCode && charCode < 256) {
|
|
55
|
+
return glyphIdArray[charCode];
|
|
56
|
+
} else {
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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: CmapFormat2.java,v 1.4 2004/09/01 09:35:23 deweese Exp $
|
|
25
|
+
* @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
|
|
26
|
+
*/
|
|
27
|
+
public class CmapFormat2 extends CmapFormat {
|
|
28
|
+
|
|
29
|
+
private final short[] subHeaderKeys = new short[256];
|
|
30
|
+
private int[] subHeaders1;
|
|
31
|
+
private int[] subHeaders2;
|
|
32
|
+
private short[] glyphIndexArray;
|
|
33
|
+
|
|
34
|
+
protected CmapFormat2(RandomAccessFileEmulator raf) throws IOException {
|
|
35
|
+
super(raf);
|
|
36
|
+
format = 2;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
public int getFirst() { return 0; }
|
|
41
|
+
@Override
|
|
42
|
+
public int getLast() { return 0; }
|
|
43
|
+
|
|
44
|
+
@Override
|
|
45
|
+
public int mapCharCode(int charCode) {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
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
|
+
* @version $Id: CmapFormat4.java,v 1.6 2004/09/01 09:35:23 deweese Exp $
|
|
25
|
+
* @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
|
|
26
|
+
*/
|
|
27
|
+
public class CmapFormat4 extends CmapFormat {
|
|
28
|
+
|
|
29
|
+
public int language;
|
|
30
|
+
private final int segCountX2;
|
|
31
|
+
private final int searchRange;
|
|
32
|
+
private final int entrySelector;
|
|
33
|
+
private final int rangeShift;
|
|
34
|
+
private final int[] endCode;
|
|
35
|
+
private final int[] startCode;
|
|
36
|
+
private final int[] idDelta;
|
|
37
|
+
private final int[] idRangeOffset;
|
|
38
|
+
private final int[] glyphIdArray;
|
|
39
|
+
private final int segCount;
|
|
40
|
+
private int first, last;
|
|
41
|
+
|
|
42
|
+
protected CmapFormat4(RandomAccessFileEmulator raf) throws IOException {
|
|
43
|
+
super(raf);
|
|
44
|
+
format = 4;
|
|
45
|
+
segCountX2 = raf.readUnsignedShort();
|
|
46
|
+
segCount = segCountX2 / 2;
|
|
47
|
+
endCode = new int[segCount];
|
|
48
|
+
startCode = new int[segCount];
|
|
49
|
+
idDelta = new int[segCount];
|
|
50
|
+
idRangeOffset = new int[segCount];
|
|
51
|
+
searchRange = raf.readUnsignedShort();
|
|
52
|
+
entrySelector = raf.readUnsignedShort();
|
|
53
|
+
rangeShift = raf.readUnsignedShort();
|
|
54
|
+
last = -1;
|
|
55
|
+
for (int i = 0; i < segCount; i++) {
|
|
56
|
+
endCode[i] = raf.readUnsignedShort();
|
|
57
|
+
if (endCode[i] > last) last = endCode[i];
|
|
58
|
+
}
|
|
59
|
+
raf.readUnsignedShort(); // reservePad
|
|
60
|
+
for (int i = 0; i < segCount; i++) {
|
|
61
|
+
startCode[i] = raf.readUnsignedShort();
|
|
62
|
+
if ((i==0 ) || (startCode[i] < first)) first = startCode[i];
|
|
63
|
+
}
|
|
64
|
+
for (int i = 0; i < segCount; i++) {
|
|
65
|
+
idDelta[i] = raf.readUnsignedShort();
|
|
66
|
+
}
|
|
67
|
+
for (int i = 0; i < segCount; i++) {
|
|
68
|
+
idRangeOffset[i] = raf.readUnsignedShort();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Whatever remains of this header belongs in glyphIdArray
|
|
72
|
+
int count = (length - 16 - (segCount*8)) / 2;
|
|
73
|
+
glyphIdArray = new int[count];
|
|
74
|
+
for (int i = 0; i < count; i++) {
|
|
75
|
+
glyphIdArray[i] = raf.readUnsignedShort();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@Override
|
|
80
|
+
public int getFirst() { return first; }
|
|
81
|
+
@Override
|
|
82
|
+
public int getLast() { return last; }
|
|
83
|
+
|
|
84
|
+
@Override
|
|
85
|
+
public int mapCharCode(int charCode) {
|
|
86
|
+
try {
|
|
87
|
+
/*
|
|
88
|
+
Quoting :
|
|
89
|
+
http://developer.apple.com/fonts/TTRefMan/RM06/Chap6cmap.html#Surrogates
|
|
90
|
+
|
|
91
|
+
The original architecture of the Unicode Standard
|
|
92
|
+
allowed for all encoded characters to be represented
|
|
93
|
+
using sixteen bit code points. This allowed for up to
|
|
94
|
+
65,354 characters to be encoded. (Unicode code points
|
|
95
|
+
U+FFFE and U+FFFF are reserved and unavailable to
|
|
96
|
+
represent characters. For more details, see The Unicode
|
|
97
|
+
Standard.)
|
|
98
|
+
|
|
99
|
+
My comment : Isn't there a typo here ? Shouldn't we
|
|
100
|
+
rather read 65,534 ?
|
|
101
|
+
*/
|
|
102
|
+
if ((charCode < 0) || (charCode >= 0xFFFE))
|
|
103
|
+
return 0;
|
|
104
|
+
|
|
105
|
+
for (int i = 0; i < segCount; i++) {
|
|
106
|
+
if (endCode[i] >= charCode) {
|
|
107
|
+
if (startCode[i] <= charCode) {
|
|
108
|
+
if (idRangeOffset[i] > 0) {
|
|
109
|
+
return glyphIdArray[idRangeOffset[i]/2 +
|
|
110
|
+
(charCode - startCode[i]) -
|
|
111
|
+
(segCount - i)];
|
|
112
|
+
} else {
|
|
113
|
+
return (idDelta[i] + charCode) % 65536;
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
} catch (ArrayIndexOutOfBoundsException e) {
|
|
121
|
+
System.err.println("error: Array out of bounds - " + e.getMessage());
|
|
122
|
+
}
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@Override
|
|
127
|
+
public String toString() {
|
|
128
|
+
return new StringBuilder()
|
|
129
|
+
.append(super.toString())
|
|
130
|
+
.append(", segCountX2: ")
|
|
131
|
+
.append(segCountX2)
|
|
132
|
+
.append(", searchRange: ")
|
|
133
|
+
.append(searchRange)
|
|
134
|
+
.append(", entrySelector: ")
|
|
135
|
+
.append(entrySelector)
|
|
136
|
+
.append(", rangeShift: ")
|
|
137
|
+
.append(rangeShift)
|
|
138
|
+
.append(", endCode: ")
|
|
139
|
+
.append(endCode)
|
|
140
|
+
.append(", startCode: ")
|
|
141
|
+
.append(endCode)
|
|
142
|
+
.append(", idDelta: ")
|
|
143
|
+
.append(idDelta)
|
|
144
|
+
.append(", idRangeOffset: ")
|
|
145
|
+
.append(idRangeOffset).toString();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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: CmapFormat6.java,v 1.4 2004/09/01 09:35:23 deweese Exp $
|
|
25
|
+
* @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
|
|
26
|
+
*/
|
|
27
|
+
public class CmapFormat6 extends CmapFormat {
|
|
28
|
+
|
|
29
|
+
private final short cformat;
|
|
30
|
+
private short clength;
|
|
31
|
+
private short cversion;
|
|
32
|
+
private short firstCode;
|
|
33
|
+
private short entryCount;
|
|
34
|
+
private short[] glyphIdArray;
|
|
35
|
+
|
|
36
|
+
protected CmapFormat6(RandomAccessFileEmulator raf) throws IOException {
|
|
37
|
+
super(raf);
|
|
38
|
+
cformat = 6;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Override
|
|
42
|
+
public int getFirst() { return 0; }
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @return
|
|
47
|
+
*/
|
|
48
|
+
@Override
|
|
49
|
+
public int getLast() { return 0; }
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param charCode
|
|
54
|
+
* @return
|
|
55
|
+
*/
|
|
56
|
+
@Override
|
|
57
|
+
public int mapCharCode(int charCode) {
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
}
|