private boolean isAfmFile(RandomAccessFileOrArray raf) throws java.io.IOException { StringBuilder builder = new StringBuilder(AFM_HEADER.length()); for (int i = 0; i < AFM_HEADER.length(); i++) { try { builder.append((char)raf.readByte()); } catch (EOFException e) { raf.seek(0); return false; } } raf.seek(0); return AFM_HEADER.equals(builder.toString()); } }
protected int readNumGlyphs() throws java.io.IOException { int[] table_location = tables.get("maxp"); if (table_location == null) { return 65536; } else { raf.seek(table_location[0] + 4); return raf.readUnsignedShort(); } }
void seek(int offset) { try { buf.seek(offset); } catch (java.io.IOException e) { throw new IOException(IOException.IoException, e); } }
protected int readNumGlyphs() throws java.io.IOException { int[] table_location = tables.get("maxp"); if (table_location == null) { return 65536; } else { raf.seek(table_location[0] + 4); return raf.readUnsignedShort(); } }
void seek(int offset) { try { buf.seek(offset); } catch (java.io.IOException e) { throw new IOException(IOException.IoException, e); } }
public String checkPdfHeader() throws java.io.IOException { file.seek(0); String str = readString(1024); int idx = str.indexOf("%PDF-"); if (idx != 0) throw new IOException(IOException.PdfHeaderNotFound, this); return str.substring(idx + 1, idx + 8); }
public String checkPdfHeader() throws java.io.IOException { file.seek(0); String str = readString(1024); int idx = str.indexOf("%PDF-"); if (idx != 0) throw new IOException(IOException.PdfHeaderNotFound, this); return str.substring(idx + 1, idx + 8); }
public void checkFdfHeader() throws java.io.IOException { file.seek(0); String str = readString(1024); int idx = str.indexOf("%FDF-"); if (idx != 0) throw new IOException(IOException.FdfStartxrefNotFound, this); }
public OpenTypeScript(OpenTypeFontTableReader openTypeReader, int locationScriptTable) throws java.io.IOException { this.openTypeReader = openTypeReader; records = new ArrayList<>(); openTypeReader.rf.seek(locationScriptTable); TagAndLocation[] tagsLocs = openTypeReader.readTagAndLocations(locationScriptTable); for (TagAndLocation tagLoc : tagsLocs) { readScriptRecord(tagLoc); } }
public void checkFdfHeader() throws java.io.IOException { file.seek(0); String str = readString(1024); int idx = str.indexOf("%FDF-"); if (idx != 0) throw new IOException(IOException.FdfStartxrefNotFound, this); }
public OpenTypeScript(OpenTypeFontTableReader openTypeReader, int locationScriptTable) throws java.io.IOException { this.openTypeReader = openTypeReader; records = new ArrayList<>(); openTypeReader.rf.seek(locationScriptTable); TagAndLocation[] tagsLocs = openTypeReader.readTagAndLocations(locationScriptTable); for (TagAndLocation tagLoc : tagsLocs) { readScriptRecord(tagLoc); } }
@Override public void emit(byte[] buffer) { //System.err.println("range emit offset "+offset+" size="+length); try { buf.seek(offset); for (int i=myOffset; i<myOffset+length; i++) buffer[i] = buf.readByte(); } catch (java.io.IOException e) { throw new IOException(IOException.IoException, e); } //System.err.println("finished range emit"); } }
public static List<GposAnchor[]> readBaseArray(OpenTypeFontTableReader tableReader, int classCount, int location) throws java.io.IOException { List<GposAnchor[]> baseArray = new ArrayList<>(); tableReader.rf.seek(location); int baseCount = tableReader.rf.readUnsignedShort(); int[] anchorLocations = readUShortArray(tableReader.rf, baseCount * classCount, location); int idx = 0; for (int k = 0; k < baseCount; ++k) { baseArray.add(readAnchorArray(tableReader, anchorLocations, idx, idx + classCount)); idx += classCount; } return baseArray; }
public static List<GposAnchor[]> readBaseArray(OpenTypeFontTableReader tableReader, int classCount, int location) throws java.io.IOException { List<GposAnchor[]> baseArray = new ArrayList<>(); tableReader.rf.seek(location); int baseCount = tableReader.rf.readUnsignedShort(); int[] anchorLocations = readUShortArray(tableReader.rf, baseCount * classCount, location); int idx = 0; for (int k = 0; k < baseCount; ++k) { baseArray.add(readAnchorArray(tableReader, anchorLocations, idx, idx + classCount)); idx += classCount; } return baseArray; }
private void readLookupListTable(int lookupListTableLocation) throws java.io.IOException { lookupList = new ArrayList<>(); rf.seek(lookupListTableLocation); int lookupCount = rf.readUnsignedShort(); int[] lookupTableLocations = readUShortArray(lookupCount, lookupListTableLocation); // read LookUp tables for (int lookupLocation : lookupTableLocations) { if (lookupLocation == 0) { // be tolerant to NULL offset in LookupList table continue; } readLookupTable(lookupLocation); } }
private void readLookupListTable(int lookupListTableLocation) throws java.io.IOException { lookupList = new ArrayList<>(); rf.seek(lookupListTableLocation); int lookupCount = rf.readUnsignedShort(); int[] lookupTableLocations = readUShortArray(lookupCount, lookupListTableLocation); // read LookUp tables for (int lookupLocation : lookupTableLocations) { if (lookupLocation == 0) { // be tolerant to NULL offset in LookupList table continue; } readLookupTable(lookupLocation); } }
private void readLookupTable(int lookupTableLocation) throws java.io.IOException { rf.seek(lookupTableLocation); int lookupType = rf.readUnsignedShort(); int lookupFlag = rf.readUnsignedShort(); int subTableCount = rf.readUnsignedShort(); int[] subTableLocations = readUShortArray(subTableCount, lookupTableLocation); lookupList.add(readLookupTable(lookupType, lookupFlag, subTableLocations)); } }
private void readLookupTable(int lookupTableLocation) throws java.io.IOException { rf.seek(lookupTableLocation); int lookupType = rf.readUnsignedShort(); int lookupFlag = rf.readUnsignedShort(); int subTableCount = rf.readUnsignedShort(); int[] subTableLocations = readUShortArray(subTableCount, lookupTableLocation); lookupList.add(readLookupTable(lookupType, lookupFlag, subTableLocations)); } }
private LanguageRecord readLanguageRecord(TagAndLocation tagLoc) throws java.io.IOException { LanguageRecord rec = new LanguageRecord(); //skip lookup order openTypeReader.rf.seek(tagLoc.location + 2); rec.featureRequired = openTypeReader.rf.readUnsignedShort(); int count = openTypeReader.rf.readUnsignedShort(); rec.features = openTypeReader.readUShortArray(count); rec.tag = tagLoc.tag; return rec; } }
private LanguageRecord readLanguageRecord(TagAndLocation tagLoc) throws java.io.IOException { LanguageRecord rec = new LanguageRecord(); //skip lookup order openTypeReader.rf.seek(tagLoc.location + 2); rec.featureRequired = openTypeReader.rf.readUnsignedShort(); int count = openTypeReader.rf.readUnsignedShort(); rec.features = openTypeReader.readUShortArray(count); rec.tag = tagLoc.tag; return rec; } }