diff options
author | David Schweinsberg <[email protected]> | 2017-05-11 21:44:20 -0700 |
---|---|---|
committer | David Schweinsberg <[email protected]> | 2017-05-11 21:44:20 -0700 |
commit | 3a61bed3a754fbfcfa98e0a130f3ed330c34996b (patch) | |
tree | 9a64a4647c46b0fb671b565c2134c59e9cc00ace /src | |
parent | d3f008a1071af02e26153a367b203b30f2ac35fc (diff) |
Added some more tables
Diffstat (limited to 'src')
-rw-r--r-- | src/net/java/dev/typecast/ot/table/ColrTable.java | 78 | ||||
-rw-r--r-- | src/net/java/dev/typecast/ot/table/CpalTable.java | 27 | ||||
-rw-r--r-- | src/net/java/dev/typecast/ot/table/GdefTable.java | 27 | ||||
-rw-r--r-- | src/net/java/dev/typecast/ot/table/Table.java | 2 | ||||
-rw-r--r-- | src/net/java/dev/typecast/ot/table/TableFactory.java | 7 |
5 files changed, 141 insertions, 0 deletions
diff --git a/src/net/java/dev/typecast/ot/table/ColrTable.java b/src/net/java/dev/typecast/ot/table/ColrTable.java new file mode 100644 index 0000000..7ae60c0 --- /dev/null +++ b/src/net/java/dev/typecast/ot/table/ColrTable.java @@ -0,0 +1,78 @@ + +package net.java.dev.typecast.ot.table; + +import java.io.DataInput; +import java.io.IOException; + +/** + * @author <a href="mailto:[email protected]">David Schweinsberg</a> + */ +public class ColrTable implements Table { + + public class BaseGlyphRecord { + private final int _gid; + private final int _firstLayerIndex; + private final int _numLayers; + + protected BaseGlyphRecord(DataInput di) throws IOException { + _gid = di.readUnsignedShort(); + _firstLayerIndex = di.readUnsignedShort(); + _numLayers = di.readUnsignedShort(); + } + } + + public class LayerRecord { + private final int _gid; + private final int _paletteIndex; + + protected LayerRecord(DataInput di) throws IOException { + _gid = di.readUnsignedShort(); + _paletteIndex = di.readUnsignedShort(); + } + } + + private final DirectoryEntry _de; + private final int _version; + private final int _numBaseGlyphRecords; + private final int _offsetBaseGlyphRecord; + private final int _offsetLayerRecord; + private final int _numLayerRecords; + private final BaseGlyphRecord[] _baseGlyphRecords; + private final LayerRecord[] _layerRecords; + + protected ColrTable(DirectoryEntry de, DataInput di) throws IOException { + this._de = (DirectoryEntry) de.clone(); + _version = di.readUnsignedShort(); + _numBaseGlyphRecords = di.readUnsignedShort(); + _offsetBaseGlyphRecord = di.readInt(); + _offsetLayerRecord = di.readInt(); + _numLayerRecords = di.readUnsignedShort(); + + _baseGlyphRecords = new BaseGlyphRecord[_numBaseGlyphRecords]; + for (int i = 0; i < _numBaseGlyphRecords; ++i) { + _baseGlyphRecords[i] = new BaseGlyphRecord(di); + } + + _layerRecords = new LayerRecord[_numLayerRecords]; + for (int i = 0; i < _numLayerRecords; ++i) { + _layerRecords[i] = new LayerRecord(di); + } + } + + @Override + public String toString() { + return new StringBuffer() + .append("'COLR' Table\n---------------------------------------") + .toString(); + } + + @Override + public int getType() { + return COLR; + } + + @Override + public DirectoryEntry getDirectoryEntry() { + return _de; + } +} diff --git a/src/net/java/dev/typecast/ot/table/CpalTable.java b/src/net/java/dev/typecast/ot/table/CpalTable.java new file mode 100644 index 0000000..5326537 --- /dev/null +++ b/src/net/java/dev/typecast/ot/table/CpalTable.java @@ -0,0 +1,27 @@ + +package net.java.dev.typecast.ot.table; + +import java.io.DataInput; +import java.io.IOException; + +/** + * @author <a href="mailto:[email protected]">David Schweinsberg</a> + */ +public class CpalTable implements Table { + + private DirectoryEntry _de; + + protected CpalTable(DirectoryEntry de, DataInput di) throws IOException { + this._de = (DirectoryEntry) de.clone(); + } + + @Override + public int getType() { + return CPAL; + } + + @Override + public DirectoryEntry getDirectoryEntry() { + return _de; + } +} diff --git a/src/net/java/dev/typecast/ot/table/GdefTable.java b/src/net/java/dev/typecast/ot/table/GdefTable.java new file mode 100644 index 0000000..2358aa9 --- /dev/null +++ b/src/net/java/dev/typecast/ot/table/GdefTable.java @@ -0,0 +1,27 @@ + +package net.java.dev.typecast.ot.table; + +import java.io.DataInput; +import java.io.IOException; + +/** + * @author <a href="mailto:[email protected]">David Schweinsberg</a> + */ +public class GdefTable implements Table { + + private DirectoryEntry _de; + + protected GdefTable(DirectoryEntry de, DataInput di) throws IOException { + this._de = (DirectoryEntry) de.clone(); + } + + @Override + public int getType() { + return GDEF; + } + + @Override + public DirectoryEntry getDirectoryEntry() { + return _de; + } +} diff --git a/src/net/java/dev/typecast/ot/table/Table.java b/src/net/java/dev/typecast/ot/table/Table.java index 0145b9f..7d6319d 100644 --- a/src/net/java/dev/typecast/ot/table/Table.java +++ b/src/net/java/dev/typecast/ot/table/Table.java @@ -25,6 +25,8 @@ public interface Table { // Table constants public static final int BASE = 0x42415345; // Baseline data [OpenType] public static final int CFF = 0x43464620; // PostScript font program (compact font format) [PostScript] + public static final int COLR = 0x434f4c52; // Color Table + public static final int CPAL = 0x4350414c; // Color Palette Table public static final int DSIG = 0x44534947; // Digital signature public static final int EBDT = 0x45424454; // Embedded bitmap data public static final int EBLC = 0x45424c43; // Embedded bitmap location data diff --git a/src/net/java/dev/typecast/ot/table/TableFactory.java b/src/net/java/dev/typecast/ot/table/TableFactory.java index 91a2e33..2034ce7 100644 --- a/src/net/java/dev/typecast/ot/table/TableFactory.java +++ b/src/net/java/dev/typecast/ot/table/TableFactory.java @@ -51,6 +51,12 @@ public class TableFactory { case Table.CFF: t = new CffTable(de, dis); break; + case Table.COLR: + t = new ColrTable(de, dis); + break; + case Table.CPAL: + t = new CpalTable(de, dis); + break; case Table.DSIG: t = new DsigTable(de, dis); break; @@ -61,6 +67,7 @@ public class TableFactory { case Table.EBSC: break; case Table.GDEF: + t = new GdefTable(de, dis); break; case Table.GPOS: t = new GposTable(de, dis); |