private int readInt(RandomAccessFileOrArray stream) throws java.io.IOException { if (isBigEndian) { return stream.readInt(); } else { return stream.readIntLE(); } }
private int readInt(RandomAccessFileOrArray stream) throws java.io.IOException { if (isBigEndian) { return stream.readInt(); } else { return stream.readIntLE(); } }
/** * {@inheritDoc} */ public float readFloat() throws java.io.IOException { return Float.intBitsToFloat(readInt()); }
/** * {@inheritDoc} */ public float readFloat() throws java.io.IOException { return Float.intBitsToFloat(readInt()); }
int getInt() { try { return buf.readInt(); } catch (java.io.IOException e) { throw new IOException(IOException.IoException, e); } }
int getInt() { try { return buf.readInt(); } catch (java.io.IOException e) { throw new IOException(IOException.IoException, e); } }
private Map<Integer, int[]> readFormat12() throws java.io.IOException { Map<Integer, int[]> h = new LinkedHashMap<>(); raf.skipBytes(2); @SuppressWarnings("unused") int table_length = raf.readInt(); raf.skipBytes(4); int nGroups = raf.readInt(); for (int k = 0; k < nGroups; k++) { int startCharCode = raf.readInt(); int endCharCode = raf.readInt(); int startGlyphID = raf.readInt(); for (int i = startCharCode; i <= endCharCode; i++) { int[] r = new int[2]; r[0] = startGlyphID; r[1] = getGlyphWidth(r[0]); h.put(i, r); startGlyphID++; } } return h; } }
private Map<Integer, int[]> readFormat12() throws java.io.IOException { Map<Integer, int[]> h = new LinkedHashMap<>(); raf.skipBytes(2); @SuppressWarnings("unused") int table_length = raf.readInt(); raf.skipBytes(4); int nGroups = raf.readInt(); for (int k = 0; k < nGroups; k++) { int startCharCode = raf.readInt(); int endCharCode = raf.readInt(); int startGlyphID = raf.readInt(); for (int i = startCharCode; i <= endCharCode; i++) { int[] r = new int[2]; r[0] = startGlyphID; r[1] = getGlyphWidth(r[0]); h.put(i, r); startGlyphID++; } } return h; } }
protected void createTableDirectory() throws java.io.IOException { tableDirectory = new HashMap<>(); rf.seek(directoryOffset); int id = rf.readInt(); if (id != 0x00010000) { throw new IOException(IOException.NotAtTrueTypeFile).setMessageParams(fileName); } int num_tables = rf.readUnsignedShort(); rf.skipBytes(6); for (int k = 0; k < num_tables; ++k) { String tag = readStandardString(4); int[] tableLocation = new int[3]; tableLocation[TABLE_CHECKSUM] = rf.readInt(); tableLocation[TABLE_OFFSET] = rf.readInt(); tableLocation[TABLE_LENGTH] = rf.readInt(); tableDirectory.put(tag, tableLocation); } }
protected void createTableDirectory() throws java.io.IOException { tableDirectory = new HashMap<>(); rf.seek(directoryOffset); int id = rf.readInt(); if (id != 0x00010000) { throw new IOException(IOException.NotAtTrueTypeFile).setMessageParams(fileName); } int num_tables = rf.readUnsignedShort(); rf.skipBytes(6); for (int k = 0; k < num_tables; ++k) { String tag = readStandardString(4); int[] tableLocation = new int[3]; tableLocation[TABLE_CHECKSUM] = rf.readInt(); tableLocation[TABLE_OFFSET] = rf.readInt(); tableLocation[TABLE_LENGTH] = rf.readInt(); tableDirectory.put(tag, tableLocation); } }
private void initFontSize() throws java.io.IOException { String mainTag = raf.readString(4, PdfEncodings.WINANSI); if (!mainTag.equals("ttcf")) { throw new IOException(IOException.InvalidTtcFile); } raf.skipBytes(4); TTCSize = raf.readInt(); } }
private void initFontSize() throws java.io.IOException { String mainTag = raf.readString(4, PdfEncodings.WINANSI); if (!mainTag.equals("ttcf")) { throw new IOException(IOException.InvalidTtcFile); } raf.skipBytes(4); TTCSize = raf.readInt(); } }
void readSegment(Jbig2Segment s) throws java.io.IOException { int ptr = (int) ra.getPosition(); if (s.dataLength == 0xffffffffl) { // TODO figure this bit out, 7.2.7 return; } byte[] data = new byte[(int) s.dataLength]; ra.read(data); s.data = data; if (s.type == PAGE_INFORMATION) { int last = (int) ra.getPosition(); ra.seek(ptr); int page_bitmap_width = ra.readInt(); int page_bitmap_height = ra.readInt(); ra.seek(last); Jbig2Page p = pages.get(s.page); if (p == null) { throw new com.itextpdf.io.IOException("Referring to widht or height of a page we haven't seen yet: {0}").setMessageParams(s.page); } p.pageBitmapWidth = page_bitmap_width; p.pageBitmapHeight = page_bitmap_height; } }
private void readPostTable() throws java.io.IOException { int[] table_location = tables.get("post"); if (table_location != null) { raf.seek(table_location[0] + 4); short mantissa = raf.readShort(); int fraction = raf.readUnsignedShort(); post = new PostTable(); post.italicAngle = (float) (mantissa + fraction / 16384.0d); post.underlinePosition = raf.readShort(); post.underlineThickness = raf.readShort(); post.isFixedPitch = raf.readInt() != 0; } else { post = new OpenTypeParser.PostTable(); post.italicAngle = (float) (-Math.atan2(hhea.caretSlopeRun, hhea.caretSlopeRise) * 180 / Math.PI); } }
private void readPostTable() throws java.io.IOException { int[] table_location = tables.get("post"); if (table_location != null) { raf.seek(table_location[0] + 4); short mantissa = raf.readShort(); int fraction = raf.readUnsignedShort(); post = new PostTable(); post.italicAngle = (float) (mantissa + fraction / 16384.0d); post.underlinePosition = raf.readShort(); post.underlineThickness = raf.readShort(); post.isFixedPitch = raf.readInt() != 0; } else { post = new OpenTypeParser.PostTable(); post.italicAngle = (float) (-Math.atan2(hhea.caretSlopeRun, hhea.caretSlopeRise) * 180 / Math.PI); } }
void readFileHeader() throws java.io.IOException { ra.seek(0); byte[] idstring = new byte[8]; ra.read(idstring); byte[] refidstring = {(byte) 0x97, 0x4A, 0x42, 0x32, 0x0D, 0x0A, 0x1A, 0x0A}; for (int i = 0; i < idstring.length; i++) { if (idstring[i] != refidstring[i]) { throw new com.itextpdf.io.IOException("File header idstring is not good at byte {0}").setMessageParams(i); } } int fileheaderflags = ra.read(); this.sequential = (fileheaderflags & 0x1) == 0x1; this.number_of_pages_known = (fileheaderflags & 0x2) == 0x0; if ((fileheaderflags & 0xfc) != 0x0) { throw new com.itextpdf.io.IOException("File header flags bits from 2 to 7 should be 0, some not"); } if (this.number_of_pages_known) { this.number_of_pages = ra.readInt(); } }
void readFileHeader() throws java.io.IOException { ra.seek(0); byte[] idstring = new byte[8]; ra.read(idstring); byte[] refidstring = {(byte) 0x97, 0x4A, 0x42, 0x32, 0x0D, 0x0A, 0x1A, 0x0A}; for (int i = 0; i < idstring.length; i++) { if (idstring[i] != refidstring[i]) { throw new com.itextpdf.io.IOException("File header idstring is not good at byte {0}").setMessageParams(i); } } int fileheaderflags = ra.read(); this.sequential = (fileheaderflags & 0x1) == 0x1; this.number_of_pages_known = (fileheaderflags & 0x2) == 0x0; if ((fileheaderflags & 0xfc) != 0x0) { throw new com.itextpdf.io.IOException("File header flags bits from 2 to 7 should be 0, some not"); } if (this.number_of_pages_known) { this.number_of_pages = ra.readInt(); } }
/** * This is the starting point of the class. A sub-class must call this * method to start getting call backs to the {@link #readLookupTable(int, int, int[])} * method. * @throws FontReadingException */ final void startReadingTable() throws FontReadingException { try { rf.seek(tableLocation); /*int version =*/ rf.readInt(); //version not used int scriptListOffset = rf.readUnsignedShort(); int featureListOffset = rf.readUnsignedShort(); int lookupListOffset = rf.readUnsignedShort(); // read the Script tables scriptsType = new OpenTypeScript(this, tableLocation + scriptListOffset); // read Feature table featuresType = new OpenTypeFeature(this, tableLocation + featureListOffset); // read LookUpList table readLookupListTable(tableLocation + lookupListOffset); } catch (java.io.IOException e) { throw new FontReadingException("Error reading font file", e); } }