@Override public void seek(long pos) throws IOException { stream.seek(pos); }
/** * Read the given table if necessary. Package-private, used by TTFParser only. * * @param table the table to be initialized * * @throws IOException if there was an error reading the table. */ void readTable(TTFTable table) throws IOException { // PDFBOX-4219: synchronize on data because it is accessed by several threads // when PDFBox is accessing a standard 14 font for the first time synchronized (data) { // save current position long currentPosition = data.getCurrentPosition(); data.seek(table.getOffset()); table.read(this, data); // restore current position data.seek(currentPosition); } }
private TrueTypeFont getFontAtIndex(int idx) throws IOException { stream.seek(fontOffsets[idx]); TTFParser parser; if (stream.readTag().equals("OTTO")) { parser = new OTFParser(false, true); } else { parser = new TTFParser(false, true); } stream.seek(fontOffsets[idx]); return parser.parse(new TTCDataStream(stream)); }
/** * Returns the raw bytes of the given table. * @param table the table to read. * @throws IOException if there was an error accessing the table. */ public byte[] getTableBytes(TTFTable table) throws IOException { synchronized (lockReadtable) { // save current position long currentPosition = data.getCurrentPosition(); data.seek(table.getOffset()); // read all data byte[] bytes = data.read((int) table.getLength()); // restore current position data.seek(currentPosition); return bytes; } }
private FeatureTable readFeatureTable(TTFDataStream data, long offset) throws IOException { data.seek(offset); int featureParams = data.readUnsignedShort(); int lookupIndexCount = data.readUnsignedShort(); int[] lookupListIndices = new int[lookupIndexCount]; for (int i = 0; i < lookupIndexCount; i++) { lookupListIndices[i] = data.readUnsignedShort(); } return new FeatureTable(featureParams, lookupIndexCount, lookupListIndices); }
private LigatureSetTable readLigatureSetTable(TTFDataStream data, long ligatureSetTableLocation, int coverageGlyphId) throws IOException { data.seek(ligatureSetTableLocation); int ligatureCount = data.readUnsignedShort(); LOG.debug("ligatureCount=" + ligatureCount); int[] ligatureOffsets = new int[ligatureCount]; LigatureTable[] ligatureTables = new LigatureTable[ligatureCount]; for (int i = 0; i < ligatureOffsets.length; i++) { ligatureOffsets[i] = data.readUnsignedShort(); } for (int i = 0; i < ligatureOffsets.length; i++) { int ligatureOffset = ligatureOffsets[i]; ligatureTables[i] = readLigatureTable(data, ligatureSetTableLocation + ligatureOffset, coverageGlyphId); } return new LigatureSetTable(ligatureCount, ligatureTables); }
private LigatureTable readLigatureTable(TTFDataStream data, long ligatureTableLocation, int coverageGlyphId) throws IOException { data.seek(ligatureTableLocation); int ligatureGlyph = data.readUnsignedShort(); int componentCount = data.readUnsignedShort(); int[] componentGlyphIDs = new int[componentCount]; componentGlyphIDs[0] = coverageGlyphId; for (int i = 1; i <= componentCount - 1; i++) { componentGlyphIDs[i] = data.readUnsignedShort(); } return new LigatureTable(ligatureGlyph, componentCount, componentGlyphIDs); }
private Map<String, ScriptTable> readScriptList(TTFDataStream data, long offset) throws IOException { data.seek(offset); int scriptCount = data.readUnsignedShort(); ScriptTable[] scriptTables= new ScriptTable[scriptCount]; int[] scriptOffsets = new int[scriptCount]; String[] scriptTags = new String[scriptCount]; for (int i = 0; i < scriptCount; i++) { scriptTags[i] = data.readString(4); scriptOffsets[i] = data.readUnsignedShort(); } for (int i = 0; i < scriptCount; i++) { scriptTables[i] = readScriptTable(data, offset + scriptOffsets[i]); } Map<String, ScriptTable> resultScriptList = new LinkedHashMap<>(scriptCount); for (int i = 0; i < scriptCount; i++) { ScriptRecord scriptRecord = new ScriptRecord(scriptTags[i], scriptTables[i]); resultScriptList.put(scriptRecord.getScriptTag(), scriptRecord.getScriptTable()); } return Collections.unmodifiableMap(resultScriptList); }
private LookupListTable readLookupList(TTFDataStream data, long offset) throws IOException { data.seek(offset); int lookupCount = data.readUnsignedShort(); int[] lookups = new int[lookupCount]; for (int i = 0; i < lookupCount; i++) { lookups[i] = data.readUnsignedShort(); } LookupTable[] lookupTables = new LookupTable[lookupCount]; for (int i = 0; i < lookupCount; i++) { lookupTables[i] = readLookupTable(data, offset + lookups[i]); } return new LookupListTable(lookupCount, lookupTables); }
private LangSysTable readLangSysTable(TTFDataStream data, long offset) throws IOException { data.seek(offset); int lookupOrder = data.readUnsignedShort(); int requiredFeatureIndex = data.readUnsignedShort(); int featureIndexCount = data.readUnsignedShort(); int[] featureIndices = new int[featureIndexCount]; for (int i = 0; i < featureIndexCount; i++) { featureIndices[i] = data.readUnsignedShort(); } return new LangSysTable(lookupOrder, requiredFeatureIndex, featureIndexCount, featureIndices); }
data.seek(offset + offsets[gid]);
data.seek(glyphOffset); int glyphIndex = data.readUnsignedShort(); if (glyphIndex != 0)
private ScriptTable readScriptTable(TTFDataStream data, long offset) throws IOException data.seek(offset); int defaultLangSys = data.readUnsignedShort(); int langSysCount = data.readUnsignedShort();
private FeatureListTable readFeatureList(TTFDataStream data, long offset) throws IOException { data.seek(offset); int featureCount = data.readUnsignedShort(); FeatureRecord[] featureRecords = new FeatureRecord[featureCount]; int[] featureOffsets = new int[featureCount]; String[] featureTags = new String[featureCount]; for (int i = 0; i < featureCount; i++) { featureTags[i] = data.readString(4); featureOffsets[i] = data.readUnsignedShort(); } for (int i = 0; i < featureCount; i++) { FeatureTable featureTable = readFeatureTable(data, offset + featureOffsets[i]); featureRecords[i] = new FeatureRecord(featureTags[i], featureTable); } return new FeatureListTable(featureCount, featureRecords); }
private CoverageTable readCoverageTable(TTFDataStream data, long offset) throws IOException data.seek(offset); int coverageFormat = data.readUnsignedShort(); switch (coverageFormat)
private LookupSubTable readLigatureSubstitutionSubtable(TTFDataStream data, long offset) throws IOException data.seek(offset); int substFormat = data.readUnsignedShort();
private LookupTable readLookupTable(TTFDataStream data, long offset) throws IOException data.seek(offset); int lookupType = data.readUnsignedShort(); int lookupFlag = data.readUnsignedShort();
private LookupSubTable readLookupSubTable(TTFDataStream data, long offset) throws IOException { data.seek(offset); int substFormat = data.readUnsignedShort(); switch (substFormat) { case 1: { int coverageOffset = data.readUnsignedShort(); short deltaGlyphID = data.readSignedShort(); CoverageTable coverageTable = readCoverageTable(data, offset + coverageOffset); return new LookupTypeSingleSubstFormat1(substFormat, coverageTable, deltaGlyphID); } case 2: { int coverageOffset = data.readUnsignedShort(); int glyphCount = data.readUnsignedShort(); int[] substituteGlyphIDs = new int[glyphCount]; for (int i = 0; i < glyphCount; i++) { substituteGlyphIDs[i] = data.readUnsignedShort(); } CoverageTable coverageTable = readCoverageTable(data, offset + coverageOffset); return new LookupTypeSingleSubstFormat2(substFormat, coverageTable, substituteGlyphIDs); } default: throw new IllegalArgumentException("Unknown substFormat: " + substFormat); } }
data.seek(cmap.getOffset() + subTableOffset); int subtableFormat = data.readUnsignedShort(); long length;