aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Schweinsberg <[email protected]>2016-01-07 15:05:10 -0800
committerDavid Schweinsberg <[email protected]>2016-01-07 15:05:10 -0800
commit819814a4e205aab253ca75f3ad983a7b97ba2b0f (patch)
treeb77e14481cdb7832a98d717aa6c7120be3183a1e
parent4402728d950ba43e700aa063f7529b6b266706c5 (diff)
cmap Format 6 implemented
-rw-r--r--src/net/java/dev/typecast/ot/table/CmapFormat6.java31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/net/java/dev/typecast/ot/table/CmapFormat6.java b/src/net/java/dev/typecast/ot/table/CmapFormat6.java
index 6c5dfac..a956a6c 100644
--- a/src/net/java/dev/typecast/ot/table/CmapFormat6.java
+++ b/src/net/java/dev/typecast/ot/table/CmapFormat6.java
@@ -22,36 +22,45 @@ import java.io.DataInput;
import java.io.IOException;
/**
- * TODO: To be implemented
+ * Format 6: Trimmed table mapping
* @author <a href="mailto:[email protected]">David Schweinsberg</a>
*/
public class CmapFormat6 extends CmapFormat {
- private short _firstCode;
- private short _entryCount;
- private short[] _glyphIdArray;
+ private final int _firstCode;
+ private final int _entryCount;
+ private final int[] _glyphIdArray;
protected CmapFormat6(DataInput di) throws IOException {
super(di);
_format = 6;
-
- // HACK: As this is not yet implemented, we need to skip over the bytes
- // we should be consuming
- di.skipBytes(_length - 6);
+ _firstCode = di.readUnsignedShort();
+ _entryCount = di.readUnsignedShort();
+ _glyphIdArray = new int[_entryCount];
+ for (int i = 0; i < _entryCount; i++) {
+ _glyphIdArray[i] = di.readUnsignedShort();
+ }
}
@Override
public int getRangeCount() {
- return 0;
+ return 1;
}
@Override
public Range getRange(int index) throws ArrayIndexOutOfBoundsException {
- throw new ArrayIndexOutOfBoundsException();
+ if (index != 0) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ return new Range(_firstCode, _entryCount);
}
@Override
public int mapCharCode(int charCode) {
- return 0;
+ if (_firstCode <= charCode && charCode < _firstCode + _entryCount) {
+ return _glyphIdArray[charCode - _firstCode];
+ } else {
+ return 0;
+ }
}
}