001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: the License. You may obtain a copy of the License at
009:
010: http://www.apache.org/licenses/LICENSE-2.0
011:
012: Unless required by applicable law or agreed to in writing, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.svggen.font.table;
020:
021: import java.io.IOException;
022: import java.io.RandomAccessFile;
023:
024: /**
025: *
026: * @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
027: * @version $Id: GsubTable.java 475477 2006-11-15 22:44:28Z cam $
028: */
029: public class GsubTable implements Table, LookupSubtableFactory {
030:
031: private ScriptList scriptList;
032: private FeatureList featureList;
033: private LookupList lookupList;
034:
035: protected GsubTable(DirectoryEntry de, RandomAccessFile raf)
036: throws IOException {
037: raf.seek(de.getOffset());
038:
039: // GSUB Header
040: /* int version = */raf.readInt();
041: int scriptListOffset = raf.readUnsignedShort();
042: int featureListOffset = raf.readUnsignedShort();
043: int lookupListOffset = raf.readUnsignedShort();
044:
045: // Script List
046: scriptList = new ScriptList(raf, de.getOffset()
047: + scriptListOffset);
048:
049: // Feature List
050: featureList = new FeatureList(raf, de.getOffset()
051: + featureListOffset);
052:
053: // Lookup List
054: lookupList = new LookupList(raf, de.getOffset()
055: + lookupListOffset, this );
056: }
057:
058: /**
059: * 1 - Single - Replace one glyph with one glyph
060: * 2 - Multiple - Replace one glyph with more than one glyph
061: * 3 - Alternate - Replace one glyph with one of many glyphs
062: * 4 - Ligature - Replace multiple glyphs with one glyph
063: * 5 - Context - Replace one or more glyphs in context
064: * 6 - Chaining - Context Replace one or more glyphs in chained context
065: */
066: public LookupSubtable read(int type, RandomAccessFile raf,
067: int offset) throws IOException {
068: LookupSubtable s = null;
069: switch (type) {
070: case 1:
071: s = SingleSubst.read(raf, offset);
072: break;
073: case 2:
074: // s = MultipleSubst.read(raf, offset);
075: break;
076: case 3:
077: // s = AlternateSubst.read(raf, offset);
078: break;
079: case 4:
080: s = LigatureSubst.read(raf, offset);
081: break;
082: case 5:
083: // s = ContextSubst.read(raf, offset);
084: break;
085: case 6:
086: // s = ChainingSubst.read(raf, offset);
087: break;
088: }
089: return s;
090: }
091:
092: /** Get the table type, as a table directory value.
093: * @return The table type
094: */
095: public int getType() {
096: return GSUB;
097: }
098:
099: public ScriptList getScriptList() {
100: return scriptList;
101: }
102:
103: public FeatureList getFeatureList() {
104: return featureList;
105: }
106:
107: public LookupList getLookupList() {
108: return lookupList;
109: }
110:
111: public String toString() {
112: return "GSUB";
113: }
114:
115: }
|